Skip to main content

Introducing stoot for Micro.blog

Stoot example.

I’m on mastodon too much a lot a fair amount of time and come across items that I want to share with others on my blog. stoot is a Hugo shortcode that allows you to have a static version of a mastodon post on your site. This can match your template or be restyled as you choose.

Why?

As of this writing, I don’t use anything specifically to store links. I attempted to save things to Apple Notes and Drafts and this gives me the URL.

Apple Sharesheet saving URL to a new draft in the Drafts Application

The example that I’ll be using for this post will be to https://social.lol/​@mandaris/112944060166510117.

This works for storing the information for general notes and references, but still leaves the sharing of the content unfinished. In a lot of my previous posts, I would just have a link to a post. This is acceptable, but I’d like to make it convenient for my readers (a.k.a me) to get all the content in one place instead of going back and forth.

I remembered that Hugo offers shortcodes that allow you to embed a tweet, youtube video, etc. into a post and did a search for that. Unfortunately, I couldn’t find one for mastodon. When looking at the one for twitter, I see that it is essentially adding the code that is provided when you embed the iframe1 that twitter supplies. I suspect that it’s because mastodon also has an iframe that it’s not necessary.

The embed pretty small easy to read compared to the code that is loaded for a twitter embed.

Using the URL above, we can see what is created by mastodon. I added spacing for legibility.

<iframe
  src="https://social.lol/@mandaris/112944060166510117/embed"
  class="mastodon-embed"
  style="max-width: 100%; border: 0" width="400"
  allowfullscreen="allowfullscreen">
</iframe>

<script 
  src="https://social.lol/embed.js"
  async="async">
</script>

This produces the following output.

It look alright, but I found that it would cut off the bottom of longer posts and the scroll bars wouldn’t consistently show up. It looks like the embed.js is adding overflow: hidden to the styling during rendering and it can effect embeds with text. I’ve included a picture below in case this is fixed by browsers or changes in the code in the future

Mastodon post embedded in a web page that shows text being cut off.
I had more to say!

I could add the following css to force the embed to expand as needed, but that’s one of those solutions that you find out after working on something else.

.mastodon-embed {
  overflow-y: auto !important;
}

Full stop, this is where I should have stopped but I’ve already invested the time to make this shortcode.

How?

This is a Hugo shortcode that will allow you to embed a mastodon post into your blog. It places the post or toot in the document as a <blockquote> and is still pretty legible my RSS reader. It’s 100% based off of this post by Bryce Wray. I think that you can find updates from the original author by looking at the git repository for his site.

I’m not a Go expert like Leon, who could give you a wonderful breakdown of the code. :) Suffice to say, if you’ve got a background in code you can figure it out.

My goal is to pull the specific code out so that I can use it on Micro.blog as a plugin for myself and others. So, I pulled out the shortcode and an associated css file and placed it in a different repository.

stoot plugin on GitHub

Again, I didn’t change any of the code found in the css file and you may look at it and wonder where --text-base and --social-sans-serif are defined. Those are in Bryce’s hugo-site repository under assets/css/partial/__050-global.css. I thought about just adding them to this repository, but I wanted to get some feedback from users and I saw that it seems to work without it.

I tested the plugin with a couple other Micro.blog themes such as Sumo, tiny, cards, and Tufte and it seemed to work well. Although, Tufte did have the images show up larger than I would have liked. You can use custom css to make changes as desired.

Usage and comparison examples

The shortcode format looks like the following.

{{< stoot instance="$InstanceTLD" id="$Id" >}}

PLEASE NOTE: I had to remove the brace on either side because of it wasn’t attempting to process the shortcode in the code block above. I tried using %lbrace; but it doesn’t replace it properly. FIXED: Changed the block to be markdown and putting a comments /* */ around the contents worked.

Below, you’ll find the mastodon embeds and then stoot renderings. As of this moment, stoot does not do anything with the text of posts that are marked as sensitive. I’ve removed the call the the javascript after every embed to reduce repeated calls2.

Regular ole toot

Working on another technical project. It’s looking like it’s going to get more complicated than I expected. Part of me is excited and part of me dreads having to hunt down unexpected issues.

This is a toot with an image

I think I might give this a try.

Image 112878275931064198 from toot 112878275954894008 on social.lol

This is a toot with multiple images

Another post with multiple images.

Image 112962303425778240 from toot 112962304543748930 on social.lol Image 112962303502420039 from toot 112962304543748930 on social.lol Image 112962303545024636 from toot 112962304543748930 on social.lol Image 112962303550922135 from toot 112962304543748930 on social.lol

This is something with a content warning.

Notice the difference in what is displayed by both.

I'm trying something with a content warning.

This is a toot with content warning on the images.

Multiple images with sensitive content

Image 112962342032467150 from toot 112962351533984937 on social.lol
Sensitive content
(flagged at origin)
Image 112962342033758096 from toot 112962351533984937 on social.lol
Sensitive content
(flagged at origin)
Image 112962342039351201 from toot 112962351533984937 on social.lol
Sensitive content
(flagged at origin)
Image 112962342040977991 from toot 112962351533984937 on social.lol
Sensitive content
(flagged at origin)

This is a poll

Test poll. Toppings on pizza.

85.7%
Yes
14.3%
No

Considerations for the future

After working on this, there are somethings I’d like to think about in the future.

1. What changes would I like to implement?

This plugin uses different style choices. It fits perfectly into Bryce’s site because it was made by and for him. I’m essentially taking what he’s done and shoved it into my page.

This is on me to change using the custom css option offered by Micro.blog.

2. Another shortcode?

During testing, I realized that I’ve added a fair amount of shortcodes in my writing. Hugo doesn’t handle this well and makes transitioning between different themes troublesome.

I’m playing with the idea of creating a Micro.blog plugin that contains all the shortcodes that I’ve seen. I’ve thought about this everytime that I look at the Tufte theme, but I’d have to see how much bandwidth I have in September

Feedback

As always, I love getting feedback on any of this.


  1. The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one. -Mozilla documentation ↩︎

  2. I’m not an expert in javascript and don’t know if browsers are smart enough only call the script once. ↩︎

50 Ideas for Blog Posts by Lou Plummer #19

I do like talking about food and this one is lighter than yesterday's entry.

  1. What is your favorite food? Why do you like it? What is your history with it?

My favorite food is pizza 🍕. I’ve enjoyed it since I was a wee little lad. I do appreciate that there are many styles and combinations in the ways you can make and eat pizza.

For me, I feel the combination of meat, cheese, dough with a nice tomato based sauce is comforting. And for most of my life, I have eaten it with someone else. I know that there is pizza by the slice or personal sized pizzas, but pizza is more of a social experience for me. Collaborating with friends and family as to what toppings are going to be on it and trying to get the size right for possible leftovers is part of the fun.

It’s how I express my love.

French toast in cooking in the pan.

I’m pretty happy with the results!

50 Ideas for Blog Posts by Lou Plummer #18

I didn't expect this kind of question. I feel it is relevant to a lot of things in my life.

  1. How do you feel about alcohol? Is it something you enjoy? What do you like? What do you dislike?

The amount of times that I’ve seen alcohol used as a way to relax and have a good time has never come close to the amount of times that I’ve seen it make things worse.

I have addiction on both sides of my family and see the signs in so many people who use it just to get through the day. The problem being that it’s multiple days and multiple drinks.

It’s the magic ingredient in most of the arguments that I’ve had as an adult. Either during the drinking or some time the day afterwards.

I feel it’s the combination of being free of your inhibitions and having the excuse of having your inhibitions loosened that make it tantalizing for some.

I was drunk!

And it’s to number one drug in America.

I feel that it’s probably for the best because of all the regulations that have been placed over it. I’ve heard too many stories about other drugs being laced with unknown substances or prescriptions leading to people turning into zombies.

Ultimately, we should all find a better way to relax and have a good time.

📺 The Boys S4:E7

The Deep thinking about life
The Deep has alway been a very thoughtful character

This is the penultimate episode!

This episode like most of the season reminds me of a smoldering fire. It’s not as flashy as it was previously but it can still burn you and there is the occasional pop as the embers break.

I’m not trying to be deep or introspective on the (super) human condition or anything, but I feel that this is one of the most sinister episodes of the season. In our efforts to feel loved, respected, or powerful, what are we willing to do? What are we willing to give up?

I sometimes wonder if I spend too much time making test data for scenarios that no one cares about. Is it the back of the fence or the shape of the nail heads?

50 Ideas for Blog Posts by Lou Plummer #17

  1. What are your favorite books and why?

I think I'm going to say that my favorite genre of book is fantasy.

I think I’m drawn to the genre because most of them have a beginning, middle, and end where the protagonist resolves everything at the end. Not as complicated as real life.

📺 Harley Quinn (Season 4) - ★☆☆☆☆

Harley Quinn TV Poster
The poster reflects the fact that there is less in the show to care about

Season four? More like Season Snore!

But seriously, I found myself struggling to care about the series at the end. The only thing pushing me through those episodes at the end was my desire to just be done with the whole thing.

I feel that this season does a disservice to the series as it renders all the characters to one note copies of what they were in previous seasons. Why does a character do something? It’s because the plot or joke demands it and pushes the episode forward so that we can fill the runtime.

Looking back on it, I can probably sum up the season to about 4 or 5 plot points. That ultimately set us up to be in roughly the same spot we were in back in season 2. I think that’s what frustrates me the most. The fact that I invested my time in watching this when there are so many other things available.

Skip this season.

Working on another technical project. It’s looking like it’s going to get more complicated than I expected. Part of me is excited and part of me dreads having to hunt down unexpected issues.