Posting Ghost Posts to Pleroma
I am already running some bots through mastodon. As I thought it might be a nice idea to automatically post anything that gets posted on this blog I started looking at their API, unfortunately I cannot use the mastodon API I already use. I think they are looking into it.
I can however post with a simple axios/web request with user authentication (many of my mastodon automatons depend on using a token, this does not seem to work in pleroma (FYI I am getting a 403 response when I what to use a Bearer token).
I have been struggling with getting the formatting right, although pleroma should support html formatting but I was not getting good results. Now I am turning the HTML into markdown and with a bit of fiddling about I am now getting nice results.
Some fixes
Extracting figure tags and their info
Test with formatted text, code etc.
<figure class="kg-card kg-embed-card"><iframe width="200" height="113"
src="https://www.youtube.com/embed/ufVMqBToGno?feature=oembed" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
title="Pleroma - your doorway to the Fediverse. Run along side Mastodon, Peertube, Pixelfed, and more."></iframe>
</figure>
var tagLine = ''
if (post.tags) {
for (thisTag of post.tags) {
tagLine += "#" + thisTag.slug + " "
}
console.log(tagLine)
}
Next steps
Either an automation that gets all the posts from the blog and posts newly published posts or some clever button in ghost that says "post now".