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:
texttool://x-callback-url/transform?text=[[draft]]&method=affix&prefix=%3Coutline%20text%3D%22&suffix=%22%20%2F%3E&scope=lines&x-success={{drafts://x-callback-url/create?text=[[output]]&action=texttool-opml-dropbox}}
The 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
Name: texttool-opml-dropbox
Path: /Apps/Fargo/
Filenametype: Predefined
Filename: [[date]]
Extension: opml
Writetype: Created
Template:
<?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 texttool-opml
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.