diff options
author | Squibid <me@zacharyscheiman.com> | 2023-07-15 04:41:40 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2023-07-15 04:41:40 -0400 |
commit | 81e150fbd84e0bff8a5d4b80f93a128cabeb4433 (patch) | |
tree | 6931c2c515632488cc83990bdd0a6234cbf197d6 /gen | |
parent | 224a8f75949ecfeec9ef6dc4cd822abb9a6ffed6 (diff) | |
download | site-81e150fbd84e0bff8a5d4b80f93a128cabeb4433.tar.gz site-81e150fbd84e0bff8a5d4b80f93a128cabeb4433.tar.bz2 site-81e150fbd84e0bff8a5d4b80f93a128cabeb4433.zip |
new genblog script, remove old gen scripts new blog layout
Diffstat (limited to '')
-rwxr-xr-x | gen | 4 | ||||
-rwxr-xr-x | genblog | 51 |
2 files changed, 51 insertions, 4 deletions
@@ -1,4 +0,0 @@ -#!/bin/sh - -./scripts/gengit -./scripts/genblog @@ -0,0 +1,51 @@ +#!/bin/sh +# +# genblog is a script to take data from my blogs and format it into html for +# my website +# +# by: Squibid +# + +# +# Helper variables and functions +# +bloglist=$(ls -t1 blog/*.html | grep -oP '(?<=\/).*?(?=\.)') +top5=$(printf "$bloglist\n" | head -5) + +blogdate() { + grep -oP '(?<=\<meta name="date" content=").*(?="\>)' "blog/$1.html" +} +blogtitle() { grep -oP '(?<=\<title\>).*(?=\<\/title\>)' "blog/$1.html"; } +htmlline() { + printf "<a href=\"/blog/$1\">\ $(blogtitle $1)</a>\ +<span>$(blogdate $1)</span><br>\n" +} + +# set file dates properly +for i in $bloglist; do + if $(touch -cd "$(blogdate $i)T00:00:00" /tmp/file); then + touch -amt "$(blogdate $i | sed 's/\///g')0000" "blog/$i.html" + fi +done + +# +# Start modifing our files +# + +# delete old bloglist +sed -i -n '1,/.*<!-- b script marker blog -->/p;/.*<!-- e script marker blog -->/,$p' index.html +sed -i -n '1,/.*<!-- b script marker blog -->/p;/.*<!-- e script marker blog -->/,$p' blog.html + +# top 5 blogs +for i in $top5; do + line=$(htmlline $i) + # add new bloglist + sed -i "/.*<!-- e script marker blog -->/i $line" index.html +done + +# generate the full blog list +for i in $bloglist; do + line=$(htmlline $i) + # add new bloglist + sed -i "/.*<!-- e script marker blog -->/i $line" blog.html +done |