Embedding Mastodon Feeds

Make this demo page usable on narrow devices.

The column on the left contains recent toots from two mastodon accounts while the column on the right contains recent toots with some hashtag. This is implemented by a web component using Mastodon's REST API.

The <mastodon-toots> component takes a single attribute url for retrieving the toots. You can use any URL of the mastodon API that provides a JSON array of "statuses" (= posts = toots). See the mastodon API docs on retrieving timelines and statuses.

For example:

Here is a quick&dirty tool for finding an account id.
Type the account's username and instance (separated by "@") in the input field and press the Enter key.

The output of the component does not go to shadow DOM. So it can be styled with CSS for the main ("light") DOM tree.

The component only works if CORS is enabled by the server. All the mastodon servers I tried actually had this enabled.

Features that might be added:

Contributions and suggestions welcome! (To my mastodon account @hcschuetz@mastodon.social, in the discussion section of the github repo, or even as a pull request.)

I haven't npm-packaged the code (yet) because users of the component will probably want to tweak a few things here and there. I don't want to complicate the code by adding a lot of configurability. It should be easy for web developers to tweak their copy of the code directly. Furthermore such tweaks may depend on third-party code, but I'd like to avoid dependencies in the "vanilla" version.

Also notice that both the web component and the demo page run directly from the source code. There is no build step.

An Open Problem

When viewing the demo page

scrolling the toot boxes does not work reliably. Scrolling does work if I replace Firefox with Chrome, or if I use Firefox on my Samsung/Android mobile, or if I simply rotate my tablet to portrait orientation.

Can anybody reproduce the problem? Is this a Firefox issue? Is there a known solution or work-around?

Similar Projects

There are various instructions and projects doing similar (but somewhat different) things. I am aware of these:

So you have to find your compromise between functionality and simplicity as well as between ready-made and easily adaptable code.