54 lines
1.3 KiB
Bash
Executable File
54 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -x
|
|
|
|
for f in ./blah/*.html
|
|
do
|
|
awk '
|
|
BEGIN { n = 0; }
|
|
/^\$!NAVIGATION$/ {
|
|
if(++n == 1){
|
|
print $0 "\n\n" substr(FILENAME, 8, 10) "\n"
|
|
}else
|
|
print "\n" $0;
|
|
}
|
|
!/^\$!NAVIGATION$/ { print $0 }
|
|
' "$f" >"$f.tmp" \
|
|
&& mv "$f.tmp" "$f" \
|
|
|| rm "$f.tmp"
|
|
f="$(printf '%s\n' "$f" | sed -e 's,./blah/,,' -e 's,\.html$,,')"
|
|
test -n "$last" \
|
|
&& sed -i "./blah/$last.html" \
|
|
-e "s,\$!NAVIGATION,$nav<A HREF=\"$f.html\">\></A>,g" \
|
|
&& nav="<A HREF=\"$last.html\">\<</A>" \
|
|
|| true
|
|
nav="$nav<A HREF=\"index.html\">^</A>"
|
|
last="$f"
|
|
done
|
|
sed -i "s,\$!NAVIGATION,$nav,g" "./blah/$last.html"
|
|
|
|
ls ./blah/*.html \
|
|
| sed -e 's_.*/__g' \
|
|
-e 's/\.html$//g' \
|
|
| sort -r \
|
|
| tee ./feed.xml \
|
|
| sed -e 's_.*_<A HREF="/blah/&.html">&</A>_g' \
|
|
-e "1i\
|
|
<!DOCTYPE html><HEAD><TITLE>blah</TITLE></HEAD>\
|
|
<BODY><PRE><A HREF=\"..\">..</A>" \
|
|
-e '$a</PRE></BODY></HTML>' \
|
|
>./blah/index.html
|
|
|
|
|
|
sed -i feed.xml \
|
|
-e "1i\
|
|
<?xml version=\"1.0\" encoding=\"utf-8\"?><rss version=\"2.0\">\
|
|
<channel><title>trinity.moe/blah</title><link>https://trinity.moe/blah</link>\
|
|
<lastBuildDate>$(date)</lastBuildDate>" \
|
|
-e "s,^....-..-..\$,<item>\
|
|
<title>&</title>\
|
|
<link>https://trinity.moe/blah/&.html</link>\
|
|
<description>blah post for &</description>\
|
|
<pubdate>&</pubdate></item>," \
|
|
-e '$a</channel></rss>'
|