71 lines
1.8 KiB
Bash
71 lines
1.8 KiB
Bash
# generate feed.atom for blog
|
|
|
|
articles_uuid=0839a919-90f9-4778-98c1-087f7ae039ad
|
|
|
|
# this isn't really "blog-like", so we don't want a feed that represents
|
|
# creation dates. as such, I think it's better if we track *changes*
|
|
# rather than *new posts*. this allows people to keep up with documentation
|
|
# updates and whatnot
|
|
feed="$_BUILDDIR/articles/feed.atom"
|
|
|
|
{
|
|
|
|
while read -r time hash subject; do
|
|
date=$(date -u -d "@$time" +"%Y-%m-%dT%TZ")
|
|
desc="" files=""
|
|
uuid=$(uuidgen --sha1 -n @url -N "$hash")
|
|
|
|
# print header (only on first one)
|
|
if [ -z "$flag" ]; then
|
|
printf '%s\n' '<?xml version="1.0" encoding="UTF-8" ?>
|
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
<link rel="self" type="application/atom+xml" href="https://unix.dog/~yosh/articles/feed.atom" />
|
|
<link rel="alternate" type="text/html" href="https://unix.dog/~yosh/articles" />
|
|
<title>yosh'\''s articles</title>
|
|
<author><name>yosh</name></author>
|
|
<updated>'"$date"'</updated>
|
|
<id>urn:uuid:'"$articles_uuid"'</id>'
|
|
fi
|
|
|
|
desc=$(git log "$hash" -1 --format='%b')
|
|
files=$(git log "$hash" -1 --format='' --name-status | sed -n '
|
|
/src\/articles\// {
|
|
s,src/articles/,,
|
|
s/^M[[:space:]]*/MODIFIED: /
|
|
s/^A[[:space:]]*/ADDED: /
|
|
s/^D[[:space:]]*/DELETED: /
|
|
s/^R[0-9[:space:]]*/RENAMED: /
|
|
s/\.md$/\.html/
|
|
s/\.md /\.html /
|
|
s/ / --> /
|
|
s/^/<li><p>/
|
|
s/$/<\/p><\/li>/
|
|
p
|
|
}
|
|
')
|
|
[ -z "$files" ] && continue
|
|
|
|
printf '<entry>
|
|
<title>%s</title>
|
|
<link rel="alternate" href="/~yosh/articles" />
|
|
<id>urn:uuid:%s</id>
|
|
<updated>%s</updated>
|
|
<content type="html">%s</content>
|
|
</entry>\n' "$(escape "$subject")" "$uuid" "$date" "$(escapepipe <<-EOF
|
|
<ul>
|
|
${desc:+"<p>$desc</p>$_NL"}$files
|
|
</ul>
|
|
EOF
|
|
)"
|
|
|
|
|
|
flag=1
|
|
done <<-EOF
|
|
$(find . -type f ! \( -iname '*.sh' \) \
|
|
-exec git log --date=unix --format='%at %H %s' -10 -- {} +)
|
|
EOF
|
|
|
|
echo "</feed>"
|
|
|
|
} > "$feed"
|