Regarding Editorial

Shopping for Vinyl with Drafts and Editorial

Recorded on March 18th, 2016

The other day on a recent Back to Work (and I can’t remember which one exactly), Merlin explained to Dan about how to prepend and append text to a draft in Drafts. I’ve used this trick, but more often for prepending than for than appending. When Merlin described the use cases, I realized that appending can be especially powerful if you’ve started the bare bones of a draft, and just want to dump a bunch of hyperlinks, ideas, or whatever into it when you think of them.

Before I went record shopping the other day (thanks to a Steady Sounds birthday gift card from my thoughtful wife!), I wanted to collect all the stuff that I meant to be on the lookout for and put it in a temporary music to buy today.txt file. I typically have a long-standing music to check out.txt file and an LPs to buy.txt file in Dropbox that I can get to with Editorial or Notesy. There are entries scattered all over those two files, and I’m able to focus more in the record store if I have one consolidated, top-priority list instead of switching between two of them. So I quickly scrolled through each of those reference files, selected the text for each record or song I wanted to watch for, and tapped the Share action.

photo of selecting and sharing text on iOS

After that, I’d tap “Append” on the pop-up Drafts share sheet. image of Drafts share sheet

And behind the scenes, the line would append to the music to buy today draft. This is what it looked like after appending a bunch of items.

image of a line appended to an entry in Drafts app

After I collected all the vital music to look for, I sent the draft over to Editorial, and used the Sort Selection workflow from @olemoritz (the creator of Editorial) to alphabetize the lines. And then I used Federico Vittici’s List workflow to turn those lines into an unordered Markdown list.

image of an ordered Markdown list

Finally, I used the Preview mode in Editorial to actually pull up the list when I was in the store. The nice thing about Preview mode is that you can’t accidentally go into edit mode by tapping the screen. It’s just like a piece of paper, but on the phone.

image of a Markdown list in Editorial Preview

In practice, it is actually very quick to go through all these steps. The Drafts share sheet just does its thing and gets out of the way. And Editorial can do anything you can dream up if you find/build the workflow for it. Once you try this process, you’ll think of all sorts of uses for it.

A Regex Pattern for Editorial to Select a Single TaskPaper Project

Recorded on February 15th, 2016

I had a breakthrough today! I was stepping through some old TaskPaper-formatted projects in Editorial and wanted a quick way to grab a project and shoot it to a someday/maybe/later file so it wouldn’t clutter up my main Current.taskpaper file. I figured the best way would be to tap the folding triangle icon to fold the project, select it, cut it, and paste it to Backlog.taskpaper. But I didn’t want to leave the Bluetooth keyboard to do it, and I didn’t see an existing workflow to fold a single TaskPaper project.

I always separate TaskPaper projects with a blank line, just so they have some breathing space. I realized that if I put the cursor in the current project header line and made a workflow to select that whole line, and then do a regex to find and extend the selection to also grab all the tasks + notes underneath the project, then I could cut and paste that into another file. I haven’t finished that whole workflow, but I did finally figure out the regex pattern. It’s this:

(?s)(.*?)\n{2}

The key to this was an answer on Stack Overflow, where someone was looking for something similar. The \n{2} is the trick that searches for two newlines in a row, which will find the blank line underneath my project. Everything else in the pattern just selects all the lines in the current project until that point.

Playing with this would have been impossible if it weren’t for the eternally useful RegEx101, where you can plug in a regex and test it against your own text until you get the match you need.

screenshot of RegEx101

Here’s what the finished regex looks like in the Find action.

screenshot of Find action

And here’s Editorial’s automatic selection of just the current project.

screenshot of selected project in Editorial

I’ll share the whole workflow once I finish it and get it working totally right.

I Don’t Get Text Encoding in Editorial/Python

Recorded on February 11th, 2016

For a week, I was using the Editorial FTP Upload workflow from Macdrifter, and then realized yesterday that the text encoding it was doing in this section was converting “>” characters to > entities.

encode_string = cgi.escape(postContent).encode('ascii', 'xmlcharrefreplace')

I think this is what messes up Markdown blockquotes when Statamic renders a page. It also prevents passing any HTML through Markdown, which you’re supposed to be able to do if you need to.

I tried a bunch of stuff, changing the encoding from xmlcharrefreplace to replace or ignore, but I had no idea what I was doing, and tampering with encoding when you don’t know Python seems like a bad idea. In the end, I switched to Gabe’s alternative SFTP Upload, since it accomplishes the same thing but doesn’t confuse Statamic with the encoding.