I’ve been playing around with Pythonista on my iPad Pro trying to figure out how to automate a blogging workflow that begins and ends on this device. My primary objectives were to:
- be able to write new posts from my iOS device
- automatically commit posts to my remote git repo, both draft and final
- automatically sync the file to the correct Dropbox directory (which is synced to a headless Dropbox instance on my server, from which the post is auto-generated and made live)
I’m able to address these goals with a single solution that’s built with Python on iOS.
The previous incarnation of this blog used a static site generator called Jekyll which ingests standard markdown files with YAML front-matter and generates HTML content for this site. One of the big points of friction to this process is the specification of the YAML front-matter—mostly boilerplate fields, but a pain to remember and type. Given that this site was being generated from the contents of a Dropbox folder, I could create the markdown file directly in the _posts directory therein, but that eliminated the option of saving drafts before they went live. This meant that I had to use an editor (in my case Editorial) where I can freely write, and when ready, generate a file appropriate for Jekyll.
Once I’m finished writing a post, I can go to the share panel and select “Run Pythonista Script” which will invoke my little program and present a form interface to enter the YAML details and perform other basic file processing such as filename generation (which must be in a very specific format). Once I enter that info, the program then pushes the changes to my Gitlab repo and then syncs the file to Dropbox. Once that’s done, Jekyll detects the update in the watched folder on my server and regenerates the site with the new content!
I’ll follow up this post with the actual code.