Tweet This Post

I wrote the above Launch Center Pro action over the weekend. I thought it would take 15 minutes, but it took 45, because the encoding was such a challenge.

The Problem I Wanted to Solve

When I add new list items to an LCP action using the list tag, I sometimes just randomly add an item after the first pipe (|) I can find. Then I notice that the order of my list items has no rhyme or reason to it, so I want to alphabetize it. This is not an easy task, cut-and-pasting in a small text area on an iPhone screen. So I decided to use TextTool to automate the process for me.

  1. Remove the pipes in a sequence like Apples|Pears|Bananas using the split method.

  2. Use the sort method to alphabetize the list

  3. Add the pipes again between each item, using the join method.

Here is the full LCP action (click on the link in the Twitter embed above to install):

texttool://x-callback-url/transform?text=[clipboard]&method=split&delimiter=%7C&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Ftext%3D%5B%5Boutput%5D%5D%26method%3Dsort%26x-success%3Dtexttool%253A%252F%252Fx-callback-url%252Ftransform%253Ftext%253D%25255B%25255Boutput%25255D%25255D%2526method%253Djoin%2526delimiter%253D%25257C

The sort transformation, URL-decoded:

texttool://x-callback-url/transform?text=[[output]]&method=sort

The join transformation, URL-decoded twice:

texttool://x-callback-url/transform?text=%5B%5Boutput%5D%5D&method=join&delimiter=%7C

Notice how, even though this action was URL-encoded twice after the second x-success parameter, the [[output]] had to be encoded yet again before the entire action was URL-encoded twice. I had to add an extra %25 before each double-encoded bracket to make the complete action work.

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

Resources: TextTool x-callback-url Support page

02/03/14; 10:33:23 AM

Tweet This Post

Paperless is an iOS lists app that stores its data in XML files in Dropbox (if you choose to sync). What follows is an attempt to procure the first item in a list and send it to Due without having to copy and paste.

The first list item in any Paperless list appears to occur on line 12 of the list's XML file. It looks like this:

<itemName>LIST ITEM</itemName>

Launch Center Pro's dropbox tag lets you get the contents of a text file, so I figured I could grab the entire contents of an XML file and push it to Drafts. Tap on this link to import into LCP, or copy the action below and adapt for your purposes:

drafts://x-callback-url/create?text=[dropbox-text:Paperless/Errands.xml]&action=line12

What this does is grab the full text from the Errands list in Paperless, send it to Drafts, and then activate the line12 custom URL action.

line12 uses a Drafts tag [[line|12]] to send line 12 of the XML file to TextTool and then use the regex method to replace <itemName> and </itemName> with blank spaces. I know next to nothing about regex, but I found here that I could easily create a regex expression to match both <itemName> and </itemName>:

<(/|)itemName>

So the search parameter in TextTool is the above URL-encoded, and the replace parameter is a single space, URL-encoded:

texttool://x-callback-url/transform?text=[[line|12]]&method=regex&search=%3C(%2F%7C)itemName%3E&replace=%20&x-success=due%3A%2F%2Fx-callback-url%2Fadd%3Ftitle%3D%5B%5Boutput%5D%5D

(Tap on this link to import into Drafts.)

The x-success parameter above tells TextTool to take the [[output]] of that transformation and send it to Due. Here is that action URL-decoded:

due://x-callback-url/add?title=[[output]]

The final result... I tap on the LCP action, and it adds the first list item from my Errands list and sends it to Due. There are spaces preceding the text, but the XML is extracted.

Although the automation required to perform the above is a bit excessive (in contrast to just copying an item from Paperless and then pasting it into Due) it demonstrates the ability of the included iOS apps to accomplish pretty remarkable tasks.

 

Addendum (2014-02-04)

Here is an importable line12 Drafts action that trims the TextTool regex output before it sends the list item to Due. And here is the URL action itself:

texttool://x-callback-url/transform?text=[[line|12]]&method=regex&search=%3C(%2F%7C)itemName%3E&replace=%20&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Ftext%3D%5B%5Boutput%5D%5D%26method%3Dtrim%26x-success%3Ddue%253A%252F%252Fx-callback-url%252Fadd%253Ftitle%253D%25255B%25255Boutput%25255D%25255D

 

Addendum 2 (2014-02-04)

Here is an importable line12 Drafts action that will include a link to the Errands list in Paperless within the Due text, so that when you complete the task, you can visit the list and check off the item there. (Thanks to @epramono for inspiring this.) And here is the URL action itself:

texttool://x-callback-url/transform?text=[[line|12]]&method=regex&search=%3C(%2F%7C)itemName%3E&replace=%20&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Ftext%3D%5B%5Boutput%5D%5D%26method%3Dtrim%26x-success%3Ddue%253A%252F%252Fx-callback-url%252Fadd%253Ftitle%253D%25255B%25255Boutput%25255D%25255D%25250Apaperless%25253A%25252F%25252FviewList%25253FlistName%25253DErrands
02/03/14; 12:47:01 PM

Last built: Mon, May 12, 2014 at 8:52 AM

By Jeffrey Kishner, Monday, February 3, 2014 at 10:33 AM.