Before I wrote my previous post, I put out a call on Twitter for an iOS app that cleans short links and that also supports x-callback-url. After all the work of adapting a Pythonista script to resolve a short Dropbox link, I finally received a response from @malanowski: Clean Links. Although I cannot find any x-callback-url documentation on the web, there is documentation in the app itself.
I’ve now written a Launch Center Pro action that does the exact same thing as described in my previous post but without the hassle of creating a script in Pythonista. All you have to do is tap on this link while on your iPhone and install the action in Launch Center Pro.
Take a photo, tap on the LCP action, and your shared Dropbox image is available for publication in Markdown format in TextTool. From there you can tap on
Open In... to send to your favorite text editor.
The Geeky Details
This action uses three
x=success parameters, each of which is URL-encoded. The final TextTool transform is tripe-URL-encoded.
First, LCP adds the last-taken photo to Dropbox — by default to
/Apps/Launch Center Pro/photos and makes the URL shareable. It is offered in a short URL (
db.tt). This URL is sent to Clean Links, and the resolved URL is sent to TextTool. TextTool uses the
replace method to swap
dl. It then takes that output and adds the Markdown elements (
Here are each of the
x-success parameters URL-decoded.
This is encoded once:
This is encoded twice:
This is encoded three times:
And actually the Markdown elements are encoded in the above action:
This routines allows you to do the following:
- Take a photo with your iPhone.
- Tap on the “Upload to Markdown” Launch Center Pro action.
- Get a Markdown image link (made shareable in Dropbox) in TextTool.
What It Does Step-by-Step
- Launch Center Pro uses its new Photo Attachment action to upload the last-taken photo to Dropbox. This link, which looks like
db.tt/___.jpg, is a shortened URL of the shareable link on Dropbox.
- The Launch Center Pro action (if you’re on your iPhone, tap on this link to install it) then sends the clipboard contents to Pythonista.
- The Pythonista CleanURL script (get the code here and then create a new script in the app and call it CleanURL) resolves the shortened URL and sends it to TextTool.
- TextTool replaces the
dl. In this URL format, the actual image (instead of a download page for the image) would load in the browser. (Example: download page resolved from short Dropbox URL; the image itself which will redirect to
dl.dropboxusercontent.comin the browser.)
- TextTool then takes this transform and uses the affix method to add Markdown elements to the URL to make it an image link.
- You can then use the Open In… action to send it to your favorite text editor and then publish it.
The Geeky Details
The Launch Center Pro action is as follows:
By default it uploads the last-taken photo to the
/Apps/Launch Center Pro/photos folder in Dropbox. It then sends the link to Pythonista. Here is the
x-success parameter URL-decoded:
(The Python script and this URL action are adapted from Federico Viticci at MacStories.)
Pythonista resolves the short URL and sends the results to TextTool. Here is the complete URL scheme at the end of the script:
texttool://x-callback-url/transform?text=' + final + '&method=replace&find=www&replace=dl&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Ftext%3D%5B%5Boutput%5D%5D%26method%3Daffix%26prefix%3D!%255B%255D%2528%26suffix%3D%2529
In the first TextTool transformation,
www is replaced with
x-success parameter calls TextTool again to take its output and transform the new URL into a Markdown image link. (This part was difficult and I want to thank Craig at Black Fog Games for his help on Twitter.) Here is the
x-success parameter URL-decoded:
And here is the last part URL-decoded again:
The tricky part is that the Markdown elements need to be URL-encoded for the
affix action and then URL-encoded again when the entire URL action is added to the
CleanURL Pythonista Script
This Drafts URL action does the following:
- Enter a Twitter handle in Drafts.
- Choose the
- If you have a markdown file called
It will look like this (if your drafts is
(Here is the Tweetbot URL scheme.)
To import into Drafts while on your iOS device, tap on this link. You will then need to go into the URL action and change YOURUSERNAME to your Twitter handle.
The Geeky Details
This is what the URL action looks like:
The text that gets appended to the Byword file — when URL-decoded — looks like this:
It starts with a line break and then an asterix followed by a space, so that the markdown links show as an unordered list.
You can customize this to your liking. The Byword location can also be dropbox or icloud. And you can specify the filename and even the path. For all those details, visit the Byword x-callback-url API. You can also use another app entirely provided you know the URL scheme.
If you ever surf the web on your iOS device and encounter a link that contains something like
go.php?url=, you’re encountering a redirect. However, because you cannot (conveniently) read the php script, you cannot tell if the browser will actually send you to the link after the
= sign. Some less scrupulous webmasters send you somewhere else entirely.
The following solution requires three different iOS apps, but the end result is that you just copy the entire URL to your clipboard, tap on the
Split = action in Launch Center Pro, and Safari will open the URL after the
= sign. (There is also a solution for iCab Mobile and Google Chrome at the end of this article.)
First, on your iOS device tap on this link and choose where in Launch Center Pro you will install the action. The URL scheme is as follows:
What It Does
- It sends the clipboard contents to TextTool, which splits the contents at the = sign and puts each section on its own line. With a go link, the URL you want to open will be the second line.
- After the successful transformation, the results are sent to Drafts.
- Then the line2 URL action in Drafts is performed. This action sends the 2nd line of the draft to Launch Center Pro, and LCP simply opens the URL in Safari.
For example, if you copy
http://url1.com/go.php?url=http://url2.com to the clipboard,
http//url2.com will open in Safari.
Install the Drafts Action
While on your iOS device, tap on this link to install the
line2 URL action in Drafts. It’s simply as follows:
For Other Browsers
Let’s say you’re browsing in iCab Mobile. The workaround is slightly more complicated. The LCP action is exactly the same but we’re replacing the
line2 URL action in Drafts. Tap on this link to install the alternate URL action, which is as follows:
This sends line2 of the Draft to TextTool, which replaces
googlechrome if you want the URL to open there). Upon success, TextTool sends the output to LCP, and LCP opens that URL.
TextTool, a new iOS app that transforms text in various ways, has just been released in the App Store. MacStories has an informative article on it. Federico wrote a Drafts URL Action to turn a list in Drafts into a Markdown-formatted list using the
affix method in TextTool, and then send that text back to Drafts using x-callback-url.
Frequent readers know I am OPML-obsessed. (OPML is a structured data format for outliner software.) In May, I wrote a complicated set of Drafts actions to convert a list in Drafts into an OPML file. With TextTool, this solution become a whole less complicated. TextTool allows me to to affix a prefix of
<outline text=" and a suffix of
" /> to every line imported from Drafts, and then send that text back to Drafts. I then can use a Dropbox action to put the draft text into a template surrounded by the OPML header and footer to create a valid file (which can then be imported into an app like Fargo).
Import the Drafts Actions
If you’re reading this on your iOS device, tap on this link to import the
texttool-opml URL Action into Drafts. (You must of course have both Drafts and TextTool installed on your device.)
The URL Action itself looks like this:
action at the end of the x-success parameter tells Drafts to then perform the
textool-opml-dropbox Dropbox action. Tap on this link to import it.
It essentially wraps the [[draft]] with the text required to make it a valid OPML file.
Type of Action: dropbox
<?xml version="1.0" encoding="UTF-8"?> <opml version="2.0"> <head> <title>[[date]]</title> </head> <body> [[draft]] </body> </opml>
How It Works from Beginning to End
If I enter the following into Drafts and then tap on
Line 1 Line 2 Line 3
it will send an OPML file titled
2013-11-21.opml to the /Apps/Fargo folder in Dropbox:
<?xml version="1.0" encoding="UTF-8"?> <opml version="2.0"> <head> <title>2013-11-21</title> </head> <body> <outline text="Line 1" /> <outline text="Line 2" /> <outline text="Line 3" /> </body> </opml>
I can then open this file from within the Fargo app.
You can customize this in many ways. For example, if you like Carbonfin Outliner, use the Dropbox action to send it to the /Outliner folder and then sync the iOS app to import the file.
I recently signed up at Bandcamp to download this great cover of Daft Punk’s “Get Lucky” by Beats Antique, and when I clicked on the link in my iOS mail app I received a message that I could not download the track to my phone, I had to do it via iTunes.
Fortunately, there’s a hack for that.
Download the iCab Mobile web browser to your phone. In the Tools, under Browser ID, choose Safari 6 (Mac). This tells the server that you’re on a desktop, not your iPhone.
Copy the download link and paste it into the iCab address bar, and choose to download the MP3. You’ll see the download progress at the icon that looks like a down-facing arrow surrounded by a circle. When the download is done, tap on that icon and you’ll see all your iCab downloads. From there, you can open the MP3 in another app (“Open in an External App…”). You can save it Goodreader or Dropbox, for example.
- Call (415) 798-2175 and leave a voicemail.
- IFTTT converts your message to an MP3, and sends a link to it to the Drafts list in the Reminders app.
- When you open Drafts, the MP3 URL will import into a new draft.
To make this work, you have to (1) set up Drafts to work with Reminders; and (2) create a Drafts list in Reminders.
How I Use This Recipe
Sometimes I just want to dictate a note to myself, but don’t want to open an app, click on the microphone icon and dictate a note. (Or tell Siri to create a reminder or a note.) Now I can just call a number, leave a message and hang up, and listen to the MP3 at my leisure from Drafts.
Change This Recipe
In the IFTTT app, you can also add the transcribed message to the Reminders app. I have not found IFTTT’s speech-to-text algorithm to be terribly good. Also, I have found that long voicemails just don’t import into Reminders at all. However, if you just want to add short tasks, you might want to use this alternative.
How this script works:
- Punch Brothers
- Punch Brothers
Put the code below in your menubar.opml outline. Watch this video to learn more about scripting in Fargo.
One of the downsides of moving OPML files between apps is that the “killer feature” — attributes — is often unsupported. At minimum, an OPML file just contains text:
- <outline text="This is a headline" />
Most other outliner apps do not support these attributes, but I’ve found two that support the
_note attribute, meaning that they will import and export its value: Workflowy and CarbonFin Outliner. Fargo supports any user-defined attribute, so one can theoretically move outlines containing notes between these three apps without losing any information. (According to Joe Pairman, Omni Outliner and Tree support the
_note attribute, but I have no experience with these apps as of this writing.)