Tweaking Workflows

16th December 2014

Only a few days ago Workflow launched and whilst I’ve never really bought into Editorial, Pythonista or Launch Center Pro (though I’m aware of their collective existences) after creating a simple script to tweak the output of Overcasts tweet URL scheme I decided to solve another problem that’s annoyed me for some time.

One of the problems with Pragmatic is that it takes a considerable amount of effort to research and collect all the links I want to use during the course of most episodes. In some cases I’ve had a page full of links that I traditionally saved using the Safari Bookmark sync.

During the dark period of non-synchronicity between the iOS8 Betas, Yosemite and iCloud Drive (I insanely participated in the Public Beta of Yosemite ignoring in-part my own advice not to) Safari bookmark sync worked intermittently. I resorted to saving links and messaging them to myself, or being stuck to bookmarking items from the desktop only. Whichever way I chose it was inevitable that I would have to export my bookmarks then convert them from HTML into Markdown.

Why Markdown? Well when you blog in tech circles of late, apparently you should use some kind of markup language that isn’t HTML because you know, HTML sucks for some reason and reading raw text in Markdown is easier on your eyes. Apparently. I use Statamic as my CMS which uses Markdown as an option and I decided, one in, all in and converted every last bit of text into Markdown on the whole website.

Tools to convert HTML into Markdown exist in the form of scripts but honestly I had trouble making them work on Mavericks at the time and never bothered to revisit them. Seemed like too much work for little return benefit at the time. I’d rather just start and end in Markdown if I can and never go HTML.

Hence I just shrugged and copied and pasted text and URLs back and forth between HTML and Markdown raw text files while I was listening back to the audio as I edited.

But it still bugged me.

Enter Workflow for iPhone and iPad

Then Workflow happened and after reading Federico Viticcis War and Peace on it I threw cash in the ring and tried it out. In so doing I saw something that caught my eye: "Append to Dropbox File". I was already using DropBox as my backed-up local filestore for this website (amongst many other things) and figured I should try to append the links to a text file directly in Markdown rather than bother with the potentially problematic Safari bookmark sync. After not a great deal of work I came up with a very simple, single (iPhone 6+ screen sized) workflow to solve my highly specific use-case:

Workflow

Sharing this with my iPad I now could easily add the URLs I needed in Markdown directly as text for use in the show Markdown file later. But what about the Mac?

Mac

Using the Sharesheets is out on the Mac unless there’s an app that already does what you need. Bookmarklets could probably work but an Automator workflow should be fine, and using AppleScript is something I’ve dabbled with before. A few searches around the place and I set up a simple Automator Service workflow that takes no input, is available in Safari and whose AppleScript looks like this:

on run {input, parameters}

    tell application "Safari" to set currentTabURL to URL of the front document
    tell application "Safari" to set currentTabTitle to name of the front document

    set theFile to (((path to home folder) as text) & "dropbox:links.txt") as alias
    set N to open for access theFile with write permission

    get eof N
    if result > 0 then
        set theText to read N
        set eof N to 0
        write theText & return & "- [" & currentTabTitle & "](" & currentTabURL & ")" to N
    end if

    close access N

    tell application "Play Sound"
        play(((path to desktop) as text) & "Laser")
    end tell

    return input
end run

Play Sound is an app that accepts a scripted play/stop/pause and a filename and just plays it. Just to prove the concept I threw a Laser sound effect on the Desktop but you know, use whatever sound, wherever you like. It’s a free filesystem. Even if it is HFS+.

Conclusion

Yes this assumes you use Dropbox to glue it all together but this set up now allows me to keep all the links in the one place for easy addition into the show notes with a single quick copy and paste and no more HTML->Markdown conversion scripts that frankly, seemed a bit inverted anyway.

Attribution