I’ve started to write a Micropub client. Not a generic one (there are a range of them out there), but one for my personal use case(s) and specific set-up. For instance so that I can prepare a short blogpost within my everyday note taking system, and then post it to my website here.
I’m doing this because I found that my personal use cases don’t fit well with the clients that are out there. I want something that is local first. Something that stays within my workflow, does not require me to switch context or tools (not having to go to my WordPress back-end or a separate app to post e.g.). Positioning blogging as something that isn’t a separate task, where posts get prepared as a regular by-product of my other tasks, just needing me to finish them and hit post.
A personal software tool in short.
The upside compared to more generic existing Micropub clients is, that I know my own specific use cases and set-up. A personal tool does not have to cater for every option of eventuality, just needs to cater to something very specific. That should make it easier to build as a ‘narrow band’ tool, not requiring many ‘what ifs’ to be covered. This because, as I wrote in the linked blogpost, in narrow band tools, my context and preferences are the default inputs, and my tasks are predictable, allowing them to be put together into the equivalent of a function that you pass a few parameters. The result basically is code.
I’m writing it from scratch and now am trying my hand at writing the most minimalistic script that can take some content and post it to my blog, focusing on sending something from my php script to my website through its Micropub endpoint.Using the helpful suggestions of Jan Boddez on where and how to start, reading up on Jamie Tanna’s experience doing the same, and using his tool to manually generate the right authorisation tokens for Micropub (found here).
I’ve hit my first snag to solve, which is that my calls to the Micropub endpoint fail because there’s an issue with the HTTPS encryption (certificate verify failed). Procrastinating on solving that, I’ve written this post, and opened a page here to track progress.
@ton Die HTTPS, wat gaat daar mis? Dat je systeem (lokaal) over een certificaat gaat zeuren? Had net iets soortgelijks aan de hand, op Windows wel, opgelost (beetje ’n dirty hack, maar goed) door ergens in php.ini naar de juiste .pem-file te verwijzen. Je kunt denk ik in WordPress in je IndieAuth settings ook handmatig tokens aanmaken (die je nooit of bijv. slechts jaarlijks laat vervallen) die je dan in je script kunt gebruiken.
I had envisioned to start this week, after my off time, gently with a day to take stock of everything that I’m working on, decide the rough plans for the coming weeks, month and quarter. And only then dive back into meetings etc. What I hadn’t realised during my vacation was that I had a Monday morning meeting that pre-empted any stock taking, and immediately launched me into a meeting schedule after which I found myself on Thursday afternoon. I took a long nap then. It felt uncomfortable because I wasn’t behind the steering wheel of this week’s calendar, but the calendar was steering me. Note to self: block 2 days after a holiday in my calendar to keep them free of meetings.
This week, as stated mostly in the shape of too many meetings I:
Had a half day session with my business partners, talking about financials and the coming months
Did a half day training session on ethics in technology use, using Peter Paul Verbeek‘s mediation theory. The course is less about the ethics, and more about a workshop format to translate ethical notions to perspectives of agency around the use of a technology.
Had an annual review conversation with one of our team, which also was great to discuss where our entire team can look for personal development.
Had the usual weekly client meetings
Discussed whether a client wants and can participate in a European tender, and with which goals and conditions.
Finished reading Neal Stephenson’s Termination Shock
Started home cooking my own personal Micropub client
In my attempts to create a personal micropub client, I bumped into the oddity that my script posted correctly unless there was a SVG within the post. I use SVG icons regularly in replies (example), bookmarks etc. The feedback I received from others, such as on the issue I filed, tends to always point to trying the same thing with JSON. Though supporting JSON is optional in the Micropub standard, it is supported by the Micropub endpoint in my WordPress site.
Today, I rewrote my basic php script to talk to the Micropub endpoint, and made it submit JSON formatted data. I could not get it to work with curl, which would be the suggested route, but it does work with file_get_contents that also worked earlier without JSON. And now, using JSON, it also works with SVGs in the postings.
While changing tactics doesn’t provide an explanation of why the other route failed, it does allow me to move forward. A working Micropub client is what I now have, so next up is personalising it for my own use cases.
Writing A Personal Micropub Client by Ton Zijlstra (zylstra.org)
Door de omstandigheden had ik de blogpost nog niet gezien. Ton en ik hebben wel via mail wat notities uitgewisseld omdat ik hetzelfde wilde. In de app Drafts even snel een update tikken en door. Met Micropub kan dat en sat heb ik nu ook prima voor elkaar. Waar mijn pijnpunt nog zit is de complexiteit aan de WordPress kant. Weergave, archivering, maar ook bv. syndicatie naar Twitter en die reacties en likes weer goed weergeven. Dat is nog wel een uitdaging in mijn moederschip.
I’m pleased with how little friction I now feel to automatically publish my responses to what people send to my feed reader, using my newly home cooked Micropub client. This morning firing up the feed reader, writing and publishing responses felt very smooth. I’ll need to add some draft saving elements I think, because when responses become longer the risk of losing text in the local edit window rises.
Current status:
Created a working way to submit JSON formatted blogposts to this site, code on GitHub
Included that in my earlier scripts to create posts from my feed reading, that I now no longer then have to post by hand.
Created a Microsub client to replace my feed reader, in which I can respond directly from within the page I am reading.
Combined the same basic script with a local webform so I can very quickly post something. I don’t think I will be using this possibility much but it was a good way to add a front-end to the micropub script first and fast.
Can take a local markdown file written in Obsidian and post it as html to my site. This is by far the most useful to me
I write my blogposts in Obsidian, drafts live in a specific writing folder. They have two inline data fields, status and tags. While writing a note has status ‘writing’, when it is ready to publish I set the status to ‘draft’.
Within Obsidian I use the same status field to create a dynamic overview of posts being written, ready to publish, and previously published (using the DataView plugin).
When I’m ready to post, I hit a hotkey which launches my PHP script. It looks at all files in the specific writing folder and checks for files that changed within the last few hours and if those contain a status field ‘draft’. For those that do it transforms the markdown in those files to html, and then posts that to my site, using the tags in the other data field to tag and categorise the post. It also sets the status field in my notes from ‘draft’ to ‘posted’.
I could also run the script every hour or so using a cron job, so that anything posts automatically, while I go on with my other work.
Rationale:
Local first, personal, narrow band
See blogpost.
Narrow band means:
my preferences can be treated as default inputs
my tasks are predictable to me
together they are functions with parameters, aka code.
Sources:
Micropub standard
IndieWeb wiki on Micropub
Tips from Jan Boddez (in Dutch)
Jamie Tanna’s work on his personal micropub client
Jamie Tanna’s tool to get authorisation tokens manually, great for testing/development.
Parsedown, which I use to translate markdown files written in Obsidian, to HTML for my site.