💾 Archived View for rtr.kalayaan.xyz › blog › 006.gmi captured on 2021-12-17 at 13:26:06. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

../blog.gmi

A new workflow.

2020-05-16

So, hi.

It's been a while since I updated this blog; partly due to being "busy" but also partly due to having an inefficient means of updating the static site generator that is being used to update this blog. Well, now that the world is stricken with this pandemic. I decided to just tackle this issue so that I would be able to conveniently create blog posts from the comfort of my terminal.

Since this site is just an offshoot of the saait site generator, the only real issue that I've got when trying to streamline things is the automatic creation of both the .cfg and the .html file which are required when generating the website. This is done, quite haphazardly, in three steps. First, the user is prompted whether to create a new post or not and then once confirmed the script then tallies the current number of file in the /pages directory where the .cfg and .html files are kept and subsequently where they are ought to be generated. The tally itself is done using

ls --hide=*.html | wc -l

to give the current number of .cfg files in the said directory. This value is then used to create the current number that is to be used for the files that are about to be generated. At first, this might sound a little farcical but this approach works because I did a little bit of a "cheat" by keeping a template file in the same directory so that ls | wc will always report a value one higher than the current blog count.

Once the value's generated, the only thing left to do is to copy the template file as a new .cfg file named using the value generated from ls | wc as well as to touch a new .html file named the same way. Finally, to make things just a tad bit easier. I also appended a vim command to easily edit those two generated files after the prior commands resolve.

Here's the script in its unadulterated glory:

#!/bin/sh

directory=/directory/goes/here/

prompt=$(printf "No\nYes" | dmenu -i -c -p "Create new blog post?")
cnt=$(ls $directory --hide=*.html | wc -l)

count(){
	ls $directory --hide=*.html | wc -l
}


if [ -z "$prompt" ] || [ $prompt = "No" ]
then
	exit
else
	count
	cp $directory/template $directory/00$cnt.cfg
	touch $directory/00$cnt.html
	vim $directory/00$cnt.cfg; vim $directory/00$cnt.html
fi

As this is just a small, 40-minute script that I wrote, it just kind-of does the job. But as with all things, any suggestions to improve this thing would be appreciated. :)