Weeknotes #19
They say the best thing to do when you fall off a bike is to get back on. Perhaps the same holds true for weeknotes.
With a further delay to the conclusion of my job search, I’ll skip past that and instead concentrate on the one thing that’s been occupying my mind this week, almost to a worrying degree. I mentioned in previous week notes my attempt to build a Micropub endpoint, and on Friday, I made it public. Christened IndieKit, I described it as:
…a Micropub endpoint that can be hosted on a service like Heroku, and configured via files stored on a GitHub repo before saving posts to that repo for publishing with a static site generator like Jekyll, Hugo or Eleventy. The software is fully documented and covered by tests, including tests that replicate those provided by the Micropub Rocks! validator.
A long term ambition is to build a tool that supports different publishing destinations, other social publishing specifications (Webmention, Microsub, ActivityPub etc.) and integrates with a range of content management systems.
This week saw me finalise support for creating posts (including the upload of any images attached to a request with multipart/form-data
), deleting posts and a source query that provides a Microformats representation of any given URL. I also spent a good deal of time writing the documentation. Having made it public, the response has been really positive, even spurring a discussion about collaborating over shared components, which I’m keen to follow up.
I’m surprised at what I’ve been able to achieve in just two weeks, although building to a specification has helped. With this and the related tests structured in such a way that you can tackle one piece at a time, completing each milestone is an opportunity for celebration. Choosing to write an application in Node.js has also meant I can use the latest JavaScript features and syntax without having to worry about browser support, allowing me to focus on the application’s architecture, flows and features. And building a server application is teaching me more than I ever cared to know about sending data over HTTP.
It hasn’t all be plain sailing of course. Promises and related async
/await
functions have caused a great deal of hair pulling. They confused me last year when I was creating the service worker for this site, but this exercise has forced me to understand how they relate to each other. To explain my findings, a brief deviation via CSS.
When browsers first gave authors access to the advanced typographic features available in OpenType fonts, they did so via the font-feature-settings
property. If you wanted to turn-off a font’s ligatures and use tabular numbers in tables, for example, you would write the following:
table {
font-feature-settings: "liga" 0, "tnum";
}
This isn’t particularly nice to read, not least because it uses a syntax for its values unlike anything else in CSS (to the best of my knowledge). However, it does provide direct access to a low-level browser feature. Thankfully, new properties have been added meaning today we can write:
table {
font-variant: no-common-ligatures tabular-nums;
}
In a way, font-feature-settings
is to Promise
(with its associated resolve
and reject
arguments), as font-variant
is to async
and await
functions (with which you can use try
and catch
statements). The newer syntax allows you to write code using a more familiar synchronous syntax, with the former there if you need to dive a bit deeper.
Before I start sounding too clever, let it be known that I spent much of Saturday trying to work out why images uploaded to GitHub via its REST API were appearing as text strings; this morning I realised I was encoding them as Base64 strings… before doing the same again in a later function. Oh, and there was another evening where I began writing a regex to convert a template literal into another regex and then back into a template literal. Thankfully, on the IndieWebCamp chat, Rosemary Orchard suggested I use a simple JSON file to store and retrieve values instead, which of course made much more sense!
Anyway, after several weeks telling potential employers that I wouldn’t class myself a programmer, I’m wondering if I should update that statement: I’m a novice programmer.
Websites I’ve frequented over the last seven days:
localhost:3000/micropub
They say the best thing to do when you fall off a bike is to get back on. Perhaps the same holds true for weeknotes.
“Life is what happens while you are busy making other plans.”
Decisions, decisions, decisions.
“I can’t wait to see this video Dave”
“A little bit more than a hot dog, know what I mean?”
It’ll pass.