Wednesday November 3, 2021; 10:26 PM EDT
- I've got a few minutes, so let's make a tagging system in Drummer! Or at least work out how I could make one.#
- Simple goal: Automate updating an outline that contains links to blog posts, organized by category#
- Stretch goal: Include the list of tags assigned to a blog post at the end of the blog post#
- How to make it work#
- Adding tags to a post#
- Select a blog post to tag, and then something something—#
- Click minus sign#
- Naw, use the suitcase button and make it an attribute or something#
- Let's call it umm. I dunno. I don't see a default attribute assigned in the docs for this sort of thing. "tag" it is.#
- Adding multiple attributes named "tag" doesn't work (you can add several, but when you click the suitcase again, only one remains).#
- I dunno if I want to parse a comma-separated list, which is a common way to stick several string values in a single string, but I'll have to if I opt to just include the tag names inline in the blog post itself, like so: #
- Tags: Drummer, Drumkit, Metadata#
- Or, let's use the fact that we're working with a structured format here, and something like this at the end of the post:#
- Tags#
- Drummer#
- Drumkit#
- Metadata#
- Then, let's set an attribute on the Tags node so we don't have to recognize it by name. Let's call it, umm, hmm. Using "type" seems a bit presumptuous and prone to breakage, this is something my own script will look for, not Old School. I probably need a prefix I can use for these sorts of things. For now I'll go with "gfa", which stands for "Gary fucking around". gfaType, good enough for now.#
- Generating the tags page#
- I followed the instructions and added a button to the icon bar that builds my blog. Right now, that code just fetches a URL that tells Old School to rebuild the blog, and then beeps the speaker. I can easily add steps that run before that happens. Here's what that script will need to do: #
- Get a reference to opml.blog#
- Walk the nodes. With luck there'll be a verb that just calls me back for each node but if I have to descend the tree myself that's OK too.#
- Not sure yet which of these is better#
- When I find a node that is marked with an attribute named "gfaType" set to "tags", then each of the child nodes will be a tag #
- When I find a node that is marked with an attribute named "gfaType" set to "tag", then that node is a tag#
- Processing the tag name#
- Text of the node is the name of the tag#
- Case insensitive#
- Probably strip punctuation#
- Clean up for use in a url path#
- Processing the node#
- I want to turn it into a link node probably#
- The script will take the tag name, then generate a URL for the link#
- The link should point to something like#
- A standalone page of tags#
- An anchor to a tag on the page of tags#
- A page listing all the blog posts tagged with that tag#
- Some combination of the above#
- Then, update the tags node itself#
- Get a reference to the tags.opml or whatever I call it. This will probably be a public outline that gets included into a standalone page. Or possibly about.opml.#
- Walk that outline looking for the node that represents the collection of references to blog posts for this tag#
- Match loosely#
- Case insensitive#
- Match on plain text of tag#
- Match on cleaned up for url version#
- I suppose I could add something that lets me specify a canonical version and variants but I've done that before and it's a pain. Maybe I can just be better about maintaining my metadata.#
- See if the blog post is already in the collection#
- Add it if it isn't#