paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4b2b5536950d626665f1215bcc1fb87832d4d202
parent 92a2aab8208fcaffaa0038b0e9f9a88d81d40526
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Fri, 22 May 2020 22:55:57 -0400

Publish new blog post

Diffstat:
Mpages/blog.md | 1+
Apages/blog/rewriting-my-static-site-generator.md | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpages/home.md | 5+++--
Mpublic/feeds/sitewide-feed.xml | 18++++++++++++++++++
Mpublic/sitemap.xml | 1+
5 files changed, 92 insertions(+), 2 deletions(-)

diff --git a/pages/blog.md b/pages/blog.md @@ -20,6 +20,7 @@ href="https://social.paritybit.ca/@jbauer">Mastodon</a>. ### 2020 <ul> + <li>2020-05-22 <a href="blog/rewriting-my-static-site-generator">Rewriting My Static Site Generator</a></li> <li>2020-05-19 <a href="blog/self-hosted-mail-now-live">Self-Hosted Email is Now Live!</a></li> <li>2020-05-19 <a href="blog/attempting-to-replace-my-thinkpads-touchpad">Attempting to Replace My Thinkpad's Touchpad</a></li> <li>2020-05-18 <a href="blog/trying-out-aerc">Trying Out aerc</a></li> diff --git a/pages/blog/rewriting-my-static-site-generator.md b/pages/blog/rewriting-my-static-site-generator.md @@ -0,0 +1,69 @@ +## Rewriting My Static Site Generator + +[//]: # "After a brief hiatus, I'm back with a rewrite of my static site generator script." + +[//]: # "main.min.css" + +[//]: # + +<div class="byline"> +<b>Written By:</b> Jake Bauer | + <b>Posted:</b> 2020-05-22 | + <b>Last Updated:</b> 2020-05-22 +</div> + +After a brief, two day hiatus in posting to refill my creative juices, I'm back +with a rewrite of the script I use to generate my website. This has been a long +time coming (for me, anyways) as my old script had become too messy to work with +and I wanted to switch to using pandoc to compile my webpages. Back when I +originally wrote the script, I was still fairly new to shell scripting and the +quality of the code reflects that. This new script is much easier to read, much +better laid out, and is far easier to extend and adapt in the future. It's also +now possible to use this script for sites other than my own, as long as those +sites have their markdown files structured the same way. + +Previously, I was using `markdown` as the program to take my `.md` files and +transform them into `.html` files. Unfortunately, it had a couple of issues: It +wouldn't interpret triple-backticks as code blocks so I had to use `<pre><code>` +anywhere I wanted a code block, and it would add empty `<p>` tags before and +after `<img>` and `<figure>` tags. Additionally, using `pandoc` also enables me +to add simple syntax highlighting for code blocks since it does syntax +highlighting as part of the transformation process. + +I also took the time to make sure that the syntax highlighting colour scheme I'm +using has an appropriate set of contrast ratios. I targeted a minimum ratio of +4.5:1 and I ended up basing the colour scheme off of the +[iceberg](https://cocopon.github.io/iceberg.vim/) colour scheme which I also use +in Vim. + +One other thing that I wanted to do with this rewrite was to make my script +POSIX-compliant so it is as portable as possible. My script used to require bash +but now it should work with any POSIX-compliant shell. It should also now only +be using POSIX-compliant flags in POSIX programs. + +This new script clocks in at 7207 bytes, 235 total lines, and 180 source lines +of code as of the time of writing. This is in comparison to the old script's +10812 bytes, 253 total lines, and 152 source lines of code. This is mostly due +to the fact that the new script is easier to read and therefore doesn't require +as many comments. Also, adding syntax highlighting only increased the size of +my main CSS file by ~1kB. + +I am considering releasing this script, along with documentation, examples, and +my publish script (which also needs to be made POSIX-compliant), as a separate +project which could be used by anyone looking for a simple static site +generator. Before I do that, however, I would like to work on scripts to +transform the HTML files output by the compilation script into Gemini- and +Gopher-compatible syntax. I am thinking of writing perl scripts to accomplish +this since parsing HTML is quite complicated and perl has a good set of +libraries to accomplish that. + +You can view the new script [on +SourceHut](https://git.sr.ht/~jbauer/paritybit.ca/tree/master/compile) +([mirror](https://git.paritybit.ca/jbauer/paritybit.ca/src/branch/master/compile)). +If you really want to see the horrors of the old script, you'll find it lurking +in the commit history. + +_This is my twenty-sixth post for the +[#100DaysToOffload](https://social.paritybit.ca/tags/100DaysToOffload) +challenge. You can learn more about this challenge over at +[https://100daystooffload.com](https://100daystooffload.com)._ diff --git a/pages/home.md b/pages/home.md @@ -20,6 +20,9 @@ extent)! Access through `gopher://paritybit.ca` or `gemini://paritybit.ca`. src="/img/feed-icon.png" width="15" height="15" alt="Click for RSS Feed"/> </a> </div> + +2020-05-22 <a class="feed-item" href="blog/rewriting-my-static-site-generator">Rewriting My Static Site Generator</a> + 2020-05-19 <a class="feed-item" href="blog/self-hosted-mail-now-live">Self-Hosted Email is Now Live!</a> 2020-05-19 <a class="feed-item" href="blog/attempting-to-replace-my-thinkpads-touchpad">Attempting to Replace My Thinkpad's Touchpad</a> @@ -38,8 +41,6 @@ extent)! Access through `gopher://paritybit.ca` or `gemini://paritybit.ca`. 2020-05-11 <a class="feed-item" href="blog/a-brief-review-of-fedora-32">A Brief Review of Fedora 32</a> -2020-05-10 <a class="feed-item" href="blog/why-i-love-the-fediverse">Why I Love the Fediverse</a> - ### What is a Parity Bit? It is a bit (in the 1's and 0's sense) used in checking for errors in digital diff --git a/public/feeds/sitewide-feed.xml b/public/feeds/sitewide-feed.xml @@ -7,6 +7,24 @@ <description>The feed that covers all notable additions, updates, announcements, and other changes for the entire paritybit.ca website.</description> <item> + <title>Rewriting My Static Site Generator</title> + <link>https://www.paritybit.ca/blog/rewriting-my-static-site-generator</link> + <guid>https://www.paritybit.ca/blog/rewriting-my-static-site-generator</guid> + <pubDate>Fri, 22 May 2020 22:25:13 -0400</pubDate> +<description><![CDATA[<h2 id="rewriting-my-static-site-generator">Rewriting My Static Site Generator</h2> +<div class="byline"> +<p><b>Written By:</b> Jake Bauer | <b>Posted:</b> 2020-05-22 | <b>Last Updated:</b> 2020-05-22</p> +</div> +<p>After a brief, two day hiatus in posting to refill my creative juices, I’m back with a rewrite of the script I use to generate my website. This has been a long time coming (for me, anyways) as my old script had become too messy to work with and I wanted to switch to using pandoc to compile my webpages. Back when I originally wrote the script, I was still fairly new to shell scripting and the quality of the code reflects that. This new script is much easier to read, much better laid out, and is far easier to extend and adapt in the future. It’s also now possible to use this script for sites other than my own, as long as those sites have their markdown files structured the same way.</p> +<p>Previously, I was using <code>markdown</code> as the program to take my <code>.md</code> files and transform them into <code>.html</code> files. Unfortunately, it had a couple of issues: It wouldn’t interpret triple-backticks as code blocks so I had to use <code>&lt;pre&gt;&lt;code&gt;</code> anywhere I wanted a code block, and it would add empty <code>&lt;p&gt;</code> tags before and after <code>&lt;img&gt;</code> and <code>&lt;figure&gt;</code> tags. Additionally, using <code>pandoc</code> also enables me to add simple syntax highlighting for code blocks since it does syntax highlighting as part of the transformation process.</p> +<p>I also took the time to make sure that the syntax highlighting colour scheme I’m using has an appropriate set of contrast ratios. I targeted a minimum ratio of 4.5:1 and I ended up basing the colour scheme off of the <a href="https://cocopon.github.io/iceberg.vim/">iceberg</a> colour scheme which I also use in Vim.</p> +<p>One other thing that I wanted to do with this rewrite was to make my script POSIX-compliant so it is as portable as possible. My script used to require bash but now it should work with any POSIX-compliant shell. It should also now only be using POSIX-compliant flags in POSIX programs.</p> +<p>This new script clocks in at 7207 bytes, 235 total lines, and 180 source lines of code as of the time of writing. This is in comparison to the old script’s 10812 bytes, 253 total lines, and 152 source lines of code. This is mostly due to the fact that the new script is easier to read and therefore doesn’t require as many comments. Also, adding syntax highlighting only increased the size of my main CSS file by ~1kB.</p> +<p>I am considering releasing this script, along with documentation, examples, and my publish script (which also needs to be made POSIX-compliant), as a separate project which could be used by anyone looking for a simple static site generator. Before I do that, however, I would like to work on scripts to transform the HTML files output by the compilation script into Gemini- and Gopher-compatible syntax. I am thinking of writing perl scripts to accomplish this since parsing HTML is quite complicated and perl has a good set of libraries to accomplish that.</p> +<p>You can view the new script <a href="https://git.sr.ht/~jbauer/paritybit.ca/tree/master/compile">on SourceHut</a> (<a href="https://git.paritybit.ca/jbauer/paritybit.ca/src/branch/master/compile">mirror</a>). If you really want to see the horrors of the old script, you’ll find it lurking in the commit history.</p> +<p><em>This is my twenty-sixth post for the <a href="https://social.paritybit.ca/tags/100DaysToOffload">#100DaysToOffload</a> challenge. You can learn more about this challenge over at <a href="https://100daystooffload.com" class="uri">https://100daystooffload.com</a>.</em></p>]]></description> +</item> +<item> <title>Self-Hosted Email is Now Live!</title> <link>https://www.paritybit.ca/blog/self-hosted-mail-now-live</link> <guid>https://www.paritybit.ca/blog/self-hosted-mail-now-live</guid> diff --git a/public/sitemap.xml b/public/sitemap.xml @@ -3,6 +3,7 @@ <url><loc>https://www.paritybit.ca</loc></url> <url><loc>https://www.paritybit.ca/home</loc></url> <url><loc>https://www.paritybit.ca/blog</loc></url> + <url><loc>https://www.paritybit.ca/blog/rewriting-my-static-site-generator</loc></url> <url><loc>https://www.paritybit.ca/blog/self-hosted-mail-now-live</loc></url> <url><loc>https://www.paritybit.ca/blog/attempting-to-replace-my-thinkpads-touchpad</loc></url> <url><loc>https://www.paritybit.ca/blog/trying-out-aerc</loc></url>