<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://joelchrono.xyz/feeds/coding.xml" rel="self" type="application/atom+xml" /><link href="https://joelchrono.xyz/" rel="alternate" type="text/html" /><updated>2026-07-11T12:34:20-06:00</updated><id>https://joelchrono.xyz/feeds/coding.xml</id><title type="html">joelchrono’s blog</title><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><entry><title type="html">Improving my RSS feed</title><link href="https://joelchrono.xyz/blog/improving-my-rss-feed/" rel="alternate" type="text/html" title="Improving my RSS feed" /><published>2024-02-19T13:21:31-06:00</published><updated>2024-02-19T13:21:31-06:00</updated><id>https://joelchrono.xyz/blog/improving-my-rss-feed</id><content type="html" xml:base="https://joelchrono.xyz/blog/improving-my-rss-feed/"><![CDATA[<p>Playing around with Jekyll is great, or with any static site generator in general! But there can also be many ways to do things wrong! And while this is not really a problem most of the time, you could end up making a mess for your future self, like I’ve done this time.</p>

<p>However, I don’t see this as a failure, but as a way to keep improving myself, and something to write about in the process! So, I corrected the way I add a “reply via email (and fediverse) link” to each feed item, and also made my feed human-readable!</p>

<h1 id="adding-reply-via-email-and-fediverse-properly">Adding Reply via Email (and Fediverse!) properly</h1>

<p>Features such as includes and templates, can lead one towards the wrong path, and such was the case when I implemented email replies. I originally created an file in the <code class="language-plaintext highlighter-rouge">_include</code> folder, and I simply included it in every single article at the end, the contents of that file were hidden via CSS with <code class="language-plaintext highlighter-rouge">display:none</code>, it was a rushed and ugly way of doing this.</p>

<p>I decided to check what the rest of my friends were doing. And that’s where I noticed that in <a href="https://kevquirk.com">kevquirk.com</a>’s <a href="https://github.com/kevquirk/kq-jekyll/blob/main/feed.xml">source code</a> for its Jekyll version, the <code class="language-plaintext highlighter-rouge">feed.xml</code> file was simply, a customized feed template that included the reply via email button at the end. In his case, he escapes the XML and pasted it directly:</p>

<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;description&gt;</span>
{{ post.content | xml_escape }}
<span class="ni">&amp;lt;</span>p style=<span class="ni">&amp;quot;</span>font-size:1.3rem<span class="ni">&amp;quot;&amp;gt;&amp;lt;</span>a href=<span class="ni">&amp;quot;</span>mailto:{{ site.email | xml_escape }}?subject={{ post.title | xml_escape }}<span class="ni">&amp;quot;&amp;gt;</span>Reply to this post via email<span class="ni">&amp;lt;</span>/a<span class="ni">&amp;gt;&amp;lt;</span>/p<span class="ni">&amp;gt;</span>
<span class="nt">&lt;/description&gt;</span>
</code></pre></div></div>

<p>I was using the <code class="language-plaintext highlighter-rouge">jekyll-feed</code> plugin for this, but I decided to change it for my own custom template too, but I am using the Atom format, instead of RSS 2.0. Since my current feed was using the Atom format, I didn’t want to break something by changing it too much.</p>

<p>As for the way I implemented the reply link, I went for a different—maybe more elegant—method, where I can still edit the proper HTML easily via an include, and capturing its output in a variable that I can then escape. Here is what it looks like:</p>

<div class="language-liquid highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;content type="html" xml:base="<span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">url</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">absolute_url</span><span class="w"> </span><span class="cp">}}</span>"&gt;
    <span class="cp">{{</span><span class="w"> </span><span class="nv">post</span><span class="p">.</span><span class="nv">content</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">xml_escape</span><span class="w"> </span><span class="cp">}}</span>
    <span class="cp">{%</span><span class="w"> </span><span class="nt">capture</span><span class="w"> </span><span class="nv">replies</span><span class="w"> </span><span class="cp">%}{%</span><span class="w"> </span><span class="nt">include</span><span class="w"> </span>replies.html<span class="w"> </span><span class="cp">%}{%</span><span class="w"> </span><span class="nt">endcapture</span><span class="w"> </span><span class="cp">%}</span>
    <span class="cp">{{</span><span class="w"> </span><span class="nv">replies</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">xml_escape</span><span class="w"> </span><span class="cp">}}</span>
&lt;/content&gt;
</code></pre></div></div>

<p>Now the end of every article contains a link to reply to it, just like on the website!</p>

<h1 id="customizing-the-look-of-my-rss-feed-with-xslt">Customizing the look of my RSS feed with XSLT</h1>

<p>Now, after doing the reply via email thing, I wasn’t feeling like only sharing a blogpost with one single website change that isn’t even that noticeable to begin with!</p>

<p>This is why I also decided to work on making my RSS feed <strong>human-readable</strong>, inspired by <a href="https://minutestomidnight.co.uk/blog/build-a-human-readable-rss-with-jekyll/">this post from Minutes to Midnight</a>—although I recall seeing this applied on some other people’s feeds—I finally went ahead and tried XSLT templating!</p>

<p>This was quite a great excercise, but it proved to be harder than expected given the fact that Simone Silvestroni used RSS 2.0 like Kev. Therefore, I couldn’t just copy and paste—I had to find out how to apply this to my Atom feed. After some research online, it wasn’t that difficult—here’s what my template looks like now:</p>

<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code>---
layout: none
title: rss feed | joelchrono
permalink: "/feed.xsl"
---
<span class="cp">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="nt">&lt;xsl:stylesheet</span> 
<span class="na">version=</span><span class="s">"1.0"</span> 
<span class="na">xmlns:xsl=</span><span class="s">"http://www.w3.org/1999/XSL/Transform"</span>
<span class="na">xmlns:atom=</span><span class="s">"http://www.w3.org/2005/Atom"</span>
<span class="na">exclude-result-prefixes=</span><span class="s">"atom"</span>
<span class="nt">&gt;</span>
<span class="nt">&lt;xsl:output</span> <span class="na">method=</span><span class="s">"html"</span> <span class="na">version=</span><span class="s">"1.0"</span> <span class="na">encoding=</span><span class="s">"UTF-8"</span> <span class="na">indent=</span><span class="s">"yes"</span><span class="nt">/&gt;</span>
<span class="nt">&lt;xsl:template</span> <span class="na">match=</span><span class="s">"/"</span><span class="nt">&gt;</span>
  <span class="nt">&lt;html</span> <span class="na">xmlns=</span><span class="s">"http://www.w3.org/1999/xhtml"</span><span class="nt">&gt;</span>
    {% include head.html %}
    <span class="nt">&lt;body&gt;</span>
      <span class="nt">&lt;header&gt;</span>
        <span class="nt">&lt;center</span> <span class="na">class=</span><span class="s">"home-top"</span><span class="nt">&gt;&lt;a</span> <span class="na">href=</span><span class="s">"/"</span><span class="nt">&gt;</span>
            <span class="nt">&lt;svg</span> <span class="na">width=</span><span class="s">"80"</span> <span class="na">height=</span><span class="s">"60.5"</span> <span class="na">version=</span><span class="s">"1.1"</span> <span class="na">viewBox=</span><span class="s">"0 0 80 60.5"</span> <span class="na">xmlns=</span><span class="s">"http://www.w3.org/2000/svg"</span><span class="nt">&gt;&lt;g</span> <span class="na">transform=</span><span class="s">"matrix(1.76 0 0 1.76 -2.4 -12.1)"</span><span class="nt">&gt;&lt;g</span> <span class="na">fill=</span><span class="s">"#a9b1d6"</span><span class="nt">&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m36.9 6.84-0.79 4.5 2.77-0.913z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m33.2 7.73 0.288 4.14 2.66-0.523z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m29.9 9.46 1.1 4.2 2.5-1.79z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m27.1 11.7 1.75 4.28 2.13-2.32z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m24.8 14.5 2.6 4.2 1.4-2.68z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m23.1 17.6 3.71 3.53v-3.15z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m39.9 9.33a15.3 15.4 0 0 0-15 12.5l4.42-0.877a1.88 1.88 0 0 1 1.91 0.77 9.69 9.74 0 0 1 9.18-6.69 9.69 9.74 0 0 1 6.22 2.27l-0.345-6.53a15.3 15.4 0 0 0-6.38-1.4zm-15.1 17.7a15.3 15.4 0 0 0 13.3 13l-1.24-6.24a9.69 9.74 0 0 1-5.74-6.45 1.88 1.88 0 0 1-1.79 0.617zm21.9 5.15a9.69 9.74 0 0 1-3.22 1.78l-1.18 5.96a15.3 15.4 0 0 0 4.05-1.2z"</span> <span class="na">stop-color=</span><span class="s">"#000000"</span><span class="nt">/&gt;&lt;/g&gt;&lt;g</span> <span class="na">fill=</span><span class="s">"#9ece6a"</span><span class="nt">&gt;&lt;g</span> <span class="na">stroke-linecap=</span><span class="s">"round"</span> <span class="na">stroke-linejoin=</span><span class="s">"round"</span><span class="nt">&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m30.1 23.6a0.792 0.792 0 0 0-0.792 0.792 0.792 0.792 0 0 0 0.792 0.792h7.69a0.792 0.792 0 0 0 0.792-0.792 0.792 0.792 0 0 0-0.792-0.792z"</span> <span class="na">color=</span><span class="s">"#000000"</span><span class="nt">/&gt;&lt;path</span> <span class="na">class=</span><span class="s">"a"</span> <span class="na">d=</span><span class="s">"m29.7 26.1-8.41-1.67 8.41-1.67z"</span> <span class="na">stroke=</span><span class="s">"#9ece6a"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m40.2 21.2c-1.75 0-3.19 1.43-3.19 3.18s1.44 3.18 3.19 3.18 3.19-1.43 3.19-3.18-1.44-3.18-3.19-3.18zm0 1.58c0.897 0 1.61 0.706 1.61 1.59 0 0.886-0.708 1.59-1.61 1.59s-1.61-0.706-1.61-1.59c0-0.886 0.708-1.59 1.61-1.59z"</span> <span class="na">color=</span><span class="s">"#000000"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m40.9 32.3a0.792 0.591 0 0 1-0.792 0.591 0.792 0.591 0 0 1-0.792-0.591v-5.74a0.792 0.591 0 0 1 0.792-0.591 0.792 0.591 0 0 1 0.792 0.591z"</span> <span class="na">color=</span><span class="s">"#000000"</span><span class="nt">/&gt;&lt;path</span> <span class="na">class=</span><span class="s">"a"</span> <span class="na">d=</span><span class="s">"m38.5 32.2 1.67 8.41 1.67-8.41z"</span> <span class="na">stroke=</span><span class="s">"#9ece6a"</span><span class="nt">/&gt;&lt;/g&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m1.36 30.2v4.89l4.93 4.89v-9.77z"</span><span class="nt">/&gt;&lt;/g&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m6.25 40h8.35v-4.89h-8.35z"</span> <span class="na">fill=</span><span class="s">"#739449"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m6.35 13.6h8.2v-4.89h-8.2z"</span> <span class="na">fill=</span><span class="s">"#739449"</span><span class="nt">/&gt;&lt;g</span> <span class="na">fill=</span><span class="s">"#9ece6a"</span><span class="nt">&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m14.5 40h0.0928l4.84-4.89h-4.93z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m14.6 8.74v4.89h4.93z"</span><span class="nt">/&gt;&lt;path</span> <span class="na">d=</span><span class="s">"m14.5 13.6v21.5h4.93v-21.5h-4.89z"</span><span class="nt">/&gt;&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;</span>
        <span class="nt">&lt;/a&gt;&lt;/center&gt;</span>
        <span class="nt">&lt;center&gt;</span>
          {% include navigation.html %}
        <span class="nt">&lt;/center&gt;</span>
        <span class="nt">&lt;p&gt;</span>This is a web feed that can be viewed in the browser. <span class="nt">&lt;b&gt;</span>Subscribe for free<span class="nt">&lt;/b&gt;</span> by copying the URL <span class="nt">&lt;code&gt;</span> joelchrono.xyz/feed.xml <span class="nt">&lt;/code&gt;</span> into your RSS reader. <span class="nt">&lt;/p&gt;</span>

        <span class="nt">&lt;p&gt;</span>Read how <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"/blog/improving-my-rss-feed/"</span><span class="nt">&gt;</span>I improved this feed, and made it <span class="nt">&lt;b&gt;</span>human-readable<span class="nt">&lt;/b&gt;&lt;/a&gt;</span>.<span class="nt">&lt;/p&gt;</span>
      <span class="nt">&lt;/header&gt;</span>
      <span class="nt">&lt;main&gt;</span>
        <span class="nt">&lt;h2&gt;&lt;svg</span> <span class="na">xmlns=</span><span class="s">"http://www.w3.org/2000/svg"</span> <span class="na">width=</span><span class="s">"24"</span> <span class="na">height=</span><span class="s">"24"</span> <span class="na">viewBox=</span><span class="s">"0 0 455.731 455.731"</span> <span class="na">xml:space=</span><span class="s">"preserve"</span><span class="nt">&gt;</span> <span class="nt">&lt;path</span> <span class="na">style=</span><span class="s">"fill:#f78422"</span> <span class="na">d=</span><span class="s">"M0 0h455.731v455.731H0z"</span><span class="nt">/&gt;</span> <span class="nt">&lt;path</span> <span class="na">style=</span><span class="s">"fill:#fff"</span> <span class="na">d=</span><span class="s">"M296.208 159.16C234.445 97.397 152.266 63.382 64.81 63.382v64.348c70.268 0 136.288 27.321 185.898 76.931 49.609 49.61 76.931 115.63 76.931 185.898h64.348c-.001-87.456-34.016-169.636-95.779-231.399z"</span><span class="nt">/&gt;</span> <span class="nt">&lt;path</span> <span class="na">style=</span><span class="s">"fill:#fff"</span> <span class="na">d=</span><span class="s">"M64.143 172.273v64.348c84.881 0 153.938 69.056 153.938 153.939h64.348c0-120.364-97.922-218.287-218.286-218.287z"</span><span class="nt">/&gt;</span> <span class="nt">&lt;circle</span> <span class="na">style=</span><span class="s">"fill:#fff"</span> <span class="na">cx=</span><span class="s">"109.833"</span> <span class="na">cy=</span><span class="s">"346.26"</span> <span class="na">r=</span><span class="s">"46.088"</span><span class="nt">/&gt;</span> <span class="nt">&lt;/svg&gt;</span> Latest 20 posts<span class="nt">&lt;/h2&gt;</span>
        <span class="nt">&lt;xsl:apply-templates</span> <span class="na">select=</span><span class="s">"atom:feed/atom:entry[position() &amp;lt;= 20]"</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;/main&gt;</span>
      {% include footer.html %}
    <span class="nt">&lt;/body&gt;</span>
  <span class="nt">&lt;/html&gt;</span>
  <span class="nt">&lt;/xsl:template&gt;</span>
  <span class="nt">&lt;xsl:template</span> <span class="na">match=</span><span class="s">"atom:entry"</span><span class="nt">&gt;</span>
    <span class="nt">&lt;article</span> <span class="na">class=</span><span class="s">"posts wrapper"</span><span class="nt">&gt;</span>
      <span class="nt">&lt;p</span> <span class="na">class=</span><span class="s">"blog-data"</span><span class="nt">&gt;&lt;a</span> <span class="na">href=</span><span class="s">"{atom:link[@rel='alternate']/@href}"</span><span class="nt">&gt;&lt;b&gt;&lt;xsl:value-of</span> <span class="na">select=</span><span class="s">"atom:title"</span><span class="nt">/&gt;&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;</span>
      <span class="nt">&lt;div&gt;&lt;xsl:value-of</span> <span class="na">select=</span><span class="s">"atom:summary"</span> <span class="na">disable-output-escaping=</span><span class="s">"yes"</span> <span class="nt">/&gt;&lt;/div&gt;</span>
      <span class="nt">&lt;small</span> <span class="na">class=</span><span class="s">"post-date"</span><span class="nt">&gt;</span>
        <span class="c">&lt;!--Display the date in YYYY-MM-DD format--&gt;</span>
        <span class="nt">&lt;xsl:variable</span> <span class="na">name=</span><span class="s">"year"</span> <span class="na">select=</span><span class="s">"substring(atom:published, 1, 4)"</span><span class="nt">/&gt;</span>
        <span class="nt">&lt;xsl:variable</span> <span class="na">name=</span><span class="s">"month"</span> <span class="na">select=</span><span class="s">"substring(atom:published, 6, 2)"</span><span class="nt">/&gt;</span>
        <span class="nt">&lt;xsl:variable</span> <span class="na">name=</span><span class="s">"day"</span> <span class="na">select=</span><span class="s">"substring(atom:published, 9, 2)"</span><span class="nt">/&gt;</span>
        <span class="nt">&lt;xsl:value-of</span> <span class="na">select=</span><span class="s">"concat($year, '-', $month, '-', $day)"</span><span class="nt">/&gt;</span>
      <span class="nt">&lt;/small&gt;</span>
    <span class="nt">&lt;/article&gt;</span>
  <span class="nt">&lt;/xsl:template&gt;</span>
<span class="nt">&lt;/xsl:stylesheet&gt;</span>
</code></pre></div></div>

<p>You can check out how my RSS feed like in any browser! You will probably not be able to tell it is an xml file, but when you paste it into your RSS feed reader, it will be recognized like any other!</p>

<h1 id="final-thoughts">Final thoughts</h1>

<p>The new features in my RSS feed are honestly quite simple, and seem pretty easy to achieve now that I put my mind into it. I wonder why didn’t I do this sooner. Now I have to go back and edit the last line of every single markdown file in my posts folder, containing the include I no longer need…</p>

<p>Or I can write a script, and then blog about that :P</p>

<p>This is day 14 of <a href="https://100daystooffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="blog" /><category term="jekyll" /><category term="coding" /><category term="rss" /><summary type="html"><![CDATA[I did some changes to my website once again, and I changed the way my RSS feed works!]]></summary></entry><entry><title type="html">Rofi is my favorite app launcher</title><link href="https://joelchrono.xyz/blog/rofi-is-my-favorite-launcher/" rel="alternate" type="text/html" title="Rofi is my favorite app launcher" /><published>2023-01-16T13:15:00-06:00</published><updated>2023-01-16T13:15:00-06:00</updated><id>https://joelchrono.xyz/blog/rofi-is-my-favorite-launcher</id><content type="html" xml:base="https://joelchrono.xyz/blog/rofi-is-my-favorite-launcher/"><![CDATA[<p>Rofi describes itself as a <em>A window switcher, application launcher, ssh dialog, dmenu replacement and more</em>.</p>

<p>And that’s pretty much it. Its super fast and minimal, and works pretty much anywhere. There is even a <a href="https://hg.sr.ht/~scoopta/wofi">Wayland clone of it</a>, which I don’t use but at least its there.</p>

<p>Rofi is so good, I got really fired up when my fellow fedizen <a href="https://lazybear.social/hyde">@hyde</a> mentioned how <a href="https://lazybea.rs/posts/rofi-not-for-me/">rofi isn’t for him</a>, and he will stick to the default AwesomeWM launcher, I couldn’t help myself, and decided to write this post and answer to his complaints.</p>

<p>First of all. This is all written in a jokeful manner, no hard feelings or anything.</p>

<p><em>Seriously?</em> You use <a href="https://lazybea.rs/posts/passwords-and-websites/">pass</a> as your password manager, you use <a href="https://lazybea.rs/posts/dracula-and-mutt/">mutt for email</a>, stuff like <a href="https://lazybea.rs/posts/fzf/">fzf</a> and a bunch of other tools, you even got a weekly series of <a href="https://lazybea.rs/tags/cli/">CLI tool recommendations</a>. HOW DARE YOU disrespect rofi like THAT!?</p>

<p>Rofi can be integrated with pretty much all of the above. You can use tools such as <a href="https://github.com/carnager/rofi-pass">rofi-pass</a> to autofill your passwords everywhere (kind of better than KeepassXC Browser extensions tbh). You could create many kinds of things with neomutt, like <a href="https://beune.dev/posts/mailto-neomutt/">handling mailto: links</a></p>

<p>You can pretty much pipe whatever you want on rofi, and create general scripts for a ton of stuff. Compared to some launchers that come built-in in some desktop environments or window managers. Rofi will work on them all and can be customized quite a lot.</p>

<p>The only thing that comes close to rofi is one of its inspirations, <a href="https://tools.suckless.org/dmenu/">dmenu</a>. But given that it is even more bare bones and any additions have to be patched (rather than simply configured with rofi). I find it a little harder to sell for most.</p>

<p>I have a few posts sharing scripts, some of them <a href="/blog/rofi-automated-blog/">using rofi</a> and its simply <strong>fantastic</strong>. I’ve a couple other scripts you may be interested in checking out!</p>

<p>I actually recently changed the <a href="/blog/a-quick-tag-editor-for-my-website/">script to edit tags</a> to use just rofi. You can see some it, as well as some more of my rofi scripts <a href="https://tildegit.org/chrono/dotfiles/src/branch/main/stow_home/rofi/.config/rofi">in my dotfiles</a></p>

<p>This is day 16 of <a href="https://100daystooffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="bash" /><category term="coding" /><category term="linux" /><category term="foss" /><category term="ramble" /><summary type="html"><![CDATA[You probably already know by now, because I've mentioned almost as many times as to have a tag just for it. You should use Rofi!]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://joelchrono.xyz/assets/img/blogs/2023-01-16-rofi.jpg" /><media:content medium="image" url="https://joelchrono.xyz/assets/img/blogs/2023-01-16-rofi.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">A quick tag editor for my website</title><link href="https://joelchrono.xyz/blog/a-quick-tag-editor-for-my-website/" rel="alternate" type="text/html" title="A quick tag editor for my website" /><published>2023-01-05T08:08:43-06:00</published><updated>2023-01-05T08:08:43-06:00</updated><id>https://joelchrono.xyz/blog/a-quick-tag-editor-for-my-website</id><content type="html" xml:base="https://joelchrono.xyz/blog/a-quick-tag-editor-for-my-website/"><![CDATA[<p>I have a bit of a love hate relationship with bash scripting. Because you get to have access to all kinds of small tools, piping and doing unixy things, at the cost of having horrible syntax and being kinda hard to read sometimes.</p>

<p>Anyways, a couple posts ago I shared how to sort tags in different ways, the truth is I’ve been meaning to do some cleaning up, inspired by <a href="https://www.adamsdesk.com/posts/clean-tags-categories-two/">Adam’s post</a>.</p>

<p>He used the usual commands such as <code class="language-plaintext highlighter-rouge">sed</code> and <code class="language-plaintext highlighter-rouge">grep</code>, and I decided to quickly write a script to edit the desired tags for any file in a similar manner.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/bash</span>
<span class="c">#</span>
<span class="nv">file</span><span class="o">=</span><span class="nv">$1</span>
<span class="nv">oldtags</span><span class="o">=</span><span class="si">$(</span><span class="nb">cat</span> <span class="nv">$1</span> | <span class="nb">grep</span> <span class="s2">"tags:"</span> | <span class="nb">head</span> <span class="nt">-1</span> | <span class="nb">awk</span> <span class="s1">'{for (i=2; i&lt;NF; i++) printf $i " "; print $NF}'</span><span class="si">)</span>

<span class="nb">echo</span> <span class="nv">$oldtags</span> <span class="o">&gt;</span> /tmp/tagedit
vim /tmp/tagedit

<span class="nv">newtags</span><span class="o">=</span><span class="si">$(</span><span class="nb">cat</span> /tmp/tagedit<span class="si">)</span>

<span class="nb">rm</span> <span class="nt">-fv</span> /tmp/tagedit

<span class="nb">sed</span> <span class="nt">-i</span> <span class="s2">"s/</span><span class="nv">$oldtags</span><span class="s2">/</span><span class="nv">$newtags</span><span class="s2">/g"</span> <span class="s2">"</span><span class="nv">$file</span><span class="s2">"</span>
</code></pre></div></div>

<p>This code is rather simple, it takes the path of a file, which is given as an argument, running something like</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./edit-tags.sh filename
</code></pre></div></div>

<p>That filename is parsed, using grep, head and awk. a new temporary file containing all existing tags of that file gets opened with vim, containing the existing tags. From there I can add or remove tags as I please, and once saved, I replace the original file accordingly.</p>

<p>It is rather simple, and I think it could be done better. So please, I beg you to give me any suggestions to improve it. I tried my best to understand stuff like <code class="language-plaintext highlighter-rouge">getopts</code> and the like, to have arguments and flags but I just didn’t really get it.</p>

<p>Regardless, this is day 5 of my second attempt at <a href="https://100daystooffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="tutorial" /><category term="coding" /><category term="bash" /><category term="vim" /><summary type="html"><![CDATA[Yeah, I keep adding new scripts to make my blogging life easier. In this case, to help me edit tags with less hassle.]]></summary></entry><entry><title type="html">Sorting tags in Jekyll</title><link href="https://joelchrono.xyz/blog/sorting-tags-in-jekyll/" rel="alternate" type="text/html" title="Sorting tags in Jekyll" /><published>2023-01-03T16:31:39-06:00</published><updated>2023-01-03T16:31:39-06:00</updated><id>https://joelchrono.xyz/blog/sorting-tags-in-jekyll</id><content type="html" xml:base="https://joelchrono.xyz/blog/sorting-tags-in-jekyll/"><![CDATA[<p>So tags are quite a useful feature to loosely categorize posts in my blog. I’ve been using them for quite a while, but I never really liked the way they were shown in my website.</p>

<p>I had been showcasing a <em>tag cloud</em> in my home page for quite a while, I don’t know how many actually used it at all (let me know if you did please, I wanna know), but I decided to move it to my <a href="/tags">tags</a> section, which has been there for a while. However, I also decided to try and sort them in a better way.</p>

<p>So far, I think jekyll sorted my tags in whatever order they were created. This was clearly <strong>not</strong> ideal for me.</p>

<p>I took my time to look around online and see other ways to do this from different blogs such as <a href="https://mindthecode.com/blog/sorting-tags-in-jekyll/">this one</a>, (while writing this blog I came across <a href="https://lei1025.github.io/Implement-Sorting-Tags-by-Name-and-Value-in-Jekyll/">another similar post</a>). I found them kinda hard to understand so wrote this anyways. I think the code I found is kinda good but please, let me know if it can be improved!</p>

<p>Here’s how I can sort them alphabetically as well as based on the amount of posts each has.</p>

<h1 id="sorting-by-name">Sorting by name</h1>

<p>The following snippet will sort all tags by name and will also show the amount of posts they contain.</p>

<div class="language-liquid highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;ul&gt;
<span class="cp">{%</span><span class="w"> </span><span class="nt">assign</span><span class="w"> </span><span class="nv">sorted_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">site</span><span class="p">.</span><span class="nv">tags</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">sort</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">for</span><span class="w"> </span><span class="nv">tag</span><span class="w"> </span><span class="nt">in</span><span class="w"> </span><span class="nv">sorted_tags</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">assign</span><span class="w"> </span><span class="nv">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">tag</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">first</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">assign</span><span class="w"> </span><span class="nv">posts</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">tag</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">last</span><span class="w"> </span><span class="cp">%}</span>
&lt;li&gt;&lt;a href="/tags/<span class="cp">{{</span><span class="w"> </span><span class="nv">tag</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="cp">}}</span>/"&gt;<span class="cp">{{</span><span class="w"> </span><span class="nv">tag</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="cp">}}</span>&lt;/a&gt; has <span class="cp">{{</span><span class="w"> </span><span class="nv">tag</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">size</span><span class="w"> </span><span class="cp">}}</span> posts&lt;/li&gt;
<span class="cp">{%</span><span class="w"> </span><span class="nt">endfor</span><span class="w"> </span><span class="cp">%}</span>
&lt;/ul&gt;
</code></pre></div></div>

<h1 id="sorting-by-post-quantity">Sorting by post quantity</h1>

<p>This one was a little trickier, but still quite simple to do.</p>

<div class="language-liquid highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;ul&gt;
<span class="cp">{%</span><span class="w"> </span><span class="nt">capture</span><span class="w"> </span><span class="nv">tags</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">for</span><span class="w"> </span><span class="nv">tag</span><span class="w"> </span><span class="nt">in</span><span class="w"> </span><span class="nv">site</span><span class="p">.</span><span class="nv">tags</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{{</span><span class="w"> </span><span class="nv">tag</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nf">size</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">plus</span><span class="p">:</span><span class="w"> </span><span class="mi">1000</span><span class="w"> </span><span class="cp">}}</span>#<span class="cp">{{</span><span class="w"> </span><span class="nv">tag</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="cp">}}</span>#<span class="cp">{{</span><span class="w"> </span><span class="nv">tag</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nf">size</span><span class="w"> </span><span class="cp">}}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">endfor</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">endcapture</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">assign</span><span class="w"> </span><span class="nv">sortedtags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">tags</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">split</span><span class="p">:</span><span class="s1">' '</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">sort</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">for</span><span class="w"> </span><span class="nv">tag</span><span class="w"> </span><span class="nt">in</span><span class="w"> </span><span class="nv">sortedtags</span><span class="w"> </span><span class="na">reversed</span><span class="w"> </span><span class="cp">%}</span>
<span class="cp">{%</span><span class="w"> </span><span class="nt">assign</span><span class="w"> </span><span class="nv">tagitems</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">tag</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">split</span><span class="p">:</span><span class="w"> </span><span class="s1">'#'</span><span class="w"> </span><span class="cp">%}</span>
&lt;li&gt;&lt;a href="/tags/<span class="cp">{{</span><span class="w"> </span><span class="nv">tagitems</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="cp">}}</span>/"&gt;<span class="cp">{{</span><span class="w"> </span><span class="nv">tagitems</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="cp">}}</span>&lt;/a&gt; has <span class="cp">{{</span><span class="w"> </span><span class="nv">tagitems</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="cp">}}</span> posts&lt;/li&gt;
<span class="cp">{%</span><span class="w"> </span><span class="nt">endfor</span><span class="w"> </span><span class="cp">%}</span>
&lt;/ul&gt;
</code></pre></div></div>

<h1 id="finishing-up">Finishing up</h1>

<p>So, that’s it. Did you expect me to explain it? This is not original material, I understand the first one maybe but I do not know what the <code class="language-plaintext highlighter-rouge">plus: 1000</code> does on the second snippet nor anything in that line. Regardless, it works just fine for me to be honest and perhaps it could work for you.</p>

<p>I still find Jekyll to be quite enjoyable, it seems to me like most blogs nowadays are either Hugo or plain old WordPress. Maybe its just my own bias and its nothing like that.</p>

<p>Besides, <strong><a href="https://github.com/void-linux/void-linux.github.io/">Void Linux itself</a>, the one above all</strong>, uses Jekyll. Therefore, I will do my duty and stay loyal to it… until I get bored, or something.</p>

<p>Also, this is gonna be day 3 of my second run of <a href="https://100daystooffload.com">#100DaysToOffload</a>, <em>always has been</em>.</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="jekyll" /><category term="tutorial" /><category term="blog" /><category term="coding" /><category term="webdev" /><summary type="html"><![CDATA[Jekyll allows you to make tags, which are quite useful. I've been working on reducing the amount of tags and changing the way I display them in my blog. So here's what's up]]></summary></entry><entry><title type="html">Using AI to do my homework</title><link href="https://joelchrono.xyz/blog/using-ai-to-do-my-homework/" rel="alternate" type="text/html" title="Using AI to do my homework" /><published>2022-12-03T20:17:06-06:00</published><updated>2022-12-03T20:17:06-06:00</updated><id>https://joelchrono.xyz/blog/using-ai-to-do-my-homework-takes-some-work-too</id><content type="html" xml:base="https://joelchrono.xyz/blog/using-ai-to-do-my-homework/"><![CDATA[<p>I’m a student in Mechatronics Engineering, and like many of you, I sometimes struggle with my homework assignments. Recently, I had a particularly challenging assignment that involved working with G code and implementing the nearest neighbor algorithm to find the shortest path through a set of coordinates. It was a daunting task, but with the help of the OpenAI assistant, I was able to complete my assignment and learn a lot in the process. In this blog post, I’ll share my experience and show you how the OpenAI assistant can help you with your homework too.</p>

<p>The nearest neighbor algorithm is a simple algorithm that can be used to find the shortest path through a set of points. The algorithm starts at a given point and chooses the point that is nearest to the current point as the next point in the path. This process is repeated until all points have been visited.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat </span>code.g | <span class="nb">grep </span>G00 | <span class="nb">grep </span>Y | <span class="nb">awk</span> <span class="s1">'{print $2, $3}'</span> | <span class="nb">sed</span> <span class="s1">'s/X//g '</span> | <span class="nb">sed</span> <span class="s1">'s/Y//g'</span>
</code></pre></div></div>

<p>The OpenAI assistant was a lifesaver! It provided me with a Python code snippet that was exactly what I needed to extract the coordinates from the G code file. The code was a breeze to use - just give it the G code file, and it’ll read each line, find the x and y coordinates, and spit out the results like a champ. It was like magic!</p>

<p>Next, I needed some help with implementing the nearest neighbor algorithm in Python. I turned to the trusty OpenAI assistant, and it didn’t disappoint! It provided me with a Python code snippet that used the scipy library to implement the algorithm. Just give it a list of points, and it’ll rearrange them in the order in which they would be visited by the nearest neighbor algorithm. It was like having a personal tutor by my side! Thanks, OpenAI assistant!</p>

<p>Finally, I asked the OpenAI assistant how to plot the coordinates and their path using the matplotlib library. It provided me with a Python code snippet that used matplotlib to plot the x and y coordinates as a line plot. This was exactly what I needed to visualize the data and complete the assignment. I was so grateful for the help of the OpenAI assistant - it truly made my homework a breeze!</p>

<p>Overall, I was impressed with the knowledge and helpfulness of the OpenAI assistant. I was able to use the code snippets provided by the assistant to complete my homework assignment and learn more about working with G code and the nearest neighbor algorithm. Thanks, OpenAI!</p>

<h1 id="making-a-blog-post-with-ai">Making a blog post with AI</h1>

<p>But what really impressed me was the assistant’s ability to help me write a blog post about my experience in a fun and engaging manner. It was able to take my dull and boring sentences and turn them into lively and interesting prose. Thanks to the OpenAI assistant, my blog post was a hit and I was able to share it with my friends.</p>

<p>If you need help with your homework or just want to write a fun blog post, I highly recommend giving the OpenAI assistant a try. It’s an amazing resource that can help you learn and succeed. Thanks, OpenAI!</p>

<h1 id="lets-write-a-bit-to-conclude">Let’s write a bit to conclude</h1>

<p>Did you notice it? I didn’t write a thing up until now!</p>

<p>Guys, <strong>this is insane</strong>. I actually did all of the things I mentioned and now I got a blog post generated for free for me!</p>

<p>How cool is this? How freaky? This is a game changer. Seriously. I am so scared and so excited to play around with this thing. I wonder how many people noticed the weird writing style. Funnily enough I was able to tell the assistant to reword some things and avoid mentioning other bits. It had a weird obsesion with mentioning how my professor was impressed even though I haven’t even shown him this code yet.</p>

<p>Anyway, I am so impressed and I will be back sometime soon. I will fully write the next post myself though, <em>trust me</em>.</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="coding" /><category term="school" /><category term="productivity" /><summary type="html"><![CDATA[So, OpenAI ChatGPT is a beast, it really is. This is the process I used to make my homework with it!]]></summary></entry><entry><title type="html">Vim macros and Jekyll includes</title><link href="https://joelchrono.xyz/blog/vim-macros-and-jekyll-includes/" rel="alternate" type="text/html" title="Vim macros and Jekyll includes" /><published>2022-06-30T10:53:30-05:00</published><updated>2022-06-30T10:53:30-05:00</updated><id>https://joelchrono.xyz/blog/vim-macros-and-jekyll-includes</id><content type="html" xml:base="https://joelchrono.xyz/blog/vim-macros-and-jekyll-includes/"><![CDATA[<p>Yesterday I talked about converting all my images to WebP, because it would help keep the file sizes smaller, improving loading times. However I have to say I agree with <a href="https://thenighthas.me/@isa">@isa</a> when she mentioned how annoying it is to not have a jpg or png file available to download since webp is still not as supported by Image viewers and the like, or if you dislike file formats that stick out from the standard.</p>

<p>So I decided to keep both webp and jpg files available. I am not sure of what makes a browser choose one over the other. For now, I pretty much copy pasted the solution used by <a href="https://minutestomidnight.co.uk/blog/implementing-webp-images-in-jekyll/">Simone on his blog</a>, I only added some code to support <code class="language-plaintext highlighter-rouge">.gif</code> files, since WebP supports animation too.</p>

<p>Implementing this was not difficult at all. I created a file inside of my <code class="language-plaintext highlighter-rouge">_includes</code> folder containing the following template:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;figure</span> <span class="na">class=</span><span class="s">"{{ include.class | default: 'img' }}"</span><span class="nt">&gt;</span>
  <span class="nt">&lt;picture&gt;</span>
    <span class="nt">&lt;source</span> <span class="na">srcset=</span><span class="s">"{{ include.image | replace:'.png','.webp' | replace:'.jpg','.webp' | replace:'.jpeg','.webp' | replace: '.gif','.webp' }}"</span> <span class="na">type=</span><span class="s">"image/webp"</span><span class="nt">&gt;</span>
    <span class="nt">&lt;source</span> <span class="na">srcset=</span><span class="s">"{{ include.image }}"</span> <span class="err">{%</span> <span class="na">if</span> <span class="na">include.image</span> <span class="na">contains</span> <span class="err">'.</span><span class="na">jpg</span><span class="err">'</span> <span class="na">or</span> <span class="na">include.image</span> <span class="na">contains</span> <span class="err">'.</span><span class="na">jpeg</span><span class="err">'</span> <span class="err">%}</span><span class="na">type=</span><span class="s">"image/jpeg"</span><span class="err">{%</span> <span class="na">elsif</span> <span class="na">include.image</span> <span class="na">contains</span> <span class="err">'.</span><span class="na">png</span><span class="err">'</span> <span class="err">%}</span><span class="na">type=</span><span class="s">"image/png"</span> <span class="err">{%</span><span class="na">elsif</span> <span class="na">include.image</span> <span class="na">contains</span> <span class="err">'.</span><span class="na">gif</span><span class="err">'%}</span><span class="na">type=</span><span class="s">"image/gif"</span><span class="err">{%</span> <span class="na">endif</span> <span class="err">%}</span><span class="nt">&gt;</span>
    <span class="nt">&lt;img</span> <span class="na">class=</span><span class="s">"mx-auto"</span> <span class="na">src=</span><span class="s">"{{ include.image }}"</span> <span class="na">alt=</span><span class="s">"{{ include.alt | default: include.caption }}"</span> <span class="err">{{</span> <span class="na">include.width</span> <span class="err">?</span> <span class="na">include.width</span> <span class="err">|</span> <span class="na">prepend:</span> <span class="err">'</span><span class="na">width=</span><span class="s">"' | append: '"</span><span class="err">'</span> <span class="err">}}</span> <span class="err">{{</span> <span class="na">include.height</span> <span class="err">?</span> <span class="na">include.height</span> <span class="err">|</span> <span class="na">prepend:</span> <span class="err">'</span><span class="na">height=</span><span class="s">"' | append: '"</span><span class="err">'</span> <span class="err">}}</span><span class="nt">&gt;</span>
  <span class="nt">&lt;/picture&gt;</span>
  {% if include.caption %}<span class="nt">&lt;figcaption</span> <span class="na">class=</span><span class="s">"caption"</span><span class="nt">&gt;</span>{{ include.caption }}<span class="nt">&lt;/figcaption&gt;</span>{% endif -%}
<span class="nt">&lt;/figure&gt;</span>
</code></pre></div></div>

<p>Now all I have to do when using an image in a blogpost is provide both a webp and a jpg/png/gif file with the same filename, and use the following template:</p>

<div class="language-liquid highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">{%</span><span class="w"> </span><span class="nt">include</span><span class="w"> </span>img.html<span class="w"> </span><span class="na">image</span><span class="o">=</span><span class="s2">"/path/to/assets/image.jpg"</span><span class="w"> </span><span class="na">width</span><span class="o">=</span><span class="s2">"512px"</span><span class="w"> </span><span class="na">alt</span><span class="o">=</span><span class="s2">"Alternate text"</span><span class="w"> </span><span class="na">caption</span><span class="o">=</span><span class="s2">"A caption"</span><span class="w"> </span><span class="cp">%}</span>
</code></pre></div></div>

<p>I was already using Jekyll’s includes for a lot of things, such as the comments system, the articles of blogs I follow and other things. Its a really powerful tool that I quite like. However, editing each existing file could take me a long time. I actually did a <a href="https://benign.town/@joel/108564145793713657">poll on mastodon</a> to see what people would do. As of the writing of this post, most people say they would handle this by hand. And, to be honest, that’s kinda what I did, but I had some tricks up my sleve.</p>

<h1 id="vim-macros-to-the-rescue">Vim macros to the rescue</h1>

<p>Using macros with Vim is simply fantastic, I took a while to mention them, for some reason, all I had to do was implement 2 macros for the different kinds of markup I’ve used. Be it plain markdown (<code class="language-plaintext highlighter-rouge">![title](source)</code>) or plain html (<code class="language-plaintext highlighter-rouge">&lt;figure&gt;&lt;img&gt;&lt;/img&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;</code>). There were a couple of edge cases, like when I included links inside of the captions and such.</p>

<p>There are many examples and videos that talk about doign Vim macros, so I will just share some videos of how they worked out.</p>

<p>For Markdown, I pretty much look for <code class="language-plaintext highlighter-rouge">![</code> and then used Vim keybindings to go word for word <code class="language-plaintext highlighter-rouge">w</code>, to the end of the line <code class="language-plaintext highlighter-rouge">$</code> and such, rinse and repeat.</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2022-06-30_macros.gif" type="image/webp" />
    <source srcset="/assets/img/blogs/2022-06-30_macros.gif" type="image/gif" />
    <img class="mx-auto" src="/assets/img/blogs/2022-06-30_macros.gif" alt="Macro used for Markdown syntax." />
  </picture>
  <figcaption class="caption">Macro used for Markdown syntax.</figcaption></figure>

<p>The steps to make a macro for HTML were a bit more complicated, but doable nonetheless.</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2022-06-30_macros2.gif" type="image/webp" />
    <source srcset="/assets/img/blogs/2022-06-30_macros2.gif" type="image/gif" />
    <img class="mx-auto" src="/assets/img/blogs/2022-06-30_macros2.gif" alt="Macro used for HTML syntax." />
  </picture>
  <figcaption class="caption">Macro used for HTML syntax.</figcaption></figure>

<p>My macro had some problems, since I was doing <code class="language-plaintext highlighter-rouge">dt"</code> to <em>delete</em> the contents of something un<em>til</em> a <em>quote</em> showed up, along other similar things, adding a link to a <code class="language-plaintext highlighter-rouge">figcaption</code> broke my macro in a couple cases. But other than that, it worked alright. I also had to run my macro from a certain position relative to the HTML, or else other things would not work properly.</p>

<p>I guess doing macros is pretty much its own artform, I’ve seen some uses for them that blew me away. If you have not used them for anything before, you might want to give them a try next time you script something!</p>

<h1 id="finishing-thoughts">Finishing thoughts</h1>

<p>If I am honest, I still don’t know how I feel about it making use of includes in this way, since making the changes here was kinda annoying. But, thinking about it, it only took me like half an hour to do. I don’t know, maybe simply using something like <code class="language-plaintext highlighter-rouge">xclip</code> or <code class="language-plaintext highlighter-rouge">xdotool</code> to quickly access the plain HTML template would be a lot better to keep my markdown platform agnostic. I will think about it, but for now Jekyll is still my platform of choice.</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="webdev" /><category term="coding" /><category term="vim" /><category term="jekyll" /><category term="fediverse" /><category term="blog" /><summary type="html"><![CDATA[I've not talked about Vim in a while, but today it was quite handy while setting up WebP fallbacks to support old browsers using Jekyll's includes feature]]></summary></entry><entry><title type="html">New logo and other changes</title><link href="https://joelchrono.xyz/blog/new-logo-and-other-changes/" rel="alternate" type="text/html" title="New logo and other changes" /><published>2022-06-24T11:37:52-05:00</published><updated>2022-06-24T11:37:52-05:00</updated><id>https://joelchrono.xyz/blog/new-logo-and-other-changes</id><content type="html" xml:base="https://joelchrono.xyz/blog/new-logo-and-other-changes/"><![CDATA[<h1 id="other-site-changes">Other site changes</h1>

<p>So if you visited my website today morning you might have a couple differences compared to yesterday. I always enjoy changing and improving the look and feel of my internet home.</p>

<p>As you probably already know, I use <a href="https://jekyllrb.com">Jekyll</a> to generate my site, and I quite like how powerful it is, but sometimes it gets a little annoying. I was using <a href="https://github.com/syldexiahime/jekyll-webring/">jekyll-webring</a> to automatically generate a list of articles from different websites and blogs I follow. However, it was proving quite annoying while testing changes, since serving the site locally took like 30 seconds to complete, and it kinda looped the generation sometimes, making my CPU fan spin a ton.</p>

<p>I’ve decided to remove it and go back to <a href="https://git.sr.ht/~sircmpwn/openring">openring</a>, which I was already using before, and do a simple script to create the file locally myself.</p>

<p>Other than that I also changed the way my archive is displayed. Before, I had a simple list of articles, which was fine, but the right side felt kinda empty on the desktop. I tried adding the date, and even tags in previous attempts, but it ended up looking too cluttered on mobile. Eventually, I went ahead and <del>shamelessly copied</del> got really inspired by <a href="https://chriswiegman.com">Chris Wiegman’s</a> website, so now my article archive is shown in a grid, there is a hover animation, the article title wraps without moving the date from its place, its pretty nice now.</p>

<p>I also applied that styling to the tag pages. In case you didn’t know you can access <a href="/tags/">all posts of a certain tag</a>, and even follow an RSS feed of it, which may be quite useful if you only care about some topics of mine. Its particularly nice if your RSS reader supports hiding posts with the same titles, like FreshRSS.</p>

<h1 id="a-new-logo">A new logo</h1>

<p>This is not really that big of a deal, but I wanted to have a new favicon and logo for my website, I had been using a character from <a href="https://joelchrono12.itch.io/swap-die-repeat">my first game jam entry</a>, and since it was pixel art, it looked fairly good as a favicon. I mean, I already know how to use Inkscape and I’ve done icons and stuff, so it was about time.</p>

<p>I was a little inspired by Kev Quirk’s logo design, where its pretty much just his initials arranged in a very cool manner, but the event that triggered my desire to do this was actually <a href="https://warmedal.se/~bjorn/index.html">Björn Wärmedal</a> and his cup emoji icon that I thought looked super awesome.</p>

<p>However, I wanted to have something that was a bit more representative of me and what I liked. At first, I went a little too crazy, and started with something like this:</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2022-06-24-favicon_v1.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2022-06-24-favicon_v1.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2022-06-24-favicon_v1.jpg" alt="My initial logo idea" width="512px" />
  </picture>
  <figcaption class="caption">I can't believe I thought this was decent enough to export</figcaption></figure>

<p>it has too many colors and it would never have worked as a favicon. <del>Un</del>fortunately I lost the original file, since I was working on top of it during some time and eventually got lost in the undo history.</p>

<p>In this design I used the C from Chrono Trigger’s title screen, since I’ve said countless times how its my favorite game. I made the logo with Inkscape, and it is actually a modification from the one I did for the Arcticons Icon pack.</p>

<p>The J is from my name, and the font comes <a href="http://www.thealmightyguru.com/GameFonts/Series-ChronoTrigger.html">from here</a>. Its based on the font used in the game text boxes and dialogues, so I thought it was quite fitting. Eventually ending up this logo, which I actually pushed to my site for a few hours before this article was written.</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2022-06-24-favicon_v2.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2022-06-24-favicon_v2.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2022-06-24-favicon_v2.jpg" alt="An improved and simplified version" width="512px" />
  </picture>
  <figcaption class="caption">I was pretty happy with this one, not gonna lie!</figcaption></figure>

<p>However, while the pixel art font was cool and all, and I can justify it with my love for emulation and retro games, I kinda wanted to have something different and simpler, more minimal.</p>

<p>I decided to look for some fonts that kinda looked like origami, and I stumbled upon <a href="https://creiden.com/free-origami-letters/">this one</a>. So I downloaded it and pasted that J in its place, and ended up with my (for now) current logo!</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/logo.webp" type="image/webp" />
    <source srcset="/assets/img/logo.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/logo.jpg" alt="Current logo" width="512px" />
  </picture>
  <figcaption class="caption">My current choice, maybe it'll change in the future again...</figcaption></figure>

<h1 id="conclusion">Conclusion</h1>

<p>I was thinking about maybe setting the clock inside of the C to say its 12 o’clock, but I didn’t really feel like it, it just doesn’t look right.</p>

<p>I made other small changes here and there in my website, I am always fiddling around so it was about time I made another one of these posts.</p>

<p>Anyways, that’s all for today folks.</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="blog" /><category term="webdev" /><category term="design" /><category term="coding" /><summary type="html"><![CDATA[I was really bored, so I made a new logo for my website, inspired, as always, by other people's blogs.]]></summary></entry><entry><title type="html">Sharing my blogs to the Fediverse automatically</title><link href="https://joelchrono.xyz/blog/sharing-my-blogs-to-the-fediverse-automatically/" rel="alternate" type="text/html" title="Sharing my blogs to the Fediverse automatically" /><published>2022-06-10T20:00:34-05:00</published><updated>2022-06-10T20:00:34-05:00</updated><id>https://joelchrono.xyz/blog/sharing-my-blogs-to-the-fediverse-automatically</id><content type="html" xml:base="https://joelchrono.xyz/blog/sharing-my-blogs-to-the-fediverse-automatically/"><![CDATA[<p>There are many problems that come when you don’t use some CMS like Wordpress or Ghost, and this is one of them. When I <a href="https://joelchrono.xyz/blog/how-to-add-mastodon-comments-to-jekyll-blog/">chose Mastodon as commenting system for my blog</a> I realized it would be quite a process to share my post and get the comment section working. I had already <a href="https://joelchrono.xyz/blog/rofi-automated-blog/">automated the blog creation process</a>, but I still had to do all this:</p>

<ul>
  <li>finish writing</li>
  <li>git add, git commit, git push</li>
  <li>write toot on mastodon sharing my blogpost</li>
  <li>copy toot link</li>
  <li>paste toot link id on original blogpost</li>
  <li>git add, git commit, git push</li>
  <li>comments section now works!</li>
</ul>

<p>However, I decided to summon the power of the command line and bash scripting once again, and I finally managed to automate pretty much all of it.</p>

<p>It depends on some basic tools such as <code class="language-plaintext highlighter-rouge">sed</code>, <code class="language-plaintext highlighter-rouge">cut</code>, <code class="language-plaintext highlighter-rouge">grep</code>, but it also requires a very simple mastodon client for the command line, <code class="language-plaintext highlighter-rouge">toot</code>, you probably have it all installed already, and toot is not hard to setup either way.</p>

<p>There really is not a lot to talk about other than this. Here is the script, its not really super clean or anything (any suggestion are absolutely welcome) but at least its serviceable.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/bash</span>

<span class="k">if </span>git rev-parse <span class="nt">--git-dir</span> <span class="o">&gt;</span> /dev/null 2&gt;&amp;1<span class="p">;</span> <span class="k">then</span>
    : <span class="c"># This is a valid git repository</span>

    <span class="c"># All markdown files start with YYYY-MM-DD</span>
    <span class="nv">lastpost</span><span class="o">=</span><span class="si">$(</span>/usr/bin/ls <span class="k">${</span><span class="nv">markdown_posts_folder</span><span class="k">}</span>/<span class="k">*</span>.md | <span class="nb">sort</span> <span class="nt">-r</span> | <span class="nb">head</span> <span class="nt">-n</span> 1<span class="si">)</span> 
    <span class="nv">getdesc</span><span class="o">=</span><span class="si">$(</span><span class="nb">grep</span> <span class="s2">"description:"</span> <span class="nv">$lastpost</span> | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s2">" "</span> <span class="nt">-f2-</span><span class="si">)</span>
    <span class="nv">geturl</span><span class="o">=</span><span class="si">$(</span><span class="nb">grep</span> <span class="s2">"permalink:"</span> <span class="nv">$lastpost</span> | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s2">" "</span> <span class="nt">-f2-</span><span class="si">)</span>
    <span class="nv">gettags</span><span class="o">=</span><span class="si">$(</span><span class="nb">grep</span> <span class="s2">"tags:"</span> <span class="nv">$lastpost</span> | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s2">" "</span> <span class="nt">-f2-</span> | <span class="nb">sed</span> <span class="nt">-r</span> <span class="s1">'s/([^ ]+)/#\1/g'</span><span class="si">)</span>
    <span class="nv">post</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nt">-e</span> <span class="s2">"</span><span class="k">${</span><span class="nv">getdesc</span><span class="k">}</span><span class="s2"> </span><span class="se">\n\n</span><span class="s2">https://joelchrono.xyz/</span><span class="k">${</span><span class="nv">geturl</span><span class="k">}</span><span class="s2"> </span><span class="se">\n\n</span><span class="k">${</span><span class="nv">gettags</span><span class="k">}</span><span class="s2"> #blogpost"</span><span class="si">)</span>
    <span class="nv">posturl</span><span class="o">=</span><span class="si">$(</span>toot post <span class="s2">"</span><span class="nv">$post</span><span class="s2">"</span> | <span class="nb">cut</span> <span class="nt">-d</span>/ <span class="nt">-f5</span><span class="si">)</span>
    <span class="nb">echo</span> <span class="nv">$posturl</span>
    <span class="nb">sed</span> <span class="nt">-i</span> <span class="s2">"s/commentsid/</span><span class="nv">$posturl</span><span class="s2">/g"</span> <span class="s2">"</span><span class="nv">$lastpost</span><span class="s2">"</span>

    git add <span class="k">*</span>
    git commit <span class="nt">-m</span> <span class="s2">"automatically added comments"</span>
    git push

    <span class="nb">exit</span>

<span class="c"># directory may not be the top level.</span>
<span class="c"># Check the output of the git rev-parse command if you care</span>
<span class="k">else</span>
    : <span class="c"># this is not a git repository</span>
    <span class="nb">echo</span> <span class="s2">"Run this inside of website folder"</span>
    <span class="nb">exit

</span><span class="k">fi</span>
</code></pre></div></div>

<p>There you go, I hope you find it useful, maybe you can improve it even further. If so, make sure to let me know, I am still learning these things.</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="blog" /><category term="tutorial" /><category term="coding" /><category term="bash" /><category term="linux" /><category term="git" /><category term="webdev" /><category term="blog" /><summary type="html"><![CDATA[I always share my blogposts on Mastodon when I am done writing them, but it has always been a little annoying to do so. Not anymore.]]></summary></entry><entry><title type="html">Add images to Markdown files (for Jekyll)</title><link href="https://joelchrono.xyz/blog/add-images-to-markdown-files-(for-jekyll)/" rel="alternate" type="text/html" title="Add images to Markdown files (for Jekyll)" /><published>2022-01-27T10:16:00-06:00</published><updated>2022-01-27T10:16:00-06:00</updated><id>https://joelchrono.xyz/blog/add-images-to-markdown-files-(for-jekyll)</id><content type="html" xml:base="https://joelchrono.xyz/blog/add-images-to-markdown-files-(for-jekyll)/"><![CDATA[<p>So I have already done quite a lot of posts to make the creation of new posts easier. I find Jekyll to be a pretty decent static site generator, but this little script should work with whatever you got. As long as you customize it to your file structure.</p>

<p>The script comes as a request by <a href="https://fosstodon.org/@celia">Ru</a>, or at least this is what I hope she meant when <a href="https://fosstodon.org/@celia/107694900078045072">she posted</a>:</p>

<blockquote>
  <p>Static site users who embed images frequently – what’s your workflow for it? #AskFedi</p>
</blockquote>

<p>Well, my <em>previous workflow</em> was simple enough:</p>

<ol>
  <li>Take pictures.</li>
  <li>Move to assets folder.</li>
  <li>Rename them to something like $date-$filename_without_spaces.png.</li>
  <li>Add markdown syntax and type the whole thing.</li>
  <li>Cry because you messed up the directory path.</li>
</ol>

<p>So I went ahead and decided to work on a little script I named <code class="language-plaintext highlighter-rouge">aijk</code> (Add image to Jekyll), using bash and rofi, tools that I’ve used before with decent success. I am actually really happy of how it turned out.</p>

<h1 id="the-script">The script</h1>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>

<span class="c">### AIJK (Add image to Jekyll)</span>
<span class="c">### By joelchrono12</span>

<span class="nv">pic</span><span class="o">=</span><span class="nv">$1</span>
<span class="nv">name</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 50 <span class="nt">-p</span> <span class="s2">"Title"</span> <span class="nt">-dmenu</span><span class="si">)</span>
<span class="nv">filen</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nv">$name</span> | <span class="nb">tr</span> <span class="s2">" ,.!"</span> <span class="s2">"-"</span>| <span class="nb">awk</span> <span class="s1">'{print tolower($0)}'</span><span class="si">)</span>
<span class="nv">today</span><span class="o">=</span><span class="si">$(</span><span class="nb">date</span> +<span class="s2">"%Y-%m-%d"</span><span class="si">)</span>
<span class="nv">filename</span><span class="o">=(</span><span class="nv">$today</span>-<span class="nv">$filen</span><span class="o">)</span>
<span class="nv">path</span><span class="o">=</span>/path/to/website <span class="c">#without / at the end</span>
<span class="nv">imgs</span><span class="o">=</span>/from/site_root/to/assets/ <span class="c">#example = /assets/img/blogs/</span>
<span class="nv">last_post</span><span class="o">=</span><span class="si">$(</span>/usr/bin/ls /path/to/markdown/files/<span class="k">*</span>.md | <span class="nb">sort</span> <span class="nt">-r</span> | <span class="nb">head</span> <span class="nt">-n</span> 1<span class="si">)</span>

convert <span class="nv">$1</span> <span class="nt">-quality</span> 75 <span class="k">${</span><span class="nv">path</span><span class="k">}${</span><span class="nv">imgs</span><span class="k">}${</span><span class="nv">filename</span><span class="k">}</span>.png

<span class="nb">printf</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">![</span><span class="k">${</span><span class="nv">name</span><span class="k">}</span><span class="s2">](</span><span class="k">${</span><span class="nv">imgs</span><span class="k">}${</span><span class="nv">filename</span><span class="k">}</span><span class="s2">.png)"</span> <span class="o">&gt;&gt;</span> <span class="nv">$last_post</span>

</code></pre></div></div>

<h2 id="how-to-use">How to use</h2>

<p>Once added to your $PATH and making it executable, all you need is to change the required paths in the script, I think most of you will be able to figure it out on your own, but reach me out if you need help.</p>

<p>You can run it just by doing this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>aijk file.png
</code></pre></div></div>

<p>This is how it works:</p>

<ul>
  <li>Obtain picture file from argument.</li>
  <li>Add a Title to file via a rofi input.</li>
  <li>Create filename for file itself.</li>
  <li>Set paths to different required things (depends on your site).</li>
  <li>Get the latest markdown files from your site.</li>
  <li>Make changes to picture so its smaller or whatever (can be customized, requires ImageMagick).</li>
  <li>Print formatted markdown line to bottom of the latest markdown file.</li>
</ul>

<h2 id="adding-a-graphical-option-for-mouse-users">Adding a Graphical option for mouse users</h2>

<p>You can run this script with absolute ease from your terminal, if that’s what you want, but I also figured out a way to do it from a GUI if you are using Thunar as a file manager (might be possible with others, haven’t checked).</p>

<ol>
  <li>Open Thunar &gt; Edit &gt; Configure custom actions.</li>
  <li>Add a new entry for <code class="language-plaintext highlighter-rouge">aijk</code> and save it.</li>
</ol>
<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2022-01-27-thunar-configuration.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2022-01-27-thunar-configuration.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2022-01-27-thunar-configuration.jpg" alt="" />
  </picture>
  </figure>

<ol>
  <li>Set the appearance conditions to images only.</li>
  <li>Right click on any image to try it out!</li>
</ol>

<h1 id="final-thoughts">Final thoughts</h1>

<p>I am not completely happy with how this works. But this is usable and easy to expand, there could be a way to select the destination file instead of just getting the latest one. But I don’t normally add new images to old posts anyways, so I figured most people would be ok with how this works right now.</p>

<p>The script also assumes you want to start all your files with the date, and that your markdown files also start with the dates, since <code class="language-plaintext highlighter-rouge">sort</code>  will fail to place the line in the latest file, if such file is not the first in its output.</p>

<p>There is also no way to do this with multiple files as of now, I might be able to come up with something, I could just create another script that makes use of this one to make multiple additions at once.</p>

<p>Anyways, this is what I’ll do now to add images, I will simply right click, click again and give them a name!. Or do it properly in the terminal, whatever fits me best.</p>

<p>This has been day 95 of <a href="https://100daystooffload.com">#100DaysToOffload</a>. Make sure to check out <a href="https://rusingh.com/">Ru’s website</a>, since she single-handedly managed to inspire me to work on this quick script.</p>

<p><strong>NOTE: This is actually day 96, from here it all went wrong. If you don’t understand this note, [read here]</strong></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="tutorial" /><category term="coding" /><category term="bash" /><category term="linux" /><category term="webdev" /><category term="blog" /><category term="jekyll" /><summary type="html"><![CDATA[I decided to streamline the process of adding images to new posts quickly, how did I do it? Using bash scripts of course!]]></summary></entry><entry><title type="html">Blop static site generator</title><link href="https://joelchrono.xyz/blog/blop-static-site-generator/" rel="alternate" type="text/html" title="Blop static site generator" /><published>2022-01-14T20:12:58-06:00</published><updated>2022-01-14T20:12:58-06:00</updated><id>https://joelchrono.xyz/blog/blop-static-site-generator</id><content type="html" xml:base="https://joelchrono.xyz/blog/blop-static-site-generator/"><![CDATA[<p>So, I have been part of a Tilde community for a while, a public unix server known as <a href="https://tilde.cafe">tilde.cafe</a>.</p>

<p>Because of that, I got access to some nice things, like a website, a gemini capsule and an email address, which is kind of nice. I have been using that site as a place to mirror this very same website in case anything happens. Like losing my current domain or anything like that.</p>

<p><a href="https://gitlab.com/uoou/blop/">Blop</a> is a pretty nice static site generator that is basically just a bash script that uses other programs such as sed, awk and pandoc to put together a simple site generated from markdown files and simple templates.</p>

<p>However, it had a pretty serious issue, at least for me. The generated html files ended with <code class="language-plaintext highlighter-rouge">*.html</code> instead of being a clean url like here in Jekyll.</p>

<p>So I forked the project, put some work into it and I actually managed to do it!</p>

<p>I am not that great of a bash coder, and it was not really a matter of bash but of knowing where to look and using <code class="language-plaintext highlighter-rouge">/</code> to search for the right things in Vim.</p>

<p>In the end I now have clean URLs in my <a href="https://chrono.tilde.cafe">alternative site</a>, which is kind of great.</p>

<p>You can take a look at my fork, which is not really that different from the original in my <a href="https://tildegit.org/chrono/blop">tildegit</a> repository.</p>

<p>This has been day 83 of <a href="https://100daystooffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="bash" /><category term="coding" /><category term="blog" /><category term="short" /><category term="small-web" /><summary type="html"><![CDATA[While my main site is using Jekyll, I actually have another site that serves as a simpler mirror to this one. There I use Blop, an SSG written in Bash that I can customize to my liking]]></summary></entry><entry><title type="html">How to add comments to Jekyll blog</title><link href="https://joelchrono.xyz/blog/how-to-add-mastodon-comments-to-jekyll-blog/" rel="alternate" type="text/html" title="How to add comments to Jekyll blog" /><published>2021-12-29T09:20:00-06:00</published><updated>2021-12-29T09:20:00-06:00</updated><id>https://joelchrono.xyz/blog/adding-mastodon-comments-to-jekyll-blog-2022</id><content type="html" xml:base="https://joelchrono.xyz/blog/how-to-add-mastodon-comments-to-jekyll-blog/"><![CDATA[<p>As it usually is, I have already talked about this topic before, but I recently
did some changes both to the code and the styling of it, to make it better than
before, if I do say so myself.</p>

<p>First, I am going to credit every source of inspiration I got this from.
The original form of my commenting system was based on GitHub, I got it from
<a href="https://aristath.github.io/blog/static-site-comments-using-github-issues-api">an amazing post</a>
by <a href="https://github.com/aristath">Aristath</a>. This is where most of my
current code is based on. In this case, however, I am using Mastodon’s API instead of
GitHub’s since I think that most of my readers use Mastodon or are part of the
<a href="https://en.wikipedia.org/wiki/Fediverse">Fediverse</a>.</p>

<p>Secondly, is the first iteration of Mastodon’s code system I used, which I read
in <a href="https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/">Carl Schwan’s post about it</a>, this is what I used for a while, with GitHub in the mix too.</p>

<p>After a while, Mastodon comments proved to be a lot more common and easy to set
up, and I eventually stopped using GitHub, because it also required quite a lot
of steps to set it up, compared to just posting in Mastodon.</p>

<p>At some point, I decided to rewrite Mastodon’s commenting code with a structure
similar to GitHub’s, and I landed on this.</p>

<h1 id="jekyll-set-up">Jekyll set up</h1>

<p>To get started, I created a <code class="language-plaintext highlighter-rouge">comments.html</code> file inside the <code class="language-plaintext highlighter-rouge">_includes</code> directory which is part of Jekyll’s structure. This way, you could add it to your <code class="language-plaintext highlighter-rouge">_layouts</code>folder, or any section of your blog, and just add <code class="language-plaintext highlighter-rouge">{% include comments.html %}</code>, to tell Jekyll to insert that bit of code in there.</p>

<p>In order for said code to work, we are also going to need some metadata located inside of the front matter of each markdown file, in this case, we add the this:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">host</span><span class="pi">:</span> <span class="s">fosstodon.org</span>
<span class="na">username</span><span class="pi">:</span> <span class="s">joel</span>
<span class="na">com_id</span><span class="pi">:</span> <span class="m">107526114775171486</span>

</code></pre></div></div>
<p>Finally, we are going to start writing the HTML file that is going to be called
by every post we make!</p>

<h1 id="front-end">Front end</h1>

<p>Edit <code class="language-plaintext highlighter-rouge">comments.html</code> and place the following lines:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">"stylesheet"</span> <span class="na">href=</span><span class="s">"/assets/css/comments.css"</span><span class="nt">&gt;</span>
<span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">"article-content"</span><span class="nt">&gt;</span>
<span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">"comments-list"</span><span class="nt">&gt;&lt;/div&gt;</span>
<span class="nt">&lt;noscript&gt;&lt;p&gt;</span>You need JavaScript to view comments here.<span class="nt">&lt;/p&gt;&lt;/noscript&gt;</span>
<span class="nt">&lt;a</span> <span class="na">id=</span><span class="s">"load-comment"</span><span class="nt">&gt;</span>Load comments<span class="nt">&lt;/a&gt;</span> 
<span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"https://fosstodon.org/interact/107531143511314399?=type=reply"</span><span class="nt">&gt;</span>Reply via Mastodon<span class="nt">&lt;/a&gt;&lt;br&gt;</span>
<span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"/assets/js/purify.js"</span><span class="nt">&gt;&lt;/script&gt;</span>
<span class="nt">&lt;script&gt;</span>
    <span class="c1">//Here will be the rest of the code</span>
<span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/div&gt;</span>
</code></pre></div></div>

<p>The first line will call some specific styling that you should add if you would
like to style or make it fit better. You could use mine, but I can’t promise it
will work properly on your site.</p>

<p>Secondly, we have some <code class="language-plaintext highlighter-rouge">div</code> elements that are not really that important, it is
up to your CSS too.</p>

<p>Last, we call a couple of script elements that will contain the main JavaScript
code we’ll use.</p>

<h1 id="the-good-stuff">The good stuff</h1>

<p>Next we are going to add the main code will need to make all of this work as we
expect. This bit is going to print the comments by calling a different function
that will give format to each element.</p>

<h2 id="main-function">Main function</h2>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">load-comment</span><span class="dl">'</span><span class="p">).</span><span class="nf">addEventListener</span><span class="p">(</span><span class="dl">"</span><span class="s2">click</span><span class="dl">"</span><span class="p">,</span> <span class="k">async </span><span class="p">()</span> <span class="o">=&gt;</span> <span class="p">{</span>
    <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">load-comment</span><span class="dl">'</span><span class="p">).</span><span class="nf">remove</span><span class="p">();</span>
    <span class="kd">const</span> <span class="nx">response</span> <span class="o">=</span> <span class="k">await</span> <span class="nf">fetch</span><span class="p">(</span><span class="dl">'</span><span class="s1">https://fosstodon.org/api/v1/statuses/107531143511314399/context</span><span class="dl">'</span><span class="p">);</span>
    <span class="kd">const</span> <span class="nx">data</span> <span class="o">=</span> <span class="k">await</span> <span class="nx">response</span><span class="p">.</span><span class="nf">json</span><span class="p">();</span>
    <span class="k">if </span><span class="p">(</span><span class="nx">data</span><span class="p">.</span><span class="nx">descendants</span> <span class="o">&amp;&amp;</span> <span class="nx">data</span><span class="p">.</span><span class="nx">descendants</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
        <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">comments-list</span><span class="dl">'</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;h3&gt;Mastodon Comments&lt;/h3&gt;</span><span class="dl">"</span><span class="p">;</span>
        <span class="kd">let</span> <span class="nx">descendants</span> <span class="o">=</span> <span class="nx">data</span><span class="p">.</span><span class="nx">descendants</span><span class="p">;</span>
        <span class="k">for </span><span class="p">(</span><span class="kd">let</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">descendants</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
            <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">comments-list</span><span class="dl">'</span><span class="p">).</span><span class="nf">appendChild</span><span class="p">(</span><span class="nx">DOMPurify</span><span class="p">.</span><span class="nf">sanitize</span><span class="p">(</span><span class="nf">createCommentEl</span><span class="p">(</span><span class="nx">descendants</span><span class="p">[</span><span class="nx">i</span><span class="p">]),</span> <span class="p">{</span><span class="dl">'</span><span class="s1">RETURN_DOM_FRAGMENT</span><span class="dl">'</span><span class="p">:</span> <span class="kc">true</span><span class="p">}));</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">comments-list</span><span class="dl">'</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;p&gt;⚠️ No Mastodon comments yet ⚠️&lt;/p&gt;</span><span class="dl">"</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">});</span>
</code></pre></div></div>
<p>As you can see, once the “Load comments” button is pressed, we’re going to call
the main function, which will fetch data by calling Mastodon’s API and return a
JSON, then we are going to access the <code class="language-plaintext highlighter-rouge">descendants</code> object, which should have an
array of comments and its properties, which will be processed with the function <code class="language-plaintext highlighter-rouge">createCommentEl()</code>.</p>

<h2 id="comment-formatting">Comment formatting</h2>

<p>This function will get the data from the JSON and create HTML elements based on
that data. Here is the function:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nf">createCommentEl</span><span class="p">(</span><span class="nx">response</span><span class="p">){</span>
    <span class="kd">let</span> <span class="nx">user</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nf">createElement</span><span class="p">(</span><span class="dl">'</span><span class="s1">div</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">user</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nf">add</span><span class="p">(</span><span class="dl">'</span><span class="s1">mastodon-comment</span><span class="dl">'</span><span class="p">);</span>
    <span class="kd">let</span> <span class="nx">userAvatar</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nf">createElement</span><span class="p">(</span><span class="dl">'</span><span class="s1">img</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">userAvatar</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nf">add</span><span class="p">(</span><span class="dl">'</span><span class="s1">avatar</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">userAvatar</span><span class="p">.</span><span class="nf">setAttribute</span><span class="p">(</span><span class="dl">'</span><span class="s1">height</span><span class="dl">'</span><span class="p">,</span> <span class="mi">60</span> <span class="p">);</span> 
    <span class="nx">userAvatar</span><span class="p">.</span><span class="nf">setAttribute</span><span class="p">(</span><span class="dl">'</span><span class="s1">width</span><span class="dl">'</span><span class="p">,</span> <span class="mi">60</span> <span class="p">);</span> 
    <span class="nx">userAvatar</span><span class="p">.</span><span class="nf">setAttribute</span><span class="p">(</span><span class="dl">'</span><span class="s1">src</span><span class="dl">'</span><span class="p">,</span><span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">avatar_static</span><span class="p">);</span>
    <span class="nx">user</span><span class="p">.</span><span class="nf">appendChild</span><span class="p">(</span><span class="nx">userAvatar</span><span class="p">);</span>
    <span class="kd">let</span> <span class="nx">userLink</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nf">createElement</span><span class="p">(</span><span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">userLink</span><span class="p">.</span><span class="nf">setAttribute</span><span class="p">(</span><span class="dl">'</span><span class="s1">href</span><span class="dl">'</span><span class="p">,</span><span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
    <span class="nx">userLink</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nf">add</span><span class="p">(</span><span class="dl">'</span><span class="s1">comment-author</span><span class="dl">'</span><span class="p">);</span>
    <span class="k">for </span><span class="p">(</span><span class="kd">let</span> <span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">emojis</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">j</span><span class="o">++</span><span class="p">){</span>
        <span class="kd">let</span> <span class="nx">emoji</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">emojis</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
        <span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">display_name</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">display_name</span><span class="p">.</span><span class="nf">replace</span><span class="p">(</span><span class="s2">`:</span><span class="p">${</span><span class="nx">emoji</span><span class="p">.</span><span class="nx">shortcode</span><span class="p">}</span><span class="s2">:`</span><span class="p">,</span> <span class="s2">`&lt;img src="</span><span class="p">${</span><span class="nx">emoji</span><span class="p">.</span><span class="nx">static_url</span><span class="p">}</span><span class="s2">" alt="Emoji </span><span class="p">${</span><span class="nx">emoji</span><span class="p">.</span><span class="nx">shortcode</span><span class="p">}</span><span class="s2">" height="16px" width="16px" /&gt;`</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="nx">userLink</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">display_name</span> <span class="o">+</span> <span class="dl">'</span><span class="s1"> @</span><span class="dl">'</span> <span class="o">+</span> <span class="nx">response</span><span class="p">.</span><span class="nx">account</span><span class="p">.</span><span class="nx">username</span><span class="p">;</span>

    <span class="kd">let</span> <span class="nx">commentDate</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nf">createElement</span><span class="p">(</span><span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">commentDate</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nf">add</span><span class="p">(</span><span class="dl">'</span><span class="s1">comment-date</span><span class="dl">'</span><span class="p">);</span> <span class="nx">commentDate</span><span class="p">.</span><span class="nf">setAttribute</span><span class="p">(</span><span class="dl">'</span><span class="s1">href</span><span class="dl">'</span><span class="p">,</span><span class="nx">response</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span> <span class="nx">commentDate</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">created_at</span><span class="p">.</span><span class="nf">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">10</span><span class="p">);</span>

    <span class="kd">let</span> <span class="nx">commentContents</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nf">createElement</span><span class="p">(</span><span class="dl">'</span><span class="s1">div</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">commentContents</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nf">add</span><span class="p">(</span><span class="dl">'</span><span class="s1">mastodon-comment-content</span><span class="dl">'</span><span class="p">);</span> <span class="nx">commentContents</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">content</span><span class="p">;</span>

    <span class="kd">let</span> <span class="nx">comment</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nf">createElement</span><span class="p">(</span><span class="dl">'</span><span class="s1">div</span><span class="dl">'</span><span class="p">);</span>
    <span class="nx">comment</span><span class="p">.</span><span class="nx">classList</span><span class="p">.</span><span class="nf">add</span><span class="p">(</span> <span class="dl">'</span><span class="s1">comment-content</span><span class="dl">'</span> <span class="p">);</span>

    <span class="nx">user</span><span class="p">.</span><span class="nf">appendChild</span><span class="p">(</span> <span class="nx">comment</span> <span class="p">);</span>
    <span class="nx">comment</span><span class="p">.</span><span class="nf">appendChild</span><span class="p">(</span> <span class="nx">userLink</span> <span class="p">);</span>
    <span class="nx">comment</span><span class="p">.</span><span class="nf">appendChild</span><span class="p">(</span><span class="nx">commentDate</span><span class="p">);</span>
    <span class="nx">comment</span><span class="p">.</span><span class="nf">appendChild</span><span class="p">(</span> <span class="nx">commentContents</span> <span class="p">);</span>
    <span class="k">return</span> <span class="nx">user</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>As you can see, we are creating a bunch of HTML elements that will have content
from the JSON, we assign classes, child elements, and such.</p>

<p>In fact, the only thing I kept from Schwan’s version is the way to call the API
and the basic structure, which I turned into Aristath’s syntax.</p>

<p>I am no expert when it comes to JavaScript, but I think this is pretty readable
overall. At least a bit more than the code I based this from, or maybe I am now
used to this code since I’ve worked on it for a while.</p>

<p>I think this combines the best of the comment systems I have found online, so I
think I will stick to this method for quite a while, since I have been using it
for months, I just never took the time to explain it properly until now.</p>

<p>You can always check my website’s source code to see how all of this is being
applied. And don’t be afraid to leave any question you might have by contacting
me in any way you prefer below.</p>

<p>This has been day 69 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a></p>

<h1 id="mentioned-sources-and-posts">Mentioned sources and posts</h1>

<ul>
  <li><a href="https://aristath.github.io/blog/static-site-comments-using-github-issues-api">A new comment system for my static Jekyll site (Aristath)</a></li>
  <li><a href="https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/">Adding comments to your static blog with Mastodon (Carl Schwan)</a></li>
  <li>Previous posts by me talking about <a href="/blog/adding-comments-blog/">GitHub’s</a> and <a href="/blog/mastodon-comments-and-changes/">Mastodon’s</a> comment systems.</li>
</ul>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="tutorial" /><category term="coding" /><category term="blog" /><category term="fediverse" /><category term="small-web" /><category term="jekyll" /><category term="webdev" /><summary type="html"><![CDATA[I have talked about comments on my blog before, but I think I finally found the final iteration of it, and it's now live!]]></summary></entry><entry><title type="html">Beyond the school assignment</title><link href="https://joelchrono.xyz/blog/beyond-the-school-assignment/" rel="alternate" type="text/html" title="Beyond the school assignment" /><published>2021-09-30T19:55:40-05:00</published><updated>2021-09-30T19:55:40-05:00</updated><id>https://joelchrono.xyz/blog/beyond-the-school-assignment</id><content type="html" xml:base="https://joelchrono.xyz/blog/beyond-the-school-assignment/"><![CDATA[<p>After delivering my school project, the teacher taught us the basics of HTML and PHP. As you might assume, I was already quite familiar with HTML and even a little JavaScript which I’ve used for some parts of my website.</p>

<p>During class, we learned how to detect <code class="language-plaintext highlighter-rouge">POST</code> requests and make a simple input box to set the degrees of a servomotor via the internet!</p>

<p>As far as I know PHP only works on the server side, and it can do quite a lot of stuff, like run other scripts and print its output.</p>

<p>So, I started to modify a script I had to print tables from a database, and I added HTML tags to every print function to make it a table.</p>

<p>After a few failed attempts, missing tags and some coding errors, I managed to make that work. And a nice table was displayed. I also added my website’s stylesheet!</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2021-09-30-database-table.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2021-09-30-database-table.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2021-09-30-database-table.jpg" alt="" />
  </picture>
  </figure>

<p>Next, I wanted to be able to run specific sections of that python script based on which button was pressed, so I can allow cars to enter or exit the parking lot successfully.</p>

<p>For that, the easiest route for me would be using external arguments, that come when you run a command. For example, when you run <code class="language-plaintext highlighter-rouge">cd /path/to/directory/</code> , the argument is the path you wanna go to. In my case, the arguments would be the action I wanna do, and in one of those actions I would also require the input of the user, to know which parking spot they are exiting from.</p>

<p>After messing around with Python, I was now able to recognize user input and update the page according to it thanks to arguments sent by PHP. That section looked like this!</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2021-09-30-database-input.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2021-09-30-database-input.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2021-09-30-database-input.jpg" alt="" />
  </picture>
  </figure>

<p>The cool thing about this is that not only was I displaying all this information on the website, I also did stuff in the real world, my servo opened and closed, and I setup a speaker to output when there were no spots available, or in case you are entering, which spot you were assigned to use.</p>

<p>The PHP itself looked something like this. I placed it in different sections of the HTML, so the output appears where I want it to.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>//If the car wants to enter
if($_POST['entrance'] and $_SERVER['REQUEST_METHOD'] == "POST"){

    $command = escapeshellcmd("sudo ./parking.py 2");
    $output = shell_exec($command);
    echo "$output";
}

// If the car wants to exit
if($_POST['space_num'] and $_SERVER['REQUEST_METHOD'] == "POST"){
    $v = $_POST['space_num'];
    $command2 = escapeshellcmd("sudo ./parking.py 1 $v");
    $output2 = shell_exec($command2);
    echo "$output2";
}

# Runs every time the page loads
$command = escapeshellcmd("sudo ./database_output.py");
$output = shell_exec($command);

echo "$output &lt;br&gt;";
</code></pre></div></div>

<p>As you can tell, it is quite simple to get whats going on. Now you might be wondering whats inside of those python scripts, well, I made one to output the database contents in a table, as I mentioned, and another one is in charge of updating the database, playing output to a speaker and moving the servo to let cars in and out. Check it out if you want <a href="https://tildegit.org/chrono/parking_lot_website.git">in its git repo</a></p>

<p>Let me know what do you think of my coding skills out of this! I think I took into account most of the plausible scenarios, but there might be some bugs still there.</p>

<p>I could explain these scripts but I was already unwilling to show them at all because of the mistakes I could have. Anyways, the point is I got a really cool project working that will probably be what we’ll learn during the following classes, but I am glad I got inspired to do this on my own! so I am happy about it.</p>

<p>This has been day 57 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="school" /><category term="project" /><category term="webdev" /><category term="coding" /><category term="raspberrypi" /><summary type="html"><![CDATA[After my previous school project ended, I decided to work more on it by myself. I learned a bit of PHP and server stuff so here it goes!]]></summary></entry><entry><title type="html">Raspberry school project stuff</title><link href="https://joelchrono.xyz/blog/raspberry-school-project-stuff/" rel="alternate" type="text/html" title="Raspberry school project stuff" /><published>2021-09-28T18:33:13-05:00</published><updated>2021-09-28T18:33:13-05:00</updated><id>https://joelchrono.xyz/blog/raspberry-school-project-stuff</id><content type="html" xml:base="https://joelchrono.xyz/blog/raspberry-school-project-stuff/"><![CDATA[<p>So yeah I don’t really have a lot of time to make an epic post, and its been a while since my last one, but well.</p>

<p>Last week our teacher showed us how to create databases using mariadb and how to manipulate it with Python and the PyMySQL library, so I got working on it and created my own database.</p>

<p>We had to make some sort of parking lot with 15 spaces to be used by vehicles, and all I had to do was keep track of which ones were being used or freed. I did this with a simple database with 15 slots and a state.</p>

<p>I also had to move a servo-motor so it works as the entrance, it goes up and down to let cars in and out. I even made it go smoother by making a for loop and changing the work frequency grade by grade with a timer.</p>

<p>Keeping track of the cars and making sure there are no weird errors was kinda fun. This project allowed me to experiment with Python, using stuff that I don’t really do when using other languages, like <code class="language-plaintext highlighter-rouge">try</code> and exceptions to detect stuff.</p>

<p>For example, when a car exits, I need to know the space it used, and I don’t want the code to fail when the user inputs “18” or “-4”. Although I could just make a few conditional statements, I decided to add an exception to the <code class="language-plaintext highlighter-rouge">IndexError</code> from PyMySQL and take care of stuff that way.</p>

<p>It was quite a nice experience, I also had to help half a dozen of classmates who are still not used to the Raspberry Pi and are unwilling to learn Vim for some weird reason. Anyways, I have had a lot of homework and a new <em>exam</em> coming up pretty soon, which will be quite a nightmare for me, since it looks like this semester I am only good at Embedded Systems…</p>

<p>Anyways, this was post number 56 for <a href="https://100DaysToOffload.com">#100DaysToOffload</a>, I hope you enjoyed this quick post which almost feels like a mastodon thread, but anyways, have a nice day!</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="raspberrypi" /><category term="school" /><category term="project" /><category term="coding" /><summary type="html"><![CDATA[So I finally made something kinda cool for school on my Raspberry Pi and I might do some more school stuff pretty soon too]]></summary></entry><entry><title type="html">Backup your dotfiles using stow</title><link href="https://joelchrono.xyz/blog/backing-up-my-dotfiles/" rel="alternate" type="text/html" title="Backup your dotfiles using stow" /><published>2021-08-31T16:20:03-05:00</published><updated>2021-08-31T16:20:03-05:00</updated><id>https://joelchrono.xyz/blog/backing-up-my-dotfiles</id><content type="html" xml:base="https://joelchrono.xyz/blog/backing-up-my-dotfiles/"><![CDATA[<p>Managing dotfiles has always been quite annoying to me. But thankfully, I never really had a reason to do it too often. When <a href="/blog/switching-distro-ending-school/">I moved from Void Linux to EndeavourOS</a>, all I did was <code class="language-plaintext highlighter-rouge">tar</code> my whole <code class="language-plaintext highlighter-rouge">.config</code> and copied the file to an external drive.</p>

<p>That works fine,  but it’s not the best way to backup the constant changes I usually do to customize the way my programs look or act, and as a customization freak, that happens <em>quite often</em>.</p>

<p>I had seen many different ways to backup dotfiles: git bare repos, <a href="https://yadm.io">yadm</a>, symlinking scripts, and of course, GNU Stow.</p>

<p>All of these methods have their up and downs, but in the end, <code class="language-plaintext highlighter-rouge">stow</code> convinced me, and I decided to give it a try. According to their <a href="https://www.gnu.org/software/stow/">home page</a>:</p>

<blockquote>
  <p>GNU Stow is a symlink farm manager which takes distinct packages of software and/or data located in separate directories on the filesystem, and makes them appear to be installed in the same place.</p>
</blockquote>

<p>If you don’t really understand it yet, don’t worry, <em>I don’t either!</em> But in this blog, I will do my best to show you the steps to backup your current config files, I hope whoever reads this finds it useful.</p>

<h1 id="creating-a-dotfiles-repository">Creating a dotfiles repository</h1>

<p>The first step to backup your dotfiles, is to create an <strong>empty</strong> repository in some hosting service, such as <a href="https://github.com">GitHub</a>, <a href="https://codeberg.org">Codeberg</a> or <a href="https://sourcehut.org">SourceHut</a>. This is optional if you only want to see how <code class="language-plaintext highlighter-rouge">stow</code> works, but necessary to have an external backup outside your computer. Once you are done, clone the empty repo to your home directory, or in any place you want. (This tutorial will be using the home directory).</p>

<p>To clone a repo, just do:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://site.com/link/to/repo
</code></pre></div></div>

<p>In my case, I use <a href="https://tildegit.org">Tildegit</a>, a Gitea instance, so my command looks like this.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://tildegit.org/chrono/dotfiles.git
</code></pre></div></div>

<p>You can clone my dotfiles if you want to use them, <a href="https://tildegit.org/chrono/dotfiles.git">here</a> they are if you are interested.</p>

<h1 id="using-stow-to-backup-your-configuration">Using stow to backup your configuration</h1>

<p>Before actually backing something up, we need to install <code class="language-plaintext highlighter-rouge">stow</code>, depending on your distribution, you can install it with your package manager of choice. In my case, Endeavor is based on Arch, so I do:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span><span class="nb">sudo </span>pacman <span class="nt">-S</span> stow
</code></pre></div></div>

<p>Lets start by backing up the configuration of a single program. While we can backup our whole <code class="language-plaintext highlighter-rouge">.config</code> folder, that’s <strong>not</strong> a good idea, since <strong>some</strong> programs store <strong>important</strong> information that <em>should</em> stay private, and I think its better to only backup what we have actually configured. For this example, I will backup my <code class="language-plaintext highlighter-rouge">picom</code> configurations.</p>

<p>The first step is to create a new directory to use as a base (if you cloned your empty repo, you’ll be using that). You also have to create a folder structure, depending on where you want the configuration to be stored, this depends on the location the program will read its configuration from. We’ll refer to this folder as <code class="language-plaintext highlighter-rouge">dotfiles</code>.</p>

<p>If you want to add a <code class="language-plaintext highlighter-rouge">README</code> file or other stuff that you is not a config files, you can create another directory inside of <code class="language-plaintext highlighter-rouge">dotfiles</code>, in my case, I have made a <code class="language-plaintext highlighter-rouge">stow_home</code> folder, which will be where we’ll run the <code class="language-plaintext highlighter-rouge">stow</code> command. <sup id="fnref:1"><a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref">1</a></sup></p>

<p>Lets explain how <code class="language-plaintext highlighter-rouge">stow</code> works. Picom expects its config file in <code class="language-plaintext highlighter-rouge">~/.config/picom/picom.conf</code>, so, inside of the new <code class="language-plaintext highlighter-rouge">home_stow</code> directory, we recreate that folder structure, but using the program name (<code class="language-plaintext highlighter-rouge">picom</code>) instead of the tilde (<code class="language-plaintext highlighter-rouge">~</code>), which usually refers to the home folder. <sup id="fnref:2"><a href="#fn:2" class="footnote" rel="footnote" role="doc-noteref">2</a></sup></p>

<p>Lets put all of this together in the terminal.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir </span>dotfiles <span class="o">&amp;&amp;</span> <span class="nb">cd </span>dotfiles <span class="c"># mkdir only if you didn't clone it</span>
<span class="nb">touch </span>README.md other_file.txt <span class="c"># optional</span>
<span class="nb">mkdir</span> <span class="nt">-p</span> ~/dotfiles/stow_home/picom/.config/picom/
<span class="nb">mv</span> ~/.config/picom/ ~/dotfiles/stow_home/picom/.config/
</code></pre></div></div>

<p>Once you do that, your picom folder is no longer in the <code class="language-plaintext highlighter-rouge">.config</code> directory, but inside of <code class="language-plaintext highlighter-rouge">dotfiles/home_stow</code>, following <em>the same folder structure</em>, as if <code class="language-plaintext highlighter-rouge">home_stow</code> was the <code class="language-plaintext highlighter-rouge">/home</code> directory, followed by the user <code class="language-plaintext highlighter-rouge">picom</code> and the path to the picom configuration files. <sup id="fnref:4"><a href="#fn:4" class="footnote" rel="footnote" role="doc-noteref">3</a></sup></p>

<p>Now we repeat this process with all of the files and directories we want to back up. Once done, the behavior of the programs you use, such as <code class="language-plaintext highlighter-rouge">vim</code>, should revert to their default configurations, since the user config files are no longer there. So, <strong>now its time to fix that!</strong> Inside of <code class="language-plaintext highlighter-rouge">stow_home</code>, run the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>stow <span class="nt">-vt</span> ~ <span class="k">*</span>
</code></pre></div></div>

<p>This will symlink <strong>everything</strong> inside of <code class="language-plaintext highlighter-rouge">stow_home</code> <sup id="fnref:3"><a href="#fn:3" class="footnote" rel="footnote" role="doc-noteref">4</a></sup>, targetting <code class="language-plaintext highlighter-rouge">~</code> as the starting point. The <code class="language-plaintext highlighter-rouge">-v</code> flag will let you know of everything being done, so you should see an output like this, depending on the programs you backed up:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># $ stow -vt ~ *</span>
LINK: .config/awesome <span class="o">=&gt;</span> ../dotfiles/stow_home/awesome/.config/awesome
LINK: .config/bat <span class="o">=&gt;</span> ../dotfiles/stow_home/bat/.config/bat
LINK: .config/dunst <span class="o">=&gt;</span> ../dotfiles/stow_home/dunst/.config/dunst
LINK: .config/nvim <span class="o">=&gt;</span> ../dotfiles/stow_home/nvim/.config/nvim
LINK: .config/picom <span class="o">=&gt;</span> ../dotfiles/stow_home/picom/.config/picom
LINK: .config/rofi <span class="o">=&gt;</span> ../dotfiles/stow_home/rofi/.config/rofi
LINK: .config/spectrwm <span class="o">=&gt;</span> ../dotfiles/stow_home/spectrwm/.config/spectrwm
</code></pre></div></div>

<h1 id="file-versioning-with-git">File versioning with git</h1>

<p>If you stumbled upon this guide, you probably know the necesary <code class="language-plaintext highlighter-rouge">git</code> commands to backup everything to the service you chose at the beginning of this guide.</p>

<p>Generally, everytime you do changes you only need to follow these three commands, inside of your <code class="language-plaintext highlighter-rouge">dotfiles</code> folder.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git add <span class="k">*</span>
git commit <span class="nt">-m</span> <span class="s2">"Added config files"</span>
git push
</code></pre></div></div>

<p>Remember that the last command will not work if you don’t have an external repository.</p>

<p>The manual of GNU Stow contains a lot more than what I mentioned here, like unlinking and other flags that can be used and might be useful for your use case.</p>

<h1 id="finishing-up">Finishing up</h1>

<p>Anyways, that’s all folks, this has been day 54 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a>, you can check out my dotfiles if you want to see how <code class="language-plaintext highlighter-rouge">stow</code> looks once setup, besides, my <a href="/blog/spectrwm-setup">Spectrwm configuration</a> is quite sick if I do say so myself.</p>

<p>If you feel like a step is not clear enough, please let me know in the comments or via e-mail.</p>

<h2 id="secret-bonus-script">Secret bonus script!</h2>

<p>So, if you read until the end of this blog. I actually did a pretty decent bash script to automate everything here.</p>

<p>All you need to do is configure it to your liking and run it like this</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dotstow file_or_folder
</code></pre></div></div>

<p>The script is as follows, it uses basic tools like <code class="language-plaintext highlighter-rouge">cut</code> and of course, <code class="language-plaintext highlighter-rouge">stow</code></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/bash</span>
<span class="c"># Dotstow - Backup your chosen dotfiles in one go using stow.</span>
<span class="c"># Run it outside of the folder/file you want to back up</span>
<span class="c"># $ dotstow file-or-program</span>
<span class="c"># This program was made by joelchrono12</span>

<span class="nv">STOW_DIR</span><span class="o">=</span><span class="nv">$HOME</span>/dotfiles/stow_home
<span class="nv">DIR</span><span class="o">=</span><span class="si">$(</span><span class="nb">pwd</span> | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s1">'/'</span> <span class="nt">-f4-</span><span class="si">)</span>
<span class="nv">NEW_DIR</span><span class="o">=</span><span class="nv">$STOW_DIR</span>/<span class="nv">$1</span>/<span class="nv">$DIR</span>
<span class="nb">mkdir</span> <span class="nt">-pv</span> <span class="nv">$NEW_DIR</span>
<span class="nb">mv</span> <span class="nt">-v</span> <span class="nv">$1</span> <span class="nv">$NEW_DIR</span>
<span class="nb">cd</span> <span class="nv">$STOW_DIR</span>
stow <span class="nt">-vt</span> ~ <span class="nv">$1</span>
</code></pre></div></div>

<p>The program does not check if a folder already exists or anything like that. So feel free to send any suggestions and changes to it in a comment or using <a href="https://git-send-email.io/">git send-email</a> to my email address.</p>

<hr />

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1">
      <p>You can just use dotfiles as is without a folder inside it, but if you want to be able to quickly deploy everything using <code class="language-plaintext highlighter-rouge">*</code>, you must make a folder where README and other files you don’t want to symlink won’t interfere . <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:2">
      <p>Other files, like <code class="language-plaintext highlighter-rouge">.bashrc</code>, are not in the <code class="language-plaintext highlighter-rouge">.config</code> folder, keep in mind that the path to use depends on where the program needs it to be. In this case, it would have to be placed in <code class="language-plaintext highlighter-rouge">~/dotfiles/stow_home/bash/.bashrc</code>. <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:4">
      <p>You can also move specific files of a configuration folder. For example, <code class="language-plaintext highlighter-rouge">tut</code>, a mastodon client, saves the account data (passwords, etc) inside of another file in its configuration folder. if thats the case. You should move only the files you want, instead of the whole directory. <code class="language-plaintext highlighter-rouge">stow</code> should manage the rest. <a href="#fnref:4" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:3">
      <p>If you are unsure about the paths you created, you can run the <code class="language-plaintext highlighter-rouge">-n</code> flag to <em>simulate</em> the output and see exactly where each symlink <em>would be</em> placed. That way you dont end up symlinking in the wrong place and doing weird stuff to your filesystem. <a href="#fnref:3" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="linux" /><category term="foss" /><category term="vim" /><category term="tutorial" /><category term="dotfiles" /><category term="coding" /><category term="bash" /><summary type="html"><![CDATA[I finally figured out a nice way to backup my config files, and I decided to upload mine once and for all.]]></summary></entry><entry><title type="html">Getting a Raspberry Pi to play with</title><link href="https://joelchrono.xyz/blog/getting-a-raspberry-pi-to-play-with/" rel="alternate" type="text/html" title="Getting a Raspberry Pi to play with" /><published>2021-08-17T15:19:28-05:00</published><updated>2021-08-17T15:19:28-05:00</updated><id>https://joelchrono.xyz/blog/getting-a-raspberry-pi-to-play-with</id><content type="html" xml:base="https://joelchrono.xyz/blog/getting-a-raspberry-pi-to-play-with/"><![CDATA[<p>So, going back to school was not as I expected, I thought I was going to be able to pay attention to the new classes and maybe take some notes, be a good student and everything.</p>

<p>But of course, I had to get a Raspberry Pi, and I just cannot stop being distracted by it. During the first couple of days I decided to try and move my website to it, self host a few things and try some new programs.</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2021-08-07-raspi.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2021-08-07-raspi.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2021-08-07-raspi.jpg" alt="My Raspberry Pi setup" />
  </picture>
  <figcaption class="caption">My Raspberry Pi setup</figcaption></figure>

<p>Sadly, despite my best efforts, I was unable to open the necessary ports to the world, so I wont be able to self host at the moment. Thankfully, it looks like the network in the area we live will be updated to fiber. We will get some new modems and maybe the software and configuration allow me to have it working before this year ends.</p>

<h1 id="setting-up-a-pi-hole">Setting up a pi-hole</h1>

<p>After failing to use my Pi as a web server, I decided to at least use it as an local ad blocker, so everyone at my house can enjoy an ad-free experience. To do this easily, I used a software known as <a href="https://pi-hole.net/">pi-hole</a>.</p>

<p>Setting it up was extremely simple, I only had to run a simple script and then configure my router to use my Raspi as its main DNS. I added a few more host lists, blocked some specific domains, set up dark mode for the web UI, and voilá!</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2021-08-17-pihole.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2021-08-17-pihole.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2021-08-17-pihole.jpg" alt="Pi-hole's web interface" />
  </picture>
  <figcaption class="caption">Pi-hole's web interface</figcaption></figure>

<p>It has worked quite well for me and my family, from time to time an ad will appear, but I just had to add it to the blacklist and say I won’t see it again!</p>

<p>I have to use this device for a a University class, but I will only have to access it via ssh, since we’ll probably do code for it and I already know how to live in VIM and of course, the terminal. I will love to teach my classmates a little bit about how Linux works thanks to this class, the teacher is a bit too strict tho, and does not like interruptions, so I am going to try and behave instead of correcting him everytime he pronounces commands in a weird way…</p>

<p>This has been day 53 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="coding" /><category term="tech" /><category term="linux" /><category term="foss" /><category term="school" /><category term="raspberrypi" /><category term="webdev" /><summary type="html"><![CDATA[Last week, I got back to school, and I also got a Raspberry Pi. Lets say my attention got divided quite a lot]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://joelchrono.xyz/assets/img/blogs/2021-08-07-raspi.jpg" /><media:content medium="image" url="https://joelchrono.xyz/assets/img/blogs/2021-08-07-raspi.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Redesigning my Website’s Stylesheet</title><link href="https://joelchrono.xyz/blog/redesigning-my-website's-stylesheet/" rel="alternate" type="text/html" title="Redesigning my Website’s Stylesheet" /><published>2021-07-07T21:21:01-05:00</published><updated>2021-07-07T21:21:01-05:00</updated><id>https://joelchrono.xyz/blog/redesigning-my-website-stylesheet</id><content type="html" xml:base="https://joelchrono.xyz/blog/redesigning-my-website&apos;s-stylesheet/"><![CDATA[<p>So, after doing some experiments, I have decided to leave Simple.css, the framework I have used since I started this blog, and I started to play around with my own, simpler Cascading stylesheet.</p>

<p>If you have visited my tilde website (or if you are in it right now), you will notice how simple the site looks, and I decided to finally translate that to my main website.</p>

<p>I have enjoyed Simple.css a lot, I really like it, and I did everything in my power to customize my site using it as a base, after all, the tutorial I followed to get started on this site recommended it, since both are made by Kev after all. But as time went by, I started to develop my own ideas, create my own little pieces and I finally decided to scrap it all and just go for something more minimal and decluttered.</p>

<p>I still kept some things, like the navigation var on top, which is fairly similar to the old one, as well as readapted some parts like my projects section or my comments.</p>

<p>I guess I have some more changes to do, but I like it so far and I am pretty happy with it. I have felt quite inspired to do a bunch of changes, buying some vps and a domain that is not one of the free ones, but maybe its just the moment and tomorrow all of this will only be a memory.</p>

<p>Anyways, I saved a screenshot of the old site just to keep it alive somehow, Simple.css is awesome and if you wanna get started on your own site, check it our <a href="https://simplecss.org">here</a>!</p>

<p>This is day 48 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a>, RIP old stylesheet, you will live as a comment in my html website source.</p>

<figure class="img">
  <picture>
    <source srcset="/assets/img/blogs/2021-07-07-website-simplecss.webp" type="image/webp" />
    <source srcset="/assets/img/blogs/2021-07-07-website-simplecss.jpg" type="image/jpeg" />
    <img class="mx-auto" src="/assets/img/blogs/2021-07-07-website-simplecss.jpg" alt="" />
  </picture>
  </figure>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="webdev" /><category term="coding" /><category term="design" /><category term="ramble" /><category term="blog" /><summary type="html"><![CDATA[I decided to leave Simple.css behind and do something even simpler, debloated and still elegant]]></summary></entry><entry><title type="html">Adventures with ssh, git and rofi scripts</title><link href="https://joelchrono.xyz/blog/adventures-ssh-git-rofi-script/" rel="alternate" type="text/html" title="Adventures with ssh, git and rofi scripts" /><published>2021-07-01T07:54:58-05:00</published><updated>2021-07-01T07:54:58-05:00</updated><id>https://joelchrono.xyz/blog/adventures-with-ssh-git-and-rofi-scripts</id><content type="html" xml:base="https://joelchrono.xyz/blog/adventures-ssh-git-rofi-script/"><![CDATA[<p>This day has been kinda tiresome, but also quite successful, I learned a ton of stuff, and I am happy for it.</p>

<p>The terminal is a place that I have enjoyed for months now, and I really like being on it. But there were a lot of things that I didn’t really do on a terminal, simply because I was already used to other ways. Like downloading files, or transferring it from a computer to my phone.</p>

<p>Since I joined a tilde, a public UNIX server that is accessed via ssh, I had to learn a few more things, or do them in different ways.</p>

<h1 id="getting-familiar-with-ssh">Getting familiar with ssh</h1>

<p>I had been using ssh with my website’s git repo for a while now, in fact, I have my local repos all connected to GitHub via ssh, and I had had no problems with it. However, when I created my tilde account, I got access to tildegit.org, and I decided to give it a try!</p>

<p>Tildegit is a Gitea instance, and its pretty good. It allows me to export my GH repos with ease (at least the public ones), and I am considering to make it my primary Git service. But right now, I would like to keep both. But how am I supposed to do so? There is a “This repo is a mirror” checkmark, but I decided to make the sync from my local repo.</p>

<p>I read this <a href="https://gist.github.com/rvl/c3f156e117e22a25f242">gist</a> guide and set up my git to push to both services, I also learned about the ssh config file, from <a href="https://friendo.monster/log/ssh_config.html">this blog</a> by Drew, so I setup my ssh config for something like this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Host cafe
    Hostname tilde.cafe
    User chrono
    Identityfile ~/.ssh/cafe
    PubkeyAuthentication yes

Host tildegit
    Hostname tildegit.org
    Identityfile ~/.ssh/tildegit
    User git
    PubkeyAuthentication yes

Host github
    Hostname github.com
    Identityfile ~/.ssh/id_ed25519
    User git
    PubkeyAuthentication yes
</code></pre></div></div>

<p>So, as far as I knew, everything should have worked, <em>except it didn’t</em>, the Tildegit ssh connection did not work. I could go on and on, but the trick was simple.</p>

<p>Running <code class="language-plaintext highlighter-rouge">ssh -vT git@tildegit.org</code> did not work, that command does some tests to try and login to the server, but its output was</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git@tildegit.org: Permission denied (publickey).
</code></pre></div></div>

<p>Why wasn’t it picking up my tildegit key? I don’t know, but my repo’s git config had this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># repo/.git/config
...
[remote "origin"]
	url = git@github.com:joelchrono12/joelchrono12.ml.git
	fetch = +refs/heads/*:refs/remotes/origin/*
	pushurl = git@tildegit.org:chrono/joelchrono12.ml.git
	pushurl = git@github.com:joelchrono12/joelchrono12.ml.git
...
</code></pre></div></div>

<p>So I tried something. My ~/ssh/config file names the <code class="language-plaintext highlighter-rouge">Host</code> as <code class="language-plaintext highlighter-rouge">tildegit</code> and nothing else. So I decided to run <code class="language-plaintext highlighter-rouge">ssh -vT tildegit</code>, and after <del>typing my passphrase</del> autotyping  my passphrase with <code class="language-plaintext highlighter-rouge">rofi-pass</code>, this was the output.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Hi there, chrono! You've successfully authenticated with the key named tilde.cafe, but Gitea does not provide shell access.
</code></pre></div></div>

<p>And so, after countless useless commits and failed pushes, I got it, I just changed the pushurl to <code class="language-plaintext highlighter-rouge">tildegit:username/repo</code> and it all worked out fine! I did the same for GH.</p>

<h2 id="using-ssh-agent">Using ssh-agent</h2>

<p>Its worth noting that all this time, I knew I could use the <code class="language-plaintext highlighter-rouge">ssh-agent</code>, but I didn’t really feel like it. I don’t think its bad, but for some reason it does not autostart on my system and while it would probably be easy to set it up, I use <code class="language-plaintext highlighter-rouge">pass</code> to store my passwords, and I decided to just use that and autotype it every time.</p>

<h1 id="some-script-fixing">Some script fixing</h1>

<p>Now, in my previous blog I mentioned that I started using <a href="https://gitlab.com/uoou/blop">Blop</a> to produce a simple, more minimal mirror of this website on my tilde <a href="https://chrono.tilde.cafe">here</a>. However, the script uses <code class="language-plaintext highlighter-rouge">sed</code> to change a bunch of stuff, and after reading it, I found a few things I could apply to my current rofi scripts, so I renewed it and made it better, I also removed some blank spaces that were getting added and caused some weird behavior, like having my HTML end with a dash like <code class="language-plaintext highlighter-rouge">this-file-.html</code> and other things.</p>

<p>Now it looks like this!</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#! /bin/bash</span>
<span class="nv">path</span><span class="o">=</span>/home/joelchrono12/git/joelchrono12.ml/_posts/
<span class="nv">title</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 50 <span class="nt">-p</span> <span class="s2">"Title:"</span> <span class="nt">-dmenu</span><span class="si">)</span>
<span class="nv">filen</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nv">$title</span> | <span class="nb">tr</span> <span class="s2">" ,.!"</span> <span class="s2">"-"</span>| <span class="nb">awk</span> <span class="s1">'{print tolower($0)}'</span><span class="si">)</span>
<span class="k">if</span> <span class="o">[</span> <span class="nt">-z</span> <span class="nv">$title</span> <span class="o">]</span><span class="p">;</span> <span class="k">then
	</span><span class="nb">exit
</span><span class="k">fi
</span><span class="nv">today</span><span class="o">=</span><span class="si">$(</span><span class="nb">date</span> +<span class="s2">"%Y-%m-%d"</span><span class="si">)</span>
<span class="nv">filename</span><span class="o">=(</span><span class="nv">$today</span>-<span class="nv">$filen</span><span class="o">)</span>
<span class="nv">description</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 60 <span class="nt">-height</span> 20 <span class="nt">-p</span> <span class="s2">"Description:"</span> <span class="nt">-dmenu</span><span class="si">)</span>
<span class="nv">tags</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 45 <span class="nt">-p</span> <span class="s2">"Tags:"</span> <span class="nt">-dmenu</span><span class="si">)</span>
<span class="nv">num</span><span class="o">=</span>0
<span class="k">while</span> <span class="o">[</span> <span class="nv">$num</span> <span class="o">=</span> 0 <span class="o">]</span><span class="p">;</span> <span class="k">do
	</span><span class="nv">choice</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nt">-e</span> <span class="s2">"Edit file</span><span class="se">\n</span><span class="s2">Edit title</span><span class="se">\n</span><span class="s2">Edit description</span><span class="se">\n</span><span class="s2">Edit tags</span><span class="se">\n</span><span class="s2">Cancel"</span> | rofi <span class="nt">-width</span> 15 <span class="nt">-l</span> 5-p <span class="s2">"Now?:"</span> <span class="nt">-dmenu</span><span class="si">)</span>

	<span class="k">if</span> <span class="o">[[</span> <span class="nv">$choice</span> <span class="o">=</span> <span class="s2">"Edit file"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
  	</span><span class="nb">touch</span> <span class="nv">$path</span>/<span class="nv">$filename</span>.md
  	<span class="nb">echo</span> <span class="nt">-e</span> <span class="s2">"---</span><span class="se">\n</span><span class="s2">title: </span><span class="nv">$title</span><span class="se">\n</span><span class="s2">header: </span><span class="nv">$title</span><span class="se">\n</span><span class="s2">description: </span><span class="nv">$description</span><span class="se">\n</span><span class="s2">tags: </span><span class="nv">$tags</span><span class="se">\n</span><span class="s2">permalink: /blog/</span><span class="nv">$filen</span><span class="s2">/</span><span class="se">\n</span><span class="s2">layout: post</span><span class="se">\n</span><span class="s2">date: </span><span class="nv">$today</span><span class="s2"> </span><span class="si">$(</span><span class="nb">date</span> +<span class="s2">"%T"</span><span class="si">)</span><span class="s2"> -0500</span><span class="se">\n</span><span class="s2">"</span><span class="o">&gt;&gt;</span> <span class="nv">$path</span>/<span class="nv">$filename</span>.md
		<span class="nv">num</span><span class="o">=</span>1
		alacritty <span class="nt">-e</span> nvim <span class="nv">$path</span>/<span class="nv">$filename</span>.md &amp; <span class="nb">disown</span>
        <span class="c">#cp $path/$filename.md ~/Documents</span>
	<span class="k">elif</span> <span class="o">[[</span> <span class="nv">$choice</span> <span class="o">=</span> <span class="s2">"Edit title"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
		</span><span class="nv">title</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 50 <span class="nt">-p</span> <span class="s2">"Title:"</span> <span class="nt">-dmenu</span><span class="si">)</span>
	<span class="k">elif</span> <span class="o">[[</span> <span class="nv">$choice</span> <span class="o">=</span> <span class="s2">"Edit description"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
		</span><span class="nv">description</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 60 <span class="nt">-height</span> 20 <span class="nt">-p</span> <span class="s2">"Description:"</span> <span class="nt">-dmenu</span><span class="si">)</span>
	<span class="k">elif</span> <span class="o">[[</span> <span class="nv">$choice</span> <span class="o">=</span> <span class="s2">"Edit tags"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
		</span><span class="nv">tags</span><span class="o">=</span><span class="si">$(</span>rofi <span class="nt">-l</span> 0 <span class="nt">-width</span> 45 <span class="nt">-p</span> <span class="s2">"Tags:"</span> <span class="nt">-dmenu</span><span class="si">)</span>
	<span class="k">else
		</span><span class="nv">num</span><span class="o">=</span>1
	<span class="k">fi
done</span>
</code></pre></div></div>

<h1 id="the-end">The end</h1>

<p>Remember all of the metadata is adapted to work with Jekyll, but it is easy to edit the script for whatever you need. I am using <code class="language-plaintext highlighter-rouge">sed</code> and <code class="language-plaintext highlighter-rouge">tr</code> to remove commas and dots from the filename, and to add dashes instead of spaces, it will duplicate some dashes sometimes, but that’s fine. In the end I managed to learn a bit more about how computers work and stuff like that.</p>

<p>Also, I am almost done with school, I did a couple more icons for the Arcticons icon pack, and I should be cleaning up my room today, I have visits soon and its quite a mess!</p>

<p>This is day 47 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="coding" /><category term="linux" /><category term="blog" /><category term="tilde" /><category term="git" /><summary type="html"><![CDATA[Playing with SSH and Git and some fixes I added to my rofi post making script]]></summary></entry><entry><title type="html">Scripting mistakes and tilde communities</title><link href="https://joelchrono.xyz/blog/blog-scripting-mistake/" rel="alternate" type="text/html" title="Scripting mistakes and tilde communities" /><published>2021-06-29T17:50:26-05:00</published><updated>2021-06-29T17:50:26-05:00</updated><id>https://joelchrono.xyz/blog/blog-scripting-mistake</id><content type="html" xml:base="https://joelchrono.xyz/blog/blog-scripting-mistake/"><![CDATA[<p>Up until now I have been using Neovim to write my blog posts, and it has been working wonderfully, as far as I could tell. However, something got my attention recently.</p>

<p>I have been playing around with <code class="language-plaintext highlighter-rouge">blop</code>, a static site generator written in bash that uses pandoc, sed and other simple utilities to generate a blog. I have decided to give it a chance in a new site I got because I joined a tilde pubnix.</p>

<p>What even is a pubnix or a tilde you might ask? Well, its kinda like a shared computer where you can log into using SSH. There are a lot of communities like that and you can checkout some of them by visiting the <a href="https://tildeverse.org">Tildeverse website</a></p>

<p>I decided to join to <a href="https://tilde.cafe">tilde.cafe</a>. I got accepted a few days after I made my request, and it has been a great experience so far.</p>

<p>Coming back to the mistake I mentioned before, neovim offers some neat syntax highlighting by default, and I enjoy to have it not only for Markdown but most other programming and markup languages that I use every now and then.</p>

<p>But Markdown was not working somehow, and I did not know why, it was <em>kinda</em> working, but headers were showing up as if they were comments, with a gray coloring since I use the Nord color scheme, which made them harder to read.</p>

<p>But I just thought I had some weird plugin and I never really tried to fix it, since the rest of things worked as intended for the most part.</p>

<p>It was not until I used <code class="language-plaintext highlighter-rouge">blop</code> to with my current posts that I noticed that most of them were not working. There is some simple templating, and only the header and footer showed up without any of the content. I spent a lot of time messing around with the metadata on top of it, which is kinda  different from Jekyll. Like this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>---
author: Me
title: Title
summary: A summary
date: YYYY-MM-DD HH:MM
---
</code></pre></div></div>

<p>But there is something that is not noticeable at all, an extra space at the end of the last dash, which came from my good old rofi script, that has a line like this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>echo -e "# Previous metadata ...  \n--- "&gt;&gt; $path/$filename.md
</code></pre></div></div>

<p>And as you can see, that little space in the end was messing it all up. The <code class="language-plaintext highlighter-rouge">sed</code> command used in the bash script was not finding the last <code class="language-plaintext highlighter-rouge">"---"</code> and it just went through the whole blog. After removing all of those spaces, everything started to work as intended, and now I have a new website, which is a mirror of this one, using my tilde.cafe domain, and you can <a href="https://chrono.tilde.cafe">visit it here</a></p>

<p>This is day 46 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a></p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="foss" /><category term="coding" /><category term="linux" /><category term="tilde" /><summary type="html"><![CDATA[Playing around with a static site generator I found out a mistake that messed up my Markdown experience, and I did not even noticed until now while trying to build a website on tilde.cafe!]]></summary></entry><entry><title type="html">Changing the comment system and customizing this site</title><link href="https://joelchrono.xyz/blog/mastodon-comments-and-changes/" rel="alternate" type="text/html" title="Changing the comment system and customizing this site" /><published>2021-04-08T16:52:44-05:00</published><updated>2021-04-08T16:52:44-05:00</updated><id>https://joelchrono.xyz/blog/mastodon-comments-and-changes</id><content type="html" xml:base="https://joelchrono.xyz/blog/mastodon-comments-and-changes/"><![CDATA[<p>Lately, as you can see, I have been adding many little details to this website, in order to make it my own even more.</p>

<p>Everything started with <a href="http://simplecss.org" title="Simple.css website">Simple.css</a> as a base, you can go to that website to see how it looks by default. The first changes I did were pretty simple. Since I love the <a href="https://nordtheme.com" title="Nord's website">Nord</a> color scheme, I just implemented those colors, then I modified some other values, and some more, then added classes, and id’s, and I ended up with the current design!.</p>

<h1 id="adding-new-details-to-my-site">Adding new details to my site</h1>

<p>I did all of this to keep myself entertained and to challenge myself trying to understand CSS and HTML better, so I could eventually figure out problems by myself (and with the Internet’s guidance) and design the stuff I liked.</p>

<p>I also have played around with the way Jekyll works, I have added tags and some HTML snippets, making use of the <code class="language-plaintext highlighter-rouge">_include</code> folder to avoid cluttering my layouts and that kind of things.</p>

<p>So for a few days I started checking out some blogs and websites to borrow inspiration from, and I ended up with a new footer section, as well as a new showcase area in my front page. And don’t forget the new SVG icons and dividers that look awesome.</p>

<p>Due to the rush in inspiration, I decided to go ahead and change something I have been meaning to do for a while.</p>

<h1 id="revamping-the-comments-section">Revamping the comments section</h1>

<p>While GitHub comments worked nicely, I wasn’t really getting a lot of activity lately. I think that happened because I didn’t set them up. You see, for every new post, I had to create a new issue, and honestly, I didn’t feel like it. So I just stopped having comments. Besides, most of the people who keep track of this blog are aware of Mastodon. Therefore, the path to follow was clear.</p>

<p>Instead of trying to actually learn some JavaScript. I decided to search for some already existing solution. so it didn’t took a lot of time to find <a href="https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/">Carl Schwan’s blog </a>, who already blessed me with a script that did exactly what I needed. I just had to do some changes so it works with Jekyll’s syntax, so I basically changed the <code class="language-plaintext highlighter-rouge">{{ .stuff }}</code> with <code class="language-plaintext highlighter-rouge">{{ page.stuff }}</code>.</p>

<p>I also had to add those new variables to my blog metadata, which was not hard to do, since I just modified my already existing <a href="/blog/rofi-automated-blog">rofi script</a> to setup my blog’s metadata with a few new lines. I still have to setup the id, like on GitHub, but its easier since I already create the Fosstodon post anyways.</p>

<h1 id="conclusion">Conclusion</h1>

<p>In the end, I am very happy with the results, I am quite surprised with how my blogging journey has been. Sometimes I don’t have time to do blogs, and sometimes I have too much time and do everything but blogs. But hey, today I decided to do a blog <strong>and</strong> implement some new features, yay!</p>

<p>This has been day 30 of <a href="https://100daystooffload.com">#100DaystoOffload</a>, thanks for reading! And don’t forget to try out the new comment system, I didn’t really worked too hard for it, but I still had to setup some CSS to make it look good!</p>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="coding" /><category term="linux" /><category term="foss" /><summary type="html"><![CDATA[The past few days I have been inspired into making this site more "personal", I also decided to make my comments work using mastodon]]></summary></entry><entry><title type="html">Doing changes to the blog archive page (and others)</title><link href="https://joelchrono.xyz/blog/changing-blog-sorting/" rel="alternate" type="text/html" title="Doing changes to the blog archive page (and others)" /><published>2021-03-23T21:14:02-06:00</published><updated>2021-03-23T21:14:02-06:00</updated><id>https://joelchrono.xyz/blog/changing-blog-sorting</id><content type="html" xml:base="https://joelchrono.xyz/blog/changing-blog-sorting/"><![CDATA[<p>So, at this point you should not be surprised at a blog that talks about making and optimizing the way this blog is done. I already made some posts talking about the way I made <a href="/blog/rofi-automated-blog">creating blogs easier</a> for me, so now I will talk a bit more, but this time about the blog layout itself.</p>

<p>I have made some changes to the CSS, as well as modifying some pages, such as the <a href="/tags">tags</a> and <a href="/blog">blogs</a> one. Up until the creation of this post, the blog archive has been a relatively small list of all of the blogs I’ve made. However, thinking about the future, I wanted to split all of this into sections, divided by year and month. To do that, a <a href="https://fosstodon.org/@joeligj12/105936877426053202">asked for suggestions</a> on Mastodon. And of course, I got some replies. I ended up on Stack Overflow and found some ways to do what I wanted.</p>

<p>After a check there, I added the following lines to my blog.md file (located on my site’s root directory).</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{% assign postsByYear = site.posts | group_by_exp:"post", "post.date | date: '%Y'" %}
{% for year in postsByYear %}
  <span class="nt">&lt;h1&gt;</span>{{ year.name }}<span class="nt">&lt;/h1&gt;</span>
{% assign postsByMonth = year.items | group_by_exp:"post", "post.date | date: '%B'" %}
{% for month in postsByMonth %}
<span class="nt">&lt;details&gt;&lt;summary&gt;</span>{{ month.name }}<span class="nt">&lt;/summary&gt;</span>
<span class="nt">&lt;ul&gt;</span>
  {% for post in month.items %}
   <span class="nt">&lt;li&gt;</span>
   <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"{{ post.url }}"</span><span class="nt">&gt;</span>{{ post.title }}<span class="nt">&lt;/a&gt;&lt;br&gt;</span>
	 {% for tag in post.tags %}
    <span class="nt">&lt;a</span> <span class="na">class=</span><span class="s">"posttag"</span> <span class="na">href=</span><span class="s">"/tags/{{ tag }}"</span><span class="nt">&gt;</span>{{ tag }}<span class="nt">&lt;/a&gt;</span>  
	 {% endfor %}
		📅 {{ post.date | date: "%Y-%m-%d" }} <span class="nt">&lt;br&gt;</span>{{ post.description }}
    <span class="nt">&lt;/li&gt;</span>
  {% endfor %}
	<span class="nt">&lt;/ul&gt;</span>
	<span class="nt">&lt;/details&gt;</span>
{% endfor %}
{% endfor %}
</code></pre></div></div>

<p>I made use of the nice <code class="language-plaintext highlighter-rouge">&lt;details&gt;</code> HTML element which is quite pretty thanks to <a href="https://simplecss.org">Simple.css</a>, the CSS framework I am using right now. I also used them to the tags page, which has a similar structure to the blog, although is quite simpler.</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{% for tag in site.tags %}
  <span class="nt">&lt;details&gt;</span>
  <span class="nt">&lt;summary&gt;</span>{{ tag[0] }}<span class="nt">&lt;/summary&gt;</span>  
    {% for post in tag[1] limit:3 %}
      <span class="nt">&lt;p&gt;&lt;a</span> <span class="na">href=</span><span class="s">"{{ post.url }}"</span><span class="nt">&gt;</span>{{ post.title }}<span class="nt">&lt;/a&gt;</span> - 📅 {{post.date | date_to_string}} <span class="nt">&lt;/p&gt;</span>
    {% endfor %}
  <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"/tags/{{ tag[0] }}/"</span> <span class="na">class=</span><span class="s">"button"</span><span class="nt">&gt;</span>All posts<span class="nt">&lt;/a&gt;</span> <span class="nt">&lt;a</span> <span class="na">class=</span><span class="s">"button"</span> <span class="na">href=</span><span class="s">"/feeds/{{ tag[0] }}.xml/"</span><span class="nt">&gt;</span>RSS<span class="nt">&lt;/a&gt;</span>
  <span class="nt">&lt;/details&gt;</span>
{% endfor %}
</code></pre></div></div>

<p>Of course all of this might be quite weird and I am not going to pretend that I understand it all! I added tags a while ago and it took me some time to get the grasp of it. Remember that as a Jekyll SSG user it is my duty to let you all know of every little piece of liquid, HTML or ruby code I add to it!.</p>

<p>This was day 27 of <a href="https://100DaysToOffload.com">#100DaysToOffload</a>. Dont you love it when most of your blog consists of copy pasting already existing text and avoiding to explain most of it assuming your audience will understand it? I hope you did because I am done with this. I hope you read next one (and I hope its not as lazy)</p>

<p>If you want you can check more about this here:</p>
<ul>
  <li><a href="https://stackoverflow.com/questions/22044488/jekyll-code-in-jekyll#22045747">How to display raw Jekyll code in a Jekyll site</a></li>
  <li><a href="https://stackoverflow.com/questions/19086284/jekyll-liquid-templating-how-to-group-blog-posts-by-year">How to split posts by year and date</a></li>
</ul>]]></content><author><name>joelchrono</name><email>me@joelchrono.xyz</email></author><category term="foss" /><category term="coding" /><category term="tutorial" /><category term="jekyll" /><category term="webdev" /><summary type="html"><![CDATA[I have a blog made in Jekyll, I HAVE to make a blog every time I made changes to its layout. Added blog list split by year and month, and better tags layout too]]></summary></entry></feed>