This isn't live on the old blog system's Github, but partially inspired by by Based Cooking's tag system which is based on blogit, I've added in the feature to tag articles.
I've been wanting to write more articles and informational pages on my website, but doing that with no organization is somewhat impratical. I now have a tagcloud on my homepage.
My issue with blogit, the tool
used for Based.Cooking is that it is slow, mainly due to the fact that
for every file, it has multiple system/program calls (grep
, sed
,
etc. might be called for each article or tag).
Here's an example of what I do, just for info. Instead of looking
through each file and calling grep
and friends each time to get file
information, the title, the tags, etc., I merely run awk
and sed
once to get all the info from all files:
# Awk prints out the filename, title and keywords/tag lines and Sed rearranges them for parsibility
output="$(awk 2>/dev/null '
/<title>/ {printf "
" FILENAME $0};
/keywords/ {printf $0}' "$webdir/$artdir"/*html |
sed "s/\s*<meta.*keywords.*content=[\"']/|/
s/\s*<title>\s*/;/
s/\(\s\+\|[\"']>$\)/ /g
s/^\s*//
s/,//g
s/\( *&ndash.*\)*<\/title>//" | grep "|")"
Then, instead of recursing and reading every file and manually running
the same grep
or sed
commands each time, just recurse through the
output of that previous command stored in $output
.
Actually, I realize in the title of this post, I lied! It actually isn't POSIX shell, but bash, but for a very good reason. Bash has a built-in that capitalizes strings:
$ name=luke
$ echo "${name^}"
Luke
POSIX shell lacks such a feature and would have to call an external
program like sed
or tr
to capitalize strings, which I would need
when later in the script recursing through tag names. This actually is a
good case of when bash is faster to use, since it has the feature built
into it, without needing to call external programs.
Of course I'm sure someone will email me saying that there is some (albeit perhaps less elegant) way of capitalizing the first character of a string in POSIX sh...
I might make my new blog system Makefile-based like blogit to get the perks of that, but I've always found Makefile syntax in a kind of disturbing and confusing uncanny valley. I know that's a silly thing to say.
YouTube Channel Deletion
Stay frosty: possible test stream on PeerTube and YouTube in a bit