Mr. Reader Actions for Editorial
Thanks again to Mr. Reader for sponsoring Macdrifter. I really can’t say enough good things about this RSS reader for iPad. All of themes for the app look gorgeous and the extensibility is unmatched.
Mr. Reader comes with some core actions but the action customization is wide open too. Using placeholder tokens for an article, such as URL, author, title or even selected text, you can create a huge variety of your own personalized tools.
Here’s a Mr. Reader action that I pair with an Editorial workflow for grabbing an article and immediately turning it into a draft linked post for Macdrifter.
The Mr. Reader action leverages the Editorial URL scheme. The action sends out the URL, title, author and any text I have selected. The title becomes the the document title and the article title. The selected text becomes a quote.
My articles all start with some front matter like this:
:::text
title: My awesome title [Link]
link: http://some.site.com
date: 2014-01-13 20:55:00
tags: Link, Sponsor
The Mr. Reader action makes this all possible:
:::text
editorial://?command=MrReader_Link&input={[URL]
[TITLE]
[AUTHOR]:
> [TEXT-SELECTED]}
Using the Editorial URL scheme, Mr. Reader passes a formatted block of text to a specific workflow named “MrReader_Link”. The text contains the article, URL, Title, Author (if it exists) and any text selected in the article.
Here’s where a bit of Editorial-fu comes in. I also want my document named intelligently, using the article title. So I need to get at that URL coming out of Mr. Reader.
I create some variables and then extract the URL and title coming over from Mr. Reader:
:::Python
#coding: utf-8
import workflow
import re
input_text = workflow.get_variable('incomingInput')
# convert to a list of lines
lines = input_text.split('\n')
workflow.set_variable('urlString', lines[0])
workflow.set_variable('titleString', lines[1])
new_string = '\n'.join(lines[3:])
workflow.set_variable('postBody', new_string)
workflow.set_output(new_string)
Once I have those values saved to variables, I can go ahead and create the new Dropbox document with some more Python:
:::Python
#coding: utf-8
import workflow
import os
import editor
import datetime
import webbrowser
import urllib
local_path = os.path.expanduser('~/Documents')
doc_title = workflow.get_variable('titleString')
doc_body = workflow.get_variable('postBody')
link_url = workflow.get_variable('urlString')
file_current_time = datetime.datetime.now().strftime('%Y-%m-%d_%H%M%S')
meta_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
file_name = doc_title + file_current_time +'.txt'
file_content = 'title: '+doc_title+'\nlink: '+link_url+'\ndate: ' + meta_date + '\n\n\n' + '[' + file_current_time + ']: ' + link_url
editor.set_file_contents(file_name, file_content,'dropbox')
webbrowser.open('editorial://open/' + urllib.quote(file_name) + '?root=dropbox')
action_in = workflow.get_input()
#TODO: Generate the output...
action_out = action_in
workflow.set_output(action_out)
In this case, an article that looks like this:
Is transformed into a new document in Dropbox that looks like this:
Notice that the file was named with the article name and it provides an option to modify the name along the way. The link is added to the header data and as a reference link using a time stamp marker.
You can install the Editorial workflow from here.
You can download the companion Mr. Reader action here. Just install Mr. Reader and it will install automatically.
The Mr. Reader URL actions are one of my favorite features of the app. Sure, it’s beautiful and fast, but it’s also incredibly flexible. It’s also one of my favorite apps on the iPad.