<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Comments feed</title>
        <link>https://evgenykuznetsov.org/en/posts/2021/old-comments/</link>
        <description>Webmentions Again (And More) on DIMV - Comments feed</description>
        <generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>evgeny@kuznetsov.md (Evgeny Kuznetsov)</managingEditor>
            <webMaster>evgeny@kuznetsov.md (Evgeny Kuznetsov)</webMaster><lastBuildDate>Tue, 31 Aug 2021 15:11:34 &#43;0300</lastBuildDate>
            <atom:link href="https://evgenykuznetsov.org/en/posts/2021/old-comments/comments.xml" rel="self" type="application/rss+xml" />
        <atom:link href="https://switchboard.p3k.io/" rel="hub" />
    <atom:link href="https://evgenykuznetsov.superfeedr.com/" rel="hub" />
    <item>
    <title>Ejitsu liked</title>
    <link>https://twitter.com/nekr0z/status/1432678306474778628#favorited-by-2886029872</link>
    <pubDate>Tue, 31 Aug 2021 14:30:56 &#43;0000</pubDate>
    <author>Ejitsu</author>
    <guid>https://brid.gy/like/twitter/nekr0z/1432678306474778628/2886029872_https://evgenykuznetsov.org/en/posts/2021/old-comments/_1259613</guid>
    <description><![CDATA[Ejitsu liked <a href="https://evgenykuznetsov.org/en/posts/2021/old-comments/">https://evgenykuznetsov.org/en/posts/2021/old-comments/</a>]]></description>
</item><item>
    <title>Third steps to Indieweb</title>
    <link>https://petersmith.org/blog/2022/01/10/third-steps-to-indieweb/</link>
    <pubDate>Mon, 10 Jan 2022 00:53:19 &#43;0000</pubDate>
    <author>Peter Smith</author>
    <guid>https://petersmith.org/blog/2022/01/10/third-steps-to-indieweb/_https://evgenykuznetsov.org/en/posts/2021/old-comments/_1329017</guid>
    <description><![CDATA[<p>
My new theme, is working well enough that I have now republished my website using it. It also means that I have webmentions working as well. I have some rough edges to sort out but its definitely a MVP (minimum viable product).</p>
<p>
It feels as if a cast of thousands have been involved in the this new theme. I have so many people to thank.</p>
<p>
First there is <a href="https://aaronparecki.com/">Aaron Parecki</a>. I had been watching his <a href="https://www.youtube.com/c/aaronpk">videos</a> to help me get into doing my video production (for the <a href="https://www.youtube.com/channel/UCEli3VWKuB4lyZ3M4uKVIlw">BusDev@Auckland seminar series</a>) but then I stumbled into his website, and was introduced to the world of <a href="https://indieweb.org/">Indieweb</a> and <a href="https://www.w3.org/TR/webmention/">webmentions</a>. Aaron's site <a href="https://webmention.io/">webmention.io</a> also provided the glue to get webmentions working here.</p>
<p>
Soon after my first foray into webmentions, I got a <a href="https://robbinespu.gitlab.io/indieweb/211010050323/">mention</a> by <a href="https://robbinespu.gitlab.io/">Robbi Nespu</a>. That was important not just because of the excellent advice Robbi gave me, but it also gave me the impetus to charge ahead with trying to fully implement webmentions. Looking at Robbi's <a href="https://robbinespu.gitlab.io/indieweb/">site</a>, I still need to do more work to get things like 'bookmarks', 'rsvps', and other Indieweb things working here.</p>
<p>
That all prompted me to start (re)theme-ing this site to better accommodate webmentions. As I say, it works, but there is still more to be done.</p>
<p>
The basic idea for the current style of this site came from <a href="https://ministryoftype.co.uk/">The Ministry of Type</a>. In many ways it is reminiscent of the style I was using about seven or eight themes (site versions) ago. In other ways, I am paying a big homage to that site. I was rather surprised that it hasn't been updated since 2015.</p>
<p>
My basic process for 'dealing to' webmentions is use the API at <a href="https://webmention.io/">webmention.io</a> to download them all as a single JSON file. First I did it using curl. Then I wrote a Python script based on the <a href="https://randomgeekery.org/post/2020/11/using-the-webmentionio-api/">work</a> of <a href="https://randomgeekery.org/">Brian Wisti</a>. I added in some code to process the JSON with a view to splitting it up into separate JSON files for go into the director of each post (My site is structured using Hugo's <a href="https://gohugo.io/content-management/page-bundles/">page bundles</a>, with each post (and associated material) living in its own directory).</p>
<p>
I then moved on to using <a href="https://github.com/nekr0z/webmention.io-backup">webmention.io-backup</a> to fetch the JSON file. This cunning <a href="https://evgenykuznetsov.org/en/posts/2020/webmention-backup/">tool</a> from <a href="https://evgenykuznetsov.org/">Evgeny Kuznetsov</a> works pretty well. I would have liked to use the option to place the 'mentions' in the same directory as the posts, but I couldn't because his directory structure (the one the tool supports) and mine aren't compatible. Whilst <a href="https://evgenykuznetsov.org/en/posts/2021/old-comments/">Evgeny also seems to be using page bundles</a>, his structure is different. Que sera. Having said that, I need to get a bit techy …</p>
<p>
… so, I use Evgeny's tool to download my webmentions. I then access them using <code>.Site.data</code> (<a href="https://gohugo.io/templates/data-templates/">data templates</a>) as shown a bit later on.. E.g., with the following, it I want to access the author's name, then I would use <code>.Site.data.author.name</code> in my Hugo templates.</p>

<pre style="background-color:#f8f8f8;"><code>  {
    <span style="color:#008000;font-weight:700;">"author"</span>: {
      <span style="color:#008000;font-weight:700;">"name"</span>: <span style="color:#b44;">"Robbi Nespu"</span>,
      <span style="color:#008000;font-weight:700;">"photo"</span>: <span style="color:#b44;">"https://webmention.io/avatar/robbinespu.gitlab.io/6e26274b5791d929b75d7450e7a5c1f9e0d19134bb0c641705f0a1e41742e4d2.png"</span>,
      <span style="color:#008000;font-weight:700;">"type"</span>: <span style="color:#b44;">"card"</span>,
      <span style="color:#008000;font-weight:700;">"url"</span>: <span style="color:#b44;">"https://robbinespu.gitlab.io/"</span>
    },</code></pre>

<p>
Easy eh! Well, it actually took me a long time, and posts such as <a href="https://www.thenewdynamic.com/article/toward-using-a-headless-cms-with-hugo-part-1/">this</a> and <a href="https://www.thenewdynamic.com/article/toward-using-a-headless-cms-with-hugo-part-2-building-from-remote-api/">this</a> from <a href="https://www.thenewdynamic.com/">The New Dynamic</a>, to get it working. On the way I ran in to a couple of problems. First, in testing (i.e., running the site locally using <code>hugo server</code>), the URLs on the local test site didn't match those in the mentions. E.g., my local URLs began <code>http://localhost:1313/</code> where as the live posts/mentions had URLs that started with <code>https://petersmith.org</code>. So I bodged that up with a little string replacement in my templates (see, a bit further on).</p>
<p>
The second problem had to do the names of the keys used in JSON file. In the above JSON example, there are keys such as "author" and "name". That's great. But later on, following the <a href="https://github.com/aaronpk/webmention.io#api">webmention docs</a>, there are keys such as "wm-target" and "mention-of" … all beginning with "wm-". And the <code>-</code> doesn't place nice with with <code>hugo</code>. A key such as <code>wm-target</code> when accessed through <code>.Site.data.wm-target</code> falls over because <code>hugo</code> treats it as it it were <code>.Site.data.wm - target</code>; it tries to subtract something called <code>target</code> from <code>wm</code>. Doh!</p>
<p>
So, I run a teeny tiny sed script on the JSON file from <code>webmention.io</code> to change all the hyphens in key names into underscores. It's not a pretty script of sophisticated script, but it seems to do the job. In total, <code>getMentions.sh</code> looks like this:</p>

<pre style="background-color:#f8f8f8;"><code><span style="color:#080;">#!/bin/sh
</span><span style="color:#080;"></span>
<span style="color:#b8860b;">FILENAME</span><span style="color:#666;">=</span><span style="color:#b44;">"data/mentions.json"</span>
rm -fr <span style="color:#b68;font-weight:700;">${</span><span style="color:#b8860b;">FILENAME</span><span style="color:#b68;font-weight:700;">}</span>

webmention.io-backup -t -y4QezN6pCs5CNVshkMHaQ -d petersmith.org -f <span style="color:#b68;font-weight:700;">${</span><span style="color:#b8860b;">FILENAME</span><span style="color:#b68;font-weight:700;">}</span>  -jf2 -tlo<span style="color:#666;">=</span><span style="color:#a2f;">false</span> -p 

<span style="color:#080;font-style:italic;">#</span>
<span style="color:#080;font-style:italic;"># Now fix the pesky hypens in the poperty names</span>
<span style="color:#080;font-style:italic;">#</span>
sed -i  <span style="color:#b44;">'
</span><span style="color:#b44;">s/\(^ *\)"like-of":/\1"like_of":/
</span><span style="color:#b44;">s/\(^ *\)"mention-of":/\1"mention_of":/
</span><span style="color:#b44;">s/\(^ *\)"in-reply-to":/\1"in_reply_to":/
</span><span style="color:#b44;">s/\(^ *\)"wm-/\1"wm_/'</span> <span style="color:#b68;font-weight:700;">${</span><span style="color:#b8860b;">FILENAME</span><span style="color:#b68;font-weight:700;">}</span></code></pre>

<p>
So, instead of trying to access <code>.Site.data.wm-target</code>, I go for <code>.Site.data.wm_target</code>, and that works great. As an example, here is the <code>hugo</code> partical template I use to check to see how many mentions or replies a post has.</p>

<pre style="background-color:#f8f8f8;"><code>
{{- $permalink := replace .Permalink "http://localhost:1313/" "https://petersmith.org/" -}}
{{- $webmentions := .Site.Data.mentions -}}
{{- $likes := 0 -}}
{{- range $webmentions -}}
{{- if (and (or .in_reply_to .mention_of ) (eq .wm_target $permalink)) -}}
{{- $likes = add $likes  1 -}}
{{- end -}}
{{- end -}}
{{- $likes -}}</code></pre>

<p>
The 'partial' returns the count (0 or more) of the mentions as page has. I have similar 'partials' that produce a count of the number of 'likes' a page has.</p>
<p>
So far, so good. I don't quite have the displaying of mentions perfect, but it works.</p>
<p>
That said, there are some design/architecture choices I have made that I need to revisit, but I don't think any changes to that will change how the site looks and functions from a user's perspective. In practice, I use one large JSON file from <code>webmention.io</code>. I still wonder if I should use individual JSON files for each post. I think that would make processing time/site build time/scalability better. But that would me either writing a 'post processor' to run after Evgeny's tool, or to write my own. There's some thinking I need to do about that.</p>
<p>
I also wonder about finding a way to fetch and save the author images/avatars to improve page load times. As <a href="https://www.zachleat.com/web/facepile/">others have found</a> this can be a bit of a pig. I do already use 'loading="lazy"' for the avatars, but is that enough. It would be nice to download load them and save them when I build the site.</p>
<p>
Oh, well. That's enough for now. Time to go back and tweak the stylesheet to get the 'mentions' looking nice.</p>]]></description>
</item></channel>
</rss>