Jeffrey Kishner

Web Publisher, Ecstatic Dancer

  • Home
  • Blog
  • Elsewhere
  • Plugins
  • OPML
  • Javascript
You are here: Home / Blog

Take a Photo, Get a Markdown Image Link with Launch Center Pro, Clean Links, and TextTool

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.

launchpro-dropbox://addlastphoto?path=&name=&quality=&getlink=1&x-success=clean-links%3A%2F%2Fx-callback-url%2Fclean%3Furl%3D%5Bclipboard%5D%26retParam%3Dtext%26x-success%3Dtexttool%253A%252F%252Fx-callback-url%252Ftransform%253Fmethod%253Dreplace%2526find%253Dwww%2526replace%253Ddl%2526x-success%253Dtexttool%25253A%25252F%25252Fx-callback-url%25252Ftransform%25253Ftext%25253D%25255B%25255Boutput%25255D%25255D%252526method%25253Daffix%252526prefix%25253D!%2525255B%2525255D%25252528%252526suffix%25253D%25252529

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 www with dl. It then takes that output and adds the Markdown elements (![](http://dl.dropbox.com/___.jpg)).

Here are each of the x-success parameters URL-decoded.

This is encoded once:

clean-links://x-callback-url/clean?url=[clipboard]&retParam=text&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Fmethod%3Dreplace%26find%3Dwww%26replace%3Ddl%26x-success%3Dtexttool%253A%252F%252Fx-callback-url%252Ftransform%253Ftext%253D%255B%255Boutput%255D%255D%2526method%253Daffix%2526prefix%253D!%25255B%25255D%252528%2526suffix%253D%252529

This is encoded twice:

texttool://x-callback-url/transform?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

This is encoded three times:

texttool://x-callback-url/transform?text=[[output]]&method=affix&prefix=!%5B%5D%28&suffix=%29

And actually the Markdown elements are encoded in the above action:

prefix=![](&suffix=)

Published on December 4, 2013 Leave a Comment

Take a Photo, Get a Markdown Link with Launch Center Pro, Pythonista, and TextTool

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 www in https://www.dropbox.com with 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.com in 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:

launchpro-dropbox://addlastphoto?path=&name=&quality=&getlink=1&x-success=pythonista%3A%2F%2FCleanURL%3Faction%3Drun%26argv%3D%5Bclipboard%5D

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:

pythonista://CleanURL?action=run&argv=[clipboard]

(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 dl. The 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:

texttool://x-callback-url/transform?text=[[output]]&method=affix&prefix=!%5B%5D%28&suffix=%29

And here is the last part URL-decoded again:

prefix=![](&suffix=)

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 x-success parameter.

The CleanURL Pythonista Script

Published on December 4, 2013 Leave a Comment

Create Markdown Links to Open Profiles in Tweetbot with This Drafts URL Action

This Drafts URL action does the following:

  • Enter a Twitter handle in Drafts.
  • Choose the tweetbot-md-byword action.
  • If you have a markdown file called twitter in the local root directory in Byword, this action will append to that file a markdown link that — when tapped in preview — will open that user’s profile in Tweetbot.

It will look like this (if your drafts is kishner):

* [kishner](tweetbot://YOURUSERNAME/user_profile/kishner)

(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:

byword://x-callback-url/append?location=local&name=twitter.md&text=%0A*%20%5B[[draft]]%5D(tweetbot%3A%2F%2FYOURUSERNAME%2Fuser_profile%2F[[draft]])

The text that gets appended to the Byword file — when URL-decoded — looks like this:

* [[[draft]]](tweetbot://kishner/user_profile/[[draft]])

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.

Published on December 3, 2013 Leave a Comment

  • « Previous Page
  • 1
  • …
  • 7
  • 8
  • 9
  • 10
  • 11
  • …
  • 74
  • Next Page »

Recent Posts

  • An AirPods Case Looks an Awful Lot Like Dental Floss
  • Amazon Prime Picks Up 2 Seasons of “The Marvelous Mrs. Maisel”
  • My “Where” File
  • Testing Out Wallabag.it
  • Sometimes Self-Hosted Open-Source Solutions Are Just Too Much Work

Psychotherapy with Jeffrey Kishner

Jeffrey Kishner is a Licensed Mental Health Counselor practicing in New York.

Learn More

How to Reach Me

jk at jeffreykishner dot com

Follow Me

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram

Copyright © 2022 ·Modern Studio Pro · Genesis Framework by StudioPress · WordPress · Log in