Jump to content
marcus

wireshell - an extendable ProcessWire command line interface

Recommended Posts

Thanks, but I prefer to keep the visual language simpler and the reference to PW subtle (its brand colors).

  • Like 2

Share this post


Link to post
Share on other sites

I missed the possibility to download a module from github if it doesn't exist in the ProcessWire module directory or if you need a specific branch.

Added^_^

  • Like 5

Share this post


Link to post
Share on other sites

Just started toying with wireshell, this is great stuff. Some remarks about the 'new' command:

- Unless i'm missing something the new command will always install 'site-default'. Wouldn't it be nice to be able to choose between the bundled profiles that ship with PW?

- Currently the unused profiles (site-languages, site-classic etc.) are not being cleaned up after install.

- I can't exactly figure out how or where ('timezone' => "366"??), but the timezone in config.php after install seems to be 'Europe/Zurich'. Not a big deal but this does not make a lot of sense as some kind of default.

Keep up the good work guys!

  • Like 1

Share this post


Link to post
Share on other sites

Unless i'm missing something the new command will always install 'site-default'. Wouldn't it be nice to be able to choose between the bundled profiles that ship with PW?

I don't recall, but it is not that hard if not made.

Share this post


Link to post
Share on other sites

There is an option --profile={value}, but it isn't working for me with the default profiles of the download package. When I try it, I get those error messages:

D:\TEMP\pw2>ws new pw2 --profile=site-languages

 Downloading ProcessWire...
 Preparing project...

 Extracting profile...

  [RuntimeException]
  The profile can't be installed because the downloaded package is corrupted
  or because the installer doesn't have enough permissions to uncompress and
  rename the package contents.
  File "site-languages" does not exist

I have also tried with --profile=languages instead of site-languages.

The downloaded package isn't corrupted, without setting the profile option it works perfect, but installes only the default profile automatically. :)

Share this post


Link to post
Share on other sites

Hey Horst, 

The profile you need to pass is the zip file once you export the site. So it can install from old profiles. Hope that make sense.

  • Like 3

Share this post


Link to post
Share on other sites

Hi Hari,

ah, ok. That's great. So I can pass it the path to a custom profile in a zip archive to install this instead of one from the PW distribution. Thanks for making it. :)

  • Like 1

Share this post


Link to post
Share on other sites

Exactly :-) . The features were actually sponsored by someone who don't wish to reveal the name :) .

  • Like 1

Share this post


Link to post
Share on other sites

A little update on timing (of 0.4.0):

Right now I'm drowning in client work and simultaneously many PR's are coming in (which is totally cool!). Since there's a public holiday mid-May here in Germany, I hope to find the time to release 0.4.0 then, together with a microsite containing better documentation (which is necessary as the last posts here proove), some info on contributing, gathered knowledge especially on Windows and MAMP/Mac usage.

Also, clsource has raised the totally valid point of testing. While Symfony Console is more than ready I'm not sure how to mock/fake/implement the ProcessWire API layer (but also I'm kind of novice in testing). Has anyone an idea of how to do so (maybe it's much easier than I think)? Either way - thanks on input! :)

Edited by marcus
  • Like 3

Share this post


Link to post
Share on other sites

Hi Hari,

ah, ok. That's great. So I can pass it the path to a custom profile in a zip archive to install this instead of one from the PW distribution. Thanks for making it. :)

Totally agreed, great stuff. It is described in the docs as well: https://github.com/marcus-herrmann/wireshell#custom-profile-processwire-installation-%CF%80

On top of that i still think it would be a neat addition to be able to also choose from one of the bundled profiles:

site-beginner
site-blank
site-classic 
site-default 
site-languages

Once again, no critique, just an idea. Great work.

  • Like 1

Share this post


Link to post
Share on other sites

Two suggestions. If I make a mistake, writing the db password for instance, I have to start all over from the download. Even if I noticed that I typed the wrong info, there's nothing I can do to correct it.

1. allow to correct wrong input before submitting

2. create a command to install from the last download

Share this post


Link to post
Share on other sites

I really like this project, but something that i got annoyed is that there is no uniformity how command name:action pair is formed.

I don't personally care which way they are but currently there are:

mod:enable

backup:db

I would like to see that it's either of, where it's name:action or action:name pair, so i can rely on some logic.

Not a biggie but still :)

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

I would like to see that it's either of, where it's name:action or action:name pair, so i can rely on some logic.

Agreed. Such things are no deal-breakers, but annoying nevertheless.

Additionally, since we're (kind of) discussing smaller details here, what's with the "mod" part -- why not call it "module"? Seems like it's the only thing that gets shortened, and thus looks like another API inconsistency to me. Again: small, but annoying  :)

Share this post


Link to post
Share on other sites

I found another one for ya: show:version. Show is a verb, version is a noun. So it is now almoast equal amount of right commands and annoying ones)

I guess we shall just name things different. First word is a something more general, second is something less general inside of that more general realm. Things will be more clear as soon as we have not only backup:db, but also backup:files and backup:site, backup:templates and backup:all.

I would also vote for backup:and-upload-to-my-live-server ))

Share this post


Link to post
Share on other sites

Thanks for all the input on this. The "mod" namespace is renamed to "module" already on develop branch, the "show" namespace in abandoned in favor of a more generic "status" command, also available on dev.

I agree with Ivan when it comes to "general:specific" in general and the "backup" namespace in particular - although it's just the :db command right now, I plan to extend this namespace with :all (db and all scripts), :files (just /site/assets/files). But in the big picture I'll try to reach a naming scheme close to the API - modules will never by named plugins ;) and I don't really know why exactly I shortened "modules" to "mods" down in the past...

  • Like 6

Share this post


Link to post
Share on other sites
I missed some more user commands, pls have a look here (again mismatched pull request number  :angry: ).

**user:create**

- adds possibility to set a password

**user:list**

- list all users

- optional: limit output by role

**user:delete**

- delete users by username, comma separated

**user:update**

- updates username, role, email, password for an existing user

Share this post


Link to post
Share on other sites

Cool! Thanks! Was about to release 0.4.0 today, but will squeeze your additions in!

Share this post


Link to post
Share on other sites

wireshell 0.4.0 is out  :) 

Big update with a lot of contributed commands and interfaces: "Module Download" command, extended "Module Enable" command, enhanced "User Create", added "User Delete", "User List" and "User Update" (thanks @justb3a). "Module Generate" command using modules.pw (thanks @nico), added "Status" command listing information on development, ProcessWire installation, image libraries (thanks @horst). wireshell's code and documentation were extended/cleaned up by @clsource. Also 0.4.0 introduced documentation microsite, wireshell.pw

wireshell_pw_screenshot.png

Sorry, justbea and clsource, I seem to have messed up the PR's in a way that you aren't listed as project contributors on the GitHub page :(

Edited by marcus
  • Like 9

Share this post


Link to post
Share on other sites

Hi all, really great work.

Why don't you use this logo you have posted before? I think it is much better then the one on the website.

ws_draft.gif

You're right - fixed. That other logo was actually an older version.

Share this post


Link to post
Share on other sites

After upgrade I get this error:Fatal error:

Can't use method return value in write context in /Users/lpa/.composer/vendor/wireshell/wireshell/src/Helpers/PwUserTools.php on line 71
 

What might go wrong?

Share this post


Link to post
Share on other sites

I am running version 5.4.37 on Mac 10.9. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      Going through my long quest to get better with ajax and utilizing the api, I have hit yet another roadblock. I currently have a form with an image field (thanks to flydev for getting that sorted), "title" text input, and a select field set to multiple. In my ajax call, I added in:
      tags = $("#select-tags").val(); form_data.append('tags', tags); $.ajax({ type: 'POST', data: form_data, contentType: false, processData: false, url: '/ajax/upload-preview/', success: function(data) { console.log("Woo"); }, error: function(xhr, ajaxOptions, thrownError) { alert(xhr.responseText); } }); And in the ajax template: 
      $tags = $sanitizer->text($_POST['tags']); $image = $sanitizer->text($_POST['image']); $p = new Page(); $p->template = "preview"; $p->parent = $pages->get("/previews/"); $p->name = $title; $p->title = $title; $p->tags = $tags; $p->save(); If I select a "tag" from the select input and submit, it does indeed add it to the Page Reference field in the backend. However, this does not work with an array being passed to it of multiple options.

      So it does appear that my ajax call is trying to submit multiple options, but I am really just unsure how to get these two added in. I saw in other forums posts of add($page) and even add(array()). Do I need to handle this js array differently or do  I need to foreach through the $tags to add it like:
      foreach($tags as $tag) { $p->tags->add($tag); $p->save(); } I tried this approach, but apparently I am still missing something.
       
      Edit:
      I was doing some tweaking, and I know I can split the js array out like:
      for (i = 0, len = tags.length; i < len; i++) { console.log(tags[i]); } However, I am not sure then how to handle the POST in php if I were to split it out.
    • By louisstephens
      I have been messing around with creating pages from ajax requests, and it has gone swimmingly thus far. However, I am really struggling with creating a page and saving an image via ajax. 
      The form:
      <form action="./" role="form" method="post" enctype="multipart/form-data"> <div> <input type="text" id="preview" name="preview" placeholder="Image Title"> </div> <div> <input type="file" id="preview-name" name="preview-name"> </div> <div> <select id="select-tags" name="select-tags"> <?php $tags = $pages->find("template=tag"); ?> <option value="">Select Your Tags</option> <?php foreach ($tags as $tag) : ?> <option value="<?= $tag->name; ?>"><?= $tag->name; ?></option> <?php endforeach; ?> </select> </div> <div> <button type="button" id="submit-preview" name="submit" class="">Upload Images</button> </div> </form>  
      The ajax in my home template:
      $('#submit-preview').click(function(e) { e.preventDefault(); title = $("#preview").val(); image = $("input[name=preview-name]"); console.log(title); console.log(image); data = { title: title, image: image //not sure if this is actually needed }; $.ajax({ type: 'POST', data: data, url: '/development/upload-preview/', success: function(data) { console.log("Woo"); }, error: function(xhr, ajaxOptions, thrownError) { alert(xhr.responseText); } }); }); And finally in my ajax template:
      $imagePath = $config->paths->assets . "files/pdfs/"; //was from an older iteration $title = $sanitizer->text($_POST['title']); $image = $sanitizer->text($_POST['image']); $p = new Page(); $p->template = "preview"; $p->parent = $pages->get("/previews/"); $p->name = $title; $p->title = $title; $p->save(); $p->setOutputFormatting(false); $u = new WireUpload('preview_image'); $u->setMaxFiles(1); $u->setOverwrite(false); $u->setDestinationPath($p->preview_image->path()); $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png', 'pdf')); foreach($u->execute() as $filename) { $p->preview_image->add($filename); } $p->save(); I can complete the file upload but just using a simple post to the same page and it it works well, but I was really trying to work out the ajax on this so I could utilize some modals for success on creation (and to keep my templates a little cleaner). When I do run the code I have, a new/blank folder is created under assets, and a new page is created with the correct title entered. However, no image is being processed. I do get a 200 status in my console. I have searched google for help, but everything seems to be slightly off from my needs. If anyone could help point me in the right direction I would greatly appreciate it. 
    • By louisstephens
      This might be a completely dumb question, but I cant seem to wrap my head around it. I have a page reference field that allows users to select "Tags". In the front end I would like to use the titles as class names for a single item. ie:
      <?php $previews = $pages->find("template=preview"); ?> <?php foreach($previews as $preview): ?> <div class="tagOne TagTwo tagThree"> <!-- use another foreach to output--> <img src="<?=$preview->preview_image->url; ?>" /> </div> <?php endforeach; ?> I am little stumped as I know I need a foreach loop to produce each tag title, but how do I insert them all into one corresponding div class with spaces?
      Whelp, that was the easiest thing, but my brain just didnt "get it". Just put the foreach in the "class" inside of the overall foreach. Ugh 😓
    • By schwarzdesign
      We recently rebuilt the Architekturführer Köln (architectural guide Cologne) as a mobile-first JavaScript web app, powered by VueJS in the frontend and ProcessWire in the backend. Concept, design and implementation by schwarzdesign!
      The Architekturführer Köln is a guidebook and now a web application about architectural highlights in Cologne, Germany. It contains detailled information about around 100 objects (architectural landmarks) in Cologne. The web app offers multiple ways to search through all available objects, including:
      An interactive live map A list of object near the user's location Filtering based on architect, district and category Favourites saved by the user The frontend is written entirely in JavaScript, with the data coming from a ProcessWire-powered API-first backend.
      Frontend
      The app is built with the Vue framework and compiled with Webpack 4. As a learning exercise and for greater customizability we opted to not use Vue CLI, and instead wrote our own Webpack config with individually defined dependencies.
      The site is a SPA (Single Page Application), which means all internal links are intercepted by the Vue app and the corresponding routes (pages) are generated by the framework directly in the browser, using data retrieved from the API. It's also a PWA (Progressive Web App), the main feature of which is that you can install it to your home screen on your phone and launch it from there like a regular app. It also includes a service worker which catches requests to the API and returns cached responses when the network is not available. The Architekturführer is supposed to be taken with you on a walk through the city, and will keep working even if you are completely offline.
      Notable mentions from the tech stack:
      Vue Vue Router for the SPA functionality VueX for state management and storage / caching of the data returned through the API Leaflet (with Mapbox tiles) for the interactive maps Webpack 4 for compilation of the app into a single distributable Babel for transpilation of ES6+ SASS & PostCSS with Autoprefixer as a convenience for SASS in SFCs Google Workbox to generate the service worker instead of writing lots of boilerplate code Bootstrap 4 is barely used here, but we still included it's reboot and grid system Backend
      The ProcessWire backend is API-only, there are no server-side rendered templates, which means the only PHP template is the one used for the API. For this API, we used a single content type (template) with a couple of pre-defined endpoints (url segments); most importantly we built entdpoints to get a list of all objects (either including the full data, or only the data necessary to show teaser tiles), as well as individual objects and taxonomies. The API template which acts as a controller contains all the necessary switches and selectors to serve the correct response in <100 lines of code.
      Since we wanted some flexibility regarding the format in which different fields were transmitted over the api, we wrote a function to extract arbitrary page fields from ProcessWire pages and return them as serializable standard objects. There's also a function that takes a Pageimage object, creates multiple variants in different sizes and returns an object containing their base path and an array of variants (identified by their basename and width). We use that one to generate responsive images in the frontend. Check out the code for both functions in this gist.
      We used native ProcessWire data wherever possible, so as to not duplicate that work in the frontend app. For example:
      Page names from the backend translate to URLs in the frontend in the form of route parameters for the Vue Router Page IDs from ProcessWire are included in the API responses, we use those to identify objects across the app, for example to store the user's favourites, and as render keys for object lists Taxonomies have their own API endpoints, and objects contain their taxonomies only as IDs (in the same way ProcessWire uses Page References) Finally, the raw JSON data is cached using the cache API and this handy trick by @LostKobrakai to store raw JSON strings over the cache API.
      Screenshots














    • By VeiJari
      Hello forum!
      I've yet again stumbled on a head-scratching situation. We have enabled the option on our articles template and events template that it skips the title adding part and goes straight to the form. This is what our customer wants. So when you add a new article or event it automatically names it temporary to "article-0000000" and same with event. Now the problem is that obviously after saving the form we want to change to page url or "name" to the title, like it's normally. 
      Now here's the code for the hook:
      wire()->addHookBefore("Pages::saved(template=tapahtuma|artikkeli)", function($hook) {
        $page = $hook->arguments(0);
        $newUrl = wire()->sanitizer->pageName($page->title); // give it a name used in the url for the page
        wire()->log->message($page->name);
        $page->setAndSave('name', $newUrl);
      });
      I get the correct page and the name and path changes when I log them, but when I try to save it. It just loads and then I get: 
      Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) This happens in sanitizer.php
      and then another error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0
       
      What is happening? Am I not suppose to use sanitizer in this way? When we made a temporary page object in out other hook, the sanitizer worked perfectly.
      Thanks for the help!
×
×
  • Create New...