Stoot now has an option that will remove the Open Graph / Meta Tags card associated with the first link in a mastodon post. If you are interested in the tags that Mastodon sees, you can go to OpenGraph XYZ to put in your favorite URLs. Here a direct link to your fifth favorite. Mastodon takes the information meta tags from the first URL and makes them look nice when you post. For example, I posted a toot1 with a link to a post that created. I will get something like the following.
Summary
You can now add a toot to your blog without including the Open Graph tag.
The new enableOGCard option defaults to true so that it doesn’t unexpectedly change on people who have an older version of this plugin.
Details about the HTML and CSS structure
About a week ago, I got a message asking why stoot would render the image twice for the same mastodon toot.
Honestly, I had no idea it was doing this and haven’t looked at the code since I had packaged it up two weeks ago.
But, I didn’t want to leave this person without any help so I started to look into the issue and was able to reproduce the problem with a toot from someone I was already following.
A very pretty picture, but I don’t know if seeing it twice in succession.
For me to understand something better, I like to diagram it as I step through the code. I’ve included this diagram that shows you what div tags are created when using stoot. If you can always check out the code on GitHub.
Toot-block
This is the CSS class in the blockquote element that contains the entire mastodon post.
Toot-header
The div contains the information about the account that created the toot.
Toot-profile
This is the profile image of the account that made the toot. I included this CSS from the original project to establish a baseline for styling.
Toot-author
This is a div that contains the two links toot-author-name and toot-author-name that go to the same account page.
Toot-author-name
The name that toot author is going by at the time of rendering. The names sometimes changes as decided by the person in charge of the account.
Toot-author-handle
This is the account name in the @name@server format that mastodon likes to use.
Content
This is the main text of your toot.
Toot-img-grid
Stoot includes CSS and logic to handle 1, 2, 3, or 4 images in a grid and render them properly.
Toot-video-wrapper
Behind the scenes, there are two possible wrappers that render depending on what kind of video media is included with the toot.
Toot-card
This the div that contains the Open Graph card of the first link in the toot. This will include an image, title, and description from the website in the URL.
Toot-poll-wrapper
This is the div that containers HTML <meter> elements to convey the
Toot-footer
Contains date and time of the toot.
The problem is coming from the toot-card and I didn’t want to change all the cards, because someone might have become reliant on this behaviour or worse - never noticed it.
Further CSS Details
I didn’t want to make people work hard to style the included card, so I removed some styling from the CSS.
There are two div tags in the toot card that you can use to make things work to your satisfaction.
Controlling the Card
The problem is coming from the toot-card and I didn’t want to change all the cards, because someone might have become reliant on this behaviour or worse - never noticed it.
After idenifying the part of the code that controlled the cards, I set a conditional around it.
{{ifeq$enableOGCard"true"}}{{with$json.card}}{{-$cardData:=.-}}{{-with$cardData.image-}}<ahref="{{$cardData.url}}"rel="'noopener"><divclass="toot-card"><divclass="toot-card-image"><imgsrc="{{$cardData.image}}"alt="Card image from {{$masIns}} toot {{$id}}"loading="lazy"class="toot-card-image-image"/></div><divclass="toot-card-content"><pclass="card-title">{{$cardData.title}}</p><pclass="card-description">{{$cardData.description}}</p></div></div></a>{{-end-}}{{end}}{{end}}
At the top of the file, we have the following line that sets the value to a default in case it is isn’t specified.
I would like to change the alt text for the incoming images, but I think I would have to learn more about what is offered from mastodon using this API.
I want to that @lmika for giving me some advice about the go programming language. I also want to thank @DaveyCraney for giving me some feedback about stoot.
And I want to thank you for making it to the end of this article.
I am really hating the different names for slightly different things right now. ↩︎
I’m on mastodon too mucha 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.
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.
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
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.
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.
{{<stootinstance="$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.
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.
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.
**Unfortunately**, A Book Apart is [no longer selling books](https://abookapart.com/pages/about/) and I never managed to get a complete collection.
Fortunately, the authors of each book seem to be in control of what happens to their books, meaning their books are potentially still available in some way.
I always played with the idea of picking up a couple books to learn more about making my website better.
This one without a title
Just a small test to see what details and summary look like in my RSS feed.
Just a small test to see what details and summary look like in my RSS feed.
Spoilers
Do not give the ending away.
Also, I’ll see if mastodon hides it as well.
I thought about changing the table of contents from an <aside> to a <section>. My reasoning that it’s a block element that is part of an <article> and I supply it with a header. Afterwards, I thought about using the <nav>.
Does the popover api work as a suitable replacement for footnotes?
Short answer: no.
Too long answer: read the rest of the article.
Also, click here to get to the code portions of this article.
The popover api has been baselined and I really wanted to explore what this feature can do for me and my writing. I thought it would be a simple project of looking into what it is and how it could help me be a better communicator on the internet.
When it comes to using new methods, you are better served by having a target or project. It just so happened that I’ve been thinking about whether or not footnotes are a good solution to adding tangental information to my posts.
So far, I’ve spent 2-3 hours researching and talking about this before I even started writing this article. I lost track how much time it took to get images and tests.
What is the popover API?
To put it in my own words, the popover api allows you to define an element in HTML that will pop up and over the rest of the content. This element is initially hidden and then can be toggled to be visible and above the other elements.
Examples from the internet
I got a lot of this from different resources on the internet. Here are some links to tutorials and examples if you are interested.
Hidde De Vries has a slide deck with links to articles that he wrote about popover. I was planning on using some of his accessibility suggestions during the writing of this article.
It’s good to see major companies doing this as it helps everyone. I just wanted to take this time to remind you that you can do your part by making your website a little more accessible.