La Vita è Bear

Thanks to Bridgy Fed, you can now follow this blog on fediverse directly

tl;dr: Just search for @b.yuxuan.org@b.yuxuan.org on your home instance and follow there!

Bridgy Fed is an Open Source service that does fediverse related bridges: It can bridge between fediverse and bluesky, and it can also bridge websites to the fediverse. When bridging a website, the default handle would be @[domain]@web.brid.gy, but with some work you can get the @[domain]@[domain] handle, and that’s what I did with PandaBlog in this commit.

One interesting thing while implementing this is that initially I just constructed the URL and did a naive redirection. But that turned out to be not working, because when doing the redirection for /.well-known/webfinger you need to keep all the url queries with it, so I ended up doing something like this:

if err := r.ParseForm(); err != nil {
  // Handle error
}
url := (&url.URL{
  Scheme:   "https",
  Host:     domain,
  Path:     r.URL.Path,
  RawQuery: r.Form.Encode(),
}).String()
// Send redirect to url

After that is implemented, the next thing to do is to implement WebMention, because without that, it relies on periodically fetching your feed for updates, and according to my http log it only requested my feed every week or so, which will cause a huge delay.

WebMention (only for Bridgy Fed) is implemented in this commit. With this change I also took the chance to refactor how URLs are generated across the code, and fixed a bug in local development debugging.

Then it turned out that although not clearly documented, in order to use WebMention to trigger Bridgy Fed to update the account, the website is also required to have microformat support. So I also added some minimal microformat support in this commit. Now it finally triggered Bridgy Fed to (almost) immediately update when I post a blog post here. 🎉

A year or so ago I seriously considered adding AcitivityPub support to PandaBlog directly, but after reading its spec I realized that the protocol is too stateful to my taste, that in order to properly support it I would need at least a proper database in PandaBlog to handle all the things (while currently the “db” of PandaBlog is just a JSON file in Google Cloud Storage). So I’m glad that I can achieve something very similar via Bridgy Fed, a 3rd-party, open source service.

#English #go #PandaBlog #fediverse #BridgyFed