Drafts' New Automation Options Make Your iPad As Powerful As Your Mac [Feature] | Cult of Mac

Drafts’ New Automation Options Make Your iPad As Powerful As Your Mac [Feature]


Drafts just went from essential to, uh, really really essential.
Drafts just went from essential to, uh, really really essential.

Drafts, the default inbox for text on your iOS device, has just been updated to version 1.5 on the iPad and v2.5 on the iPhone. And, man, what an update!

Previously, Drafts was a great way to scribble down a note, and then send it off to pretty much any text-based app you could think of. Now, with two big new features called “URL Actions” and “Dropbox Actions,” Drafts not only becomes more powerful than you could possible imagine, it also lets you automate a whole lot of notetaking tasks.

How powerful are we talking about here? How about controlling your Mac at home from your iPhone by just jotting down a note?

Drafts is a fast-opening app which is designed to live in your iPhone or iPad dock. It opens to a blank text field with the keyboard already activated, so you can type your idea, note, or the phone number of that girl you just met on the bus.

Once you have typed it you choose where to send it (or not – Drafts actually works pretty well as a note-keeping app, and syncs with your other devices). This is where the magic comes, letting you send a simple email, preview a Markdown essay, share to OmniFocus, Dropbox, create a (native iOS) reminder or calendar entry, or any of seemingly endless other export options.

In v1.5 and 2.5, you can now do a lot more with Dropbox, and you can add custom URL-scheme-based actions for any app that supports them.

Dropbox Actions

drafts dropaction1
Adding a new action is easy, but powerful.

Dropbox actions expands on Drafts’ existing ability to either create a new TXT file in Dropbox or append your new note to an existing file. Now Drafts has access to your whole Dropbox (you’ll need to re-authorize it), whereas previously it was limited to a single file for appending, and a single folder for file creation.

drafts dropaction2
Once it’s created, your action appears alongside the built-in ones.

Now you can have any number of actions, all designed to do things in different places on your Dropbox. Here are a few examples:

dropbox view
The resulting shopping list, as seen in Dropbox.

Use Cases:

Adding text to any TXT file in your Dropbox

For example, you could add a line to the end (or the beginning, thanks to the new prepend feature) of your shopping list, your ToDo list, or even add a section to a document containing that amazing novel you’ll totally get around to finishing one day.

Automating your Mac

What? Yes, you could use text commands to automate your Mac. Just have a utility like Hazel watch a folder for new text files, and have it act on them when certain parameters are matched. You could, for instance, paste in a URL for a torrent file and have it automatically downloaded to your Mac.

You can also specify how the file is created, and how it is chopped up to make your note.

You can choose how the file is named. It can either be a predefined name (you want this if you are prepending text to a list, as in my shopping list example pictured here) or based on the date, the time, or the first line of the note.

The body of the text can be tweaked, too. If you chose to use the note’s first line as its title, then you can exclude that line from the new note’s body. This is probably easiest to explain by looking at the list of tokens you can use in note creation:

[[draft]] : The full text of the draft.

[[title]] : The first line of the draft only.

[[body]] : The remainder of the draft text after the first line is removed.

[[time]] : Timestamp in the format YYYY-MM-DD-HH-MM-SS.

[[timeshort]] : Timestamp in the format 1/1/70 12:00 AM.

[[timelong]] : Timestamp in the format January 1, 1970, 12:00:00 AM CST.

To use another example, you could create a single “Journal” file and have Drafts prepend new entries to the top, along with a date stamp. This would give you a single text file with your personal diary broken into daily chunks, in reverse chronological order (newest at the top). The possibilities are almost endless. But we’re just getting started.

The other – arguably even bigger – new feature is URL actions.

URL Actions

If you have used older versions of Drafts to send text to other apps, you have used URL actions. This is pretty much the only way iOS apps can talk to each other: An app, let’s say Fantastical, can be opened by using a URL. At its most literal, you could enter the URL into Safari to launch the app (in fact, appending a “g” to the start of a URL in Safari will open that page in Goodreader).

But URL schemes also let you pass on extra information along with just opening the target app, similar in effect to how bookmarklets can send, say, selected text to a web service. What you can send is determined by the receiving app, but these are the available options that Drafts can provide:

Name: The label that will appear in the action list.

URL: The URL to open when the action is fired. The following placeholders will be replaced with URL encoded values:

[[draft]] : The full text of the draft.

[[title]] : The first line of the draft only.

[[body]] : The remainder of the draft text after the first line is removed.

By its nature, Drafts provides only a few pieces of data to the target app, but looked at another way, it can provide all of your data as a payload, plus some extras.

Works with the web, too

Plenty of export options.
Plenty of export options.

But wait! Because this works by using custom URLs, you can also create actions to send notes to websites, creating a custom, site-specific Google search, for instance.


You can also share your actions, either by mailing them to yourself right from the action creation screen, or by posting them to the web. To help with this, developer Greg Pierce (the brains behind Agile Tortoise) has put up a page where you can share and find actions. And of course these actions use Drafts’ own drafts:// URL scheme to open them directly in the app, letting you easily “sync” actions between versions of Drafts on your various iDevices just by tapping a link.

Expect this directory to get full, fast.

URL Callbacks and Action Triggers

The final part of the puzzle comes in the form of “URL callbacks”. You know the URL actions I mentioned above? There’s another piece of info you can tack onto their payload. Also invented by Pierce, they’re called “x-callback-urls,” and they allow the app to include it’s own URL when it opens another app. It’s like when we used to send self-addressed envelopes with our mail so people could send a reply easily.

An example should make it clearer. Say you have an app which can post entries to your blog (The excellent Poster app, for example). Using x-callback-urls, you could write a blog post in your favorite text editing app and tap a button to have that entry sent off to Poster, where you could add a title and send it off to your blog.

Then, when it’s done posting, Poster will return you to the original app, automatically. As a bonus, Poster can also include a payload of data, perhaps returning the URL of the post you just made.

As you can see, this start to tie iOS apps together in a way only seen on the desktop. And the real magic is that these apps can all work together, despite never knowing that the others exist. It’s both secure and sandbox-friendly.

A Services Menu for iOS?

Drafts’ support for URL callbacks comes just days after custom URL actions were added to Mr. Reader, my favorite RSS reader for the iPad. Right now you need to hand-craft these custom export triggers, but it’s easy to see a time where there’s a central repository letting you install actions with one tap.

One of iOS’s biggest failings when you use it for work is the lack of communication between apps. Both Windows 8 and Android let apps register their abilities with the OS, and therefore make them available to other apps – this is why you can use What’s App as the default SMS app on your Galaxy phone.

This clever hack might end up being the thing that finally turns your iPad into a useful work computer.

iOS doesn’t even let apps see outside of their own sandboxes, which makes communication hard. But as more and more apps implement URL schemes that let other apps blindly pass them data, and that let them send a reply, then complex and useful things start to happen. For example, you could send a photo off to your favorite editing app, add some stupid light leaks and have it sent back onto an original app to post to Twitter, all without ever saving the image to your camera roll.

It might not seem so exciting now, but this super clever hack might end up being the thing that finally turns your iPad into a useful work computer.

Source: Agile Tortoise

Thanks: Greg!


Daily round-ups or a weekly refresher, straight from Cult of Mac to your inbox.

  • The Weekender

    The week's best Apple news, reviews and how-tos from Cult of Mac, every Saturday morning. Our readers say: "Thank you guys for always posting cool stuff" -- Vaughn Nevins. "Very informative" -- Kenly Xavier.