Render a fediverse post into portable text, like HTML.
Iri al dosiero
Jaidyn Ann 2a5715a985 Add multi-attachment screenshot 2024-04-25 21:37:58 -05:00
img Add multi-attachment screenshot 2024-04-25 21:37:58 -05:00
COPYING Add GPLv3 license 2024-04-25 18:41:12 -05:00
README.md Add multi-attachment screenshot 2024-04-25 21:37:58 -05:00
fedi2html Add header-info to fedi2html 2024-04-25 18:40:32 -05:00
style.css Add example CSS file 2024-04-25 18:41:04 -05:00

fedi2html

Clipping from a screenshot of a webpage generated by fedi2html. It is showing a legibly-formatted post, containing its username, text, date, and three attachment images. The post is by Tirifto (@tirifto@jam.xwx.moe) with a custom emoji that resembles a “K” in his username. It was posted apparently at 14:12 on April 19th 2024, and says: “Antaŭ nelonge mi bakis spickukon! Domaĝe la supro iomete bruliĝis kaj mi devis senŝeligi ĝin. Sed almenaŭ tio donis bonan pretekston, kial mi nepre kovru la supron per kirlita kremo.” The message contains a custom emoji of a laughing blobcat. The hashtags are visible below as links: #lang\_eo, #bakado, #fotoj, #kuirado, #manĝaĵoj, #spickuko, kaj #vivo. The attachments are all images: “spickuko.jpg”, “spickukeroj.jpg”, and “peco.jpg”. They each have small alt-text descriptions that are truncated. There is a reply to this post, which is displayed as a box inside the responded post. Clipping from a screenshot of a webpage generated by fedi2html. A chain of three posts, each replying to the last, are visible. Each post is within a small box, containing the poster’s avatar, user-name, and text. Each response is found within a smaller box within the parent post, showing a clear hierarchy in the thread. Reid posts, mentioning jadedctrl, “but would you ask spicy questions?” jadedctrl responds, “I like using a lot of spice myself, but because of the high sodium content I couldn’t recommend a diet like that to other people on good conscious”. jadedctrl also responds with a custom emoji of a laughing blobcat. Reid responds to that response, “a life without spice is like GTA without crime: too damn boring”.

fedi2html is a shell script that renders posts from Fediverse/Mastodon/Pleroma/etc to HTML. It could be used for archiving posts, embedding comments into a webpage, etc; the latter is my use-case.

Inspired by the work of Óscar Otero, who was inspired by Thiago Cerqueira, who was inspired by Julian Fietkau, who was in turn inspired by Cassidy James, who also was inspired by Jan Wildeboer who was inspired by Yidhra Farm, who was inspired by Joel Chrono who was inspired by Carl Schwan.

Usage

fedi2html can take post URLs or user URLs. In the first case, it will render the post and, by default, all respones. If a user URL is given, it will by default render the users posts, responses, and repeats; and all responses to these.

$ echo '<html><head><link rel="stylesheet" href="style.css" type="text/css"/></head>' > out.html
$ fedi2html https://jam.xwx.moe/users/Tirifto >> out.html
$ fedi2html https://jam.xwx.moe/notice/AfJdu8YChrGdHXmOpM >> out.html

Of course, the output is unstylized HTML, including no CSS; for best results, Id recommend using the style.css file found in this directory, as is done above (by prepending its inclusion in a tag).

There are three general arguments you should be aware of:

Flag Description
-c Only print responses to the post(s).
-I Display posts in reverse-chronological order.
-l NUM Display at maximum NUM posts.
-R Do not recursively fetch & display responses.

… and three arguments relating specifically to user feeds:

Flag Description
-b Exclude reblogs/repeats.
-B Exclude top-level replies.
-t TAG Only print posts of TAG.

Installation

Installing fedi2html itself than simple — just copy into your PATH!

Assuming that you use ~/.local/bin/:

$ PATH="$PATH:~/.local/bin/"
$ chmod +x fedi2html
$ cp fedi2html ~/.local/bin/

Dependencies

However, fedi2html has some dependencies:

  • curl — For fetching/downloading posts.
  • jq — For parsing the resultant JSON.

They are both fairly standard, and are generally accessible as packages curl and jq, respectively. In the rare cases they arent, both are written in C and are easily-compilable.

Misc

Written by Jaidyn Ann jadedctrl@posteo.at
License is GNU GPLv3
Source is at https://hak.xwx.moe/jadedctrl/fedi2html