One cool thing about most App.net clients is their support for Markdown links. Wrap the title in brackets, followed by the link between parenthesis and you're good to go. What about sharing some links straight from Safari to Riposte as Markdown links?
The Easy Way
We'll dive into the world of bookmarklets again and, as you may guess, I have plenty of those in my Safari. This exercise will introduce you to Riposte's URL scheme and also refresh your mind on how to build a bookmarklet.
The url to create a new post in Riposte is as follows:
This will create a Hello World message, but what we really want is to grab the title and url of the current page we're visiting in Safari. For the title we use
document.title, meanwhile for the url we go with
location.href. We also must URL encode this content and add our Markdown link syntax. The outcome will look like this:
But what if we wanted to put Clean Links into the mix to remove all that crap people attach to links these days? Well, let's say things can get quite nasty.
The Hard Way
Remember when we discussed the
retParam in 1Writer? Well, Clean Links has that as well, but turns out it doesn't help in our situation since we want to modify the output and the
retParam doesn't allow that as far as I'm concerned. Yet, Clean Links has another kind of output: the clipboard. But how can I send the clipboard to Riposte? Using Drafts, of course! Now that I got your head all messed up, let's start this bookmarklet backwards:
You may be familiar with that URL, it is available in Drafts' Action Directory. Install it, the headache will get a lot easier by using Drafts' built-in
action. Next we build the Markdown link using
||clipboard|| because we're power users.
Actually, I wanted to introduce you to the
||clipboard|| element in this article. From the official docs:
The /create action supports a special ||clipboard|| tag. If this tag is found in the "text" parameter, it will be replaced with the current contents of the device clipboard before creating the draft. This is particularly useful when used in x-success parameters when chaining URLs, when the clipboard might have changed while you were in another app.
Cool, right? If you skipped the quote, I'll let you know that
[[clipboard]] wouldn't work in our case, it would send the tag, literally, to Riposte. To make use of it you'd need a custom action that creates the Markdown link using the
[[draft]], which would be only the title, and then the clipboard, which wouldn't change since we triggered Clean Links. Confusing? Just stick to my example then.
After hours of trial and error, we're ready to include Clean Links, the first step is to encode everything we made so far and set it as the
x-success parameter for Clean Links. The
location.href must be encoded as well, so be careful with that.
We reviewed a few tricks for Riposte, the App.net crew goes wild, and our bookmarklet skills. We also saw the recently added
||clipboard|| parameter in Drafts and learned that getting rid of those url shorteners is harder than it sounds. See you next time, I promise it will be sooner.