TechLifeWeb

My System to Automate Repost-Of Mastodon Posts


Published by 
Scott Kingery
 on 

Sometimes I build crazy things. I get an idea for something and then I attempt to cobble it together. Mostly non-repeatable by anyone other than me but they keep me entertained. I'd rather spend hours trying to figure things like this out than play video games.

Recently I was thinking about how I could ease the creation of Mastodon Boosts in the form of using the Indieweb idea of a "repost-of".

From that link:

Why implement reposting:

  • Retweet from your own site. Incrementally supporting reposts, especially with POSSE to Twitter, enables you to "retweet" from your own site, rather than depending on Twitter to do so.

  • This in turn ensures a copy of anything you retweet on your own site, in case the original is deleted/removed etc.

The side benefit, for me, is I can search my own content for that link that I thought was interesting at some point.

Sure, I could just click the "Boost" button on my Mastodon client but that's just too easy. Instead, with my new system, I click the Bookmark button and that unleashes a crazy stream of events all in the effort of doing repost-of.

The first piece of this "house of cards" is a nifty service called Mastodon Bookmark RSS. It's fairly straight forward but, Fabrizio Musacchio has a great write up on how to use it here: How to get an RSS feed of your Mastodon bookmarks

The next piece requires a bit of background. This site is built with Eleventy (aka 11ty). Eleventy is a simpler static site generator. Among other things you can use simple Markdown to create the pages. I have the wonderful PKM tool Obsidian sitting on top of my 11ty source folder. In Obsidian terms, the Source folder is an Obsidian "Vault". This lets me interact with the files using Obsidian as a kind of "Front End". That works well for site content. For 11ty code manipulation I can light up VS Code and work with the tiles that way instead.

Inside the above mentioned Obsidian Vault I am running a plugin called Simple RSS. And the Templater plugin. Templater does the magic of converting code slugs into usable things like dates.

Simple RSS does the work of pulling in the feed that I set up in Mastodon Bookmarks to RSS. For that you have to go to the plugin's setting and first create a "Feed Type". I used the creative name "Mastodon" for mine. It looks like this:

Screenshot of the Feed Type settings

Next, you need to set up the feed. You choose a name, enter the url. The "Type" is the one you created above. The posts get pulled in an placed in the folder you enter into the path field. In the title field I use the title the feed has for each entry. That code is particular to this plugin. Then in the template I have a bunch of code for how I want the post to look on my website. Getting this right can be a little tricky because you don't have tons of control over the actual body section. Mine looks like:

Screenshot of the Feed settings

You can have the plugin run on a schedule or you can just click the icon in your Obsidian sidebar and it will pull in the latest entries.

The template I've created is built with microformats that Bridgy understands. When my site is built and uploaded I have a script that sends a Webmention to Bridgy and it does the magic creating a repost on Mastodon on my behalf.

Yep, it's a kind of crazy but it was fun to figure out. And, if it stops working, not really the end of the world.