Reply contexts are an IndieWeb feature that displays a short summary view of a post that you’re replying to, liking, reposting, or RSVPing to.
Most reply context implementations run on the server, when publishing or updating a post. They fetch the original post, extract the useful parts, store them locally, and include them when rendering the reply post.
This is fine, but there’s another option. You could write a JavaScript library that injects reply contexts into a post after it’s rendered on the client, in the browser. The interesting part is that this library could work on any CMS; all you need to do is serve it!
Here are the steps it would take after a document is loaded:
- Parse the local document’s
microformats and look for
in-reply-to
,like-of
, andrepost-of
links. (RSVPs will have anin-reply-to
.) - Fetch each of those URLs, probably using a CORS proxy like crossorigin.me.
- Parse the fetched page and render it as a reply context/link-preview. Good resources here include oEmbed, Embedly, Kevin Marks’s hovercard generator, and Slack’s unfurling.
- Inject the resulting reply context into the current post’s DOM, probably just
before the
e-content
. - Optionally include a default stylesheet that renders the reply context nicely.
Thoughts?
I’ve long avoided implementing reply contexts here on snarfed.org. I very much enjoy using WordPress, but I don’t particularly enjoy hacking on it. Having said that, I’ve had this idea in the back of my mind for a while now, and mentioned it to enough people, so I decided it was time to write it up.