new genblog script, remove old gen scripts new blog layout
This commit is contained in:
51
genblog
Executable file
51
genblog
Executable file
@ -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
|
Reference in New Issue
Block a user