Compare commits

...

25 Commits

Author SHA1 Message Date
Lucy 1c9652e1a9 deal with the footer and metadata 2020-07-21 18:46:35 +02:00
Lucy 440e4fa753 add default metadata file to pandoc and add custom template 2020-07-21 14:35:51 +02:00
Kosaki 3e7021845c change comments for rss feed and switch rsync to quitet output 2020-07-18 23:31:23 +02:00
Kosaki ab3b9a2f19 remove generation of markdown list for blog posts as it's not used anymore 2020-07-18 23:25:45 +02:00
Kosaki afe2299557 generate a pure html table instead because it gives more fine-tuning options 2020-07-18 23:17:47 +02:00
Lucy a172ac644f display date the american way because that makes more sense for the blog-index 2020-07-18 23:01:14 +02:00
Kosaki ce337cf373 simplify handling of date for rss feed and add custom date format for blog-index 2020-07-18 22:43:25 +02:00
Lucy af773b4de2 make rss feed a valid atom feed 2020-07-18 01:13:13 +02:00
Lucy f504cd34ff forgot to uncomment that again 2020-07-17 14:34:06 +02:00
Lux49 2b5195fb94 customize rss feed 2020-07-17 14:33:06 +02:00
Lux49 5e711b5f6b customize rss feed 2020-07-17 14:30:39 +02:00
Lux49 262e8d5aaf change rss feed 2020-07-17 14:29:37 +02:00
Lucy e0ed767c63 get the title from the html document instead because that's saver 2020-07-17 00:38:30 +02:00
Lucy cddfffbbe8 display footer on every static page aswell 2020-07-15 22:59:29 +02:00
Lucy 810c51faa3 just list the posts alphabetical in reverse order because they are ordered the right way by their filename anyways. 2020-07-15 21:50:30 +02:00
Lucy 30eff46640 alter the script so that the finished build get's built into the dist/ directory 2020-07-15 21:20:25 +02:00
Lucy 19007947b8 change the directory structure and add generate_static 2020-07-13 01:02:01 +02:00
Lucy ddf569e46f add proper index generation with pandoc and multiple markdown files 2020-07-12 20:09:10 +02:00
Lux49 3d3f5ee506 change the posts to be in the document root 2020-07-12 02:49:52 +02:00
Lux49 b1ab90fdb0 edit the pandoc command 2020-07-12 02:42:46 +02:00
Lux49 a2438208b0 forgot to remove something 2020-07-12 02:40:30 +02:00
Lux49 7d780a551e change path of the blog content 2020-07-11 13:56:01 +02:00
Lux49 ef7d80a19c remove the check for updates because I won't be testing this inside a git repo 2020-07-11 13:33:11 +02:00
Lux49 dd968c0f42 Change title and author in RSS feed 2020-07-11 00:45:58 +02:00
Lux49 4aae6cd240 Aquire title and date from the metadata block of every post instead 2020-07-11 00:28:31 +02:00

View File

@ -1,65 +1,95 @@
#!/bin/sh #!/bin/sh
blog_domain='https://blog.kageru.moe/' blog_domain='https://lucy.moe/'
output() { output() {
echo "$1" >> index.html echo "$1" >> dist/posts-table.html
} }
output_rss() { output_rss() {
echo "$1" >> rss.xml echo "$1" >> dist/rss.xml
} }
add_header() { add_header() {
output '<h1>Blog index</h1><table id="linklist">' output '<table>
<colgroup>
<col style="width: 70%" />
<col style="width: 30%" />
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left">title</th>
<th style="text-align: right">date</th>
</tr>
</thead>
<tbody>'
output_rss '<?xml version="1.0" encoding="UTF-8" ?> output_rss '<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<author><name>kageru</name></author> <author><name>Lucy</name></author>
<title>kageru’s blog</title>' <title type="text">Lucys blog</title>'
output_rss " <link href=\"$blog_domain\" rel=\"self\" type=\"application/atom+xml\"/> output_rss " <updated>$(date --iso-8601=seconds)</updated>
<description>kageru’s blog</description>" <id>https://lucy.moe/rss.xml</id>
<link href=\"https://lucy.moe/rss.xml\" rel=\"self\" type=\"application/atom+xml\"/>"
} }
add_footer() { add_footer() {
html_entry "legacy" "before 2020" "Older posts" html_entry "https://asagi.moe" "before July 2020" "Old site"
output '</table>' output '</tbody>
</table>'
output_rss '</feed>' output_rss '</feed>'
} }
html_entry() { html_entry() {
output '<tr>' output '<tr>'
path="$1" webpath="$1"
time="$2" time="$2"
title="$3" title="$3"
output "<td class=\"first\"><a href=\"$path\">$title</a></td>" output "<td><a href=\"$webpath\">$title</a></td>"
output "<td class=\"second\">$time</td></tr>" output "<td style=\"text-align: right\">$time</td></tr>"
} }
rss_entry() { rss_entry() {
# The content is the output minus the first line # this is made to represent what heise.de has done with
# (which would otherwise be a redundant title in most rss readers) # their rss/atom feeds and doesn't need any escaping
# and with escaped html.
# The sed expression is stolen from https://stackoverflow.com/questions/12873682/12873723#12873723
output_rss " <entry> output_rss " <entry>
<title>$1</title> <title type=\"text\">$1</title>
<link>$blog_domain$2</link> <published>$(date --iso-8601=seconds -d $4)</published>
<updated>$(date --iso-8601=seconds -r $3)</updated>
<id>$blog_domain$2</id>
<link href=\"$blog_domain$2\" type=\"text/html\" title=\"$1\"/> <link href=\"$blog_domain$2\" type=\"text/html\" title=\"$1\"/>
<content type=\"html\" xml:base=\"$blog_domain$2\"> <summary type=\"html\">
$(tail -n+2 "$2" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g') $(grep -h '^<p>' "dist/$2" | head -n 1 | sed 's/<p>//;s/<\/p>//;/<!--/d;s/^/ /')
</summary>
<content type=\"html\" xml:base=\"$blog_domain$2\"><![CDATA[
$(pandoc $3 | sed '/<!--/d;s/^/ /')]]>
</content> </content>
</entry>" </entry>"
} }
create_entry() { create_entry() {
path="$9" path="$9"
outpath="content/$(basename "$path" .md).html" outpath="$(basename "$path" .md).html"
created=$(grep -h '^date: ' "$path" | sed 's/date: //g')
created_date=$(date +'%b %d, %Y' --date="$created")
published_date=$(date --iso-8601=seconds --date="$created")
# convert new markdown posts to html # convert new markdown posts to html
pandoc "$path" -t html -f markdown -o "$outpath" pandoc -s --css=/css/sakura-vader.css --template=./pandoc-template-v2.2.1.html5 \
-V og-url="https://$outpath" -V published-date="$published_date" \
-V include-footer="$footer" \
src/meta/default.yaml "$path" -t html5 -f markdown -o "dist/$outpath"
# then add it to the index # then add it to the index
title="$(rg 'h1' "$outpath" | head -n1 | rg -o '(?<=>).*(?=<)' --pcre2)" title=$(grep -h '<title>' "dist/$outpath" | sed 's/<title>//g;s/<\/title>//g')
created=$(git log --follow --format=%as "$path" | tail -1) html_entry "$outpath" "$created_date" "$title"
html_entry "$outpath" "created on $created" "$title" rss_entry "$title" "$outpath" $path $created
rss_entry "$title" "$outpath" }
convert_static() {
path="$9"
outpath="$(basename "$path" .md).html"
pandoc -s --css=/css/sakura-vader.css --template=./pandoc-template-v2.2.1.html5 "$path" \
-V include-footer="$footer" \
-t html5 -f markdown -o "dist/$outpath"
} }
has_updates() { has_updates() {
@ -72,15 +102,15 @@ has_updates() {
fi fi
} }
cd /home/nginx/html/blog footer="$(cat src/footer/footer.html)"
if has_updates; then cd /home/lucy/blog-content/
git pull &> /dev/null rm -R dist/*
rm -f index.html rsync -q --delete -avxt static/ dist/
rm -f rss.xml add_header
add_header ls -lr src/posts/*.md | tail -n+1 | while read f; do create_entry $f; done
ls -ltu src/*.md | tail -n+1 | while read f; do create_entry $f; done ls -l src/*.md | tail -n+1 | while read f; do convert_static $f; done
add_footer add_footer
# Human-readable output for the cron notification pandoc -s --css=/css/sakura-vader.css \
echo 'Updated blog to:' -V include-after="$footer" \
git log -1 src/index/index_header.md dist/posts-table.html src/index/after-entry-list.md \
fi -t html5 -f markdown -o dist/index.html