Adding reply context to my social pages

Published on under the IndieWeb category.

Reply context showing on a blog post on my site with a description of the page I liked

When I first started implementing my Micropub endpoint, the tool I use to post content such as likes and bookmarks on my website, I decided that I would show a brief message stating how I had reacted a post. The format for these posts was “I liked ABC” or “I have bookmarked XYZ.” These were fine to begin with but I recently started to think that my posts lacked context. Unless someone clicked on the link, there was little context on what I was responding to.

That has changed with the launch of the new reply context feature on my social pages. “Reply context” is basically information about a reply, such as who wrote the post to which I am replying and a brief excerpt of the post to which I am replying. In this post, I am going to roughly describe how I have added reply context to my social pages and how this will affect the social reactions I post on my site.

What my reply contexts look like

Before I talk about the technicalities of this project, I want to show you what my reply pages look like now:

Reply context showing on a blog post on my site with an image of the original post author visible

This is an example where I was able to retrieve all of the information I wanted to, from the author of the post I liked to the actual contents of the post I liked. In this case, I posted a like on my website in response to a Tweet.

My “reply context” feature is capable of showing the following pieces of information when I post a like, bookmark, or other reaction on my site:

  • A photo of the person to whom I am reacting .
  • A link to the page to which I am reacting (examples: a Youtube video or a blog post).
  • The name of the person who created the content I have reacted to (example: James).
  • The title of the page I am liking.
  • An excerpt of the page I am liking.

All of the information above, with the exception of the link to the page, may not appear on every new post. This is because not every site publishes the information above or publishes it in a way that I can easily consume.

Implementing reply context on my Micropub client

I decided that I would implement reply contexts on my Micropub client, the tool through which I post all of my social interactions. This is because having reply context on the client would let me see what context would be posted before I actually created a social post on my website. Seeing the context means I have a rough idea of how a post is going to look before it has even made it’s way onto my site.

I wrote some Python code which does three things:

  1. Looks for microformats on the page. If microformats are available, my program will read them and look for information like who wrote the post I want to respond to and a small excerpt from the article.
  2. If no microformats are present, my code looks for the title of the page and will attempt to take an excerpt of the page.
  3. If the page I am liking is a Tweet, I use the Twitter API to get the contents of the Tweet and the author so that I can share this context on my site. This is exactly what I done to achieve the “like” in response to a Tweet that I showed in an image at the start of this article.

This code runs every time I try to react to a URL from the “bookmarklets” in my bookmarks. These bookmarklets let me respond to a post without having to manually add the URL. If I use a bookmarklet, the context retrieved from my program will appear on my “create post” page so I can preview what my code has retrieved.

Here is an example of what this looks like:

Reply context showing on my website publishing page

There is a grey box where the reply context is displayed to me. When I hit the submit button at the bottom of the form, that context is submitted to my Micropub server and will make its way onto my website.

Why is context so important?

When you like a Tweet on Twitter, the entire Tweet shows up in your list of liked Tweets. This is useful because it means you can easily see what you have liked. I wanted a similar feature on my personal website so I could display at least an excerpt from a piece of content that I have liked, rather than just saying “I liked ABC” or “I bookmarked XYZ,” where the letters are equal to the URL or title of the post with which I have interacted. A visitor could just click on a link to see the page I have liked but I wanted some context to be available without a user having to click onto another site.

Wrapping up

My new reply context is part of my publishing workflow. Any time I create a new social post on my site—a like, a reply, a bookmark, or a repost—reply context should show up at the top of the post. If no reply context is available, my code falls back to my old implementation. As a result, some posts may say “I liked XYZ” without context, but this is not a problem for me.

Have you added reply contexts to your blog? Do you have suggestions on how I can improve mine? Feel free to email me at readers@jamesg.blog or send this post a Webmention if your site supports Webmentions. I would love to hear from you!

Also posted on IndieNews.

Go Back to the Top