blob: 12bb7fe1a07a0ab4bd47baf74239b8d46aabc6a6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
|