From a45165d6d3d49ada0c326a2aaf6eee875e836ff5 Mon Sep 17 00:00:00 2001 From: Solene Rapenne Date: Wed, 29 Sep 2021 18:44:26 +0200 Subject: [PATCH] Fixing atom generation and metadata --- issues/Makefile | 2 +- issues/atom.sh | 52 +++++++++++++++++++++++--------------------- issues/make_issue.sh | 4 +++- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/issues/Makefile b/issues/Makefile index ea5ffc1..f84a8c3 100644 --- a/issues/Makefile +++ b/issues/Makefile @@ -3,7 +3,7 @@ generate-site: ./make_issue.sh _index ../public/index.html ./sitemap.sh webzine.puffy.cafe ../public/ > ../public/sitemap.xml gzip -9 -c ../public/sitemap.xml > ../public/sitemap.gz - ./atom.sh webzine.puffy.cafe ../public/ > ../public/atom.xml + ./atom.sh webzine.puffy.cafe > ../public/atom.xml all: generate-site diff --git a/issues/atom.sh b/issues/atom.sh index a2d372f..94b2bce 100755 --- a/issues/atom.sh +++ b/issues/atom.sh @@ -1,43 +1,45 @@ #!/bin/sh set -e domain="$1" -cd "$2" -feed_updated=$(date +%Y-%m-%dT%TZ) +# exit if no public issue found +ls ../public/issue-*.html >/dev/null 2>&1 + +date_updated=$(date +%Y-%m-%dT%TZ) cat < - -https://${domain}/log/ -OpenBSD Webzine -https://${domain}/favicon.png - - -OpenBSD Webzine contributors -${feed_updated} + + https://${domain}/log/ + OpenBSD Webzine + https://${domain}/favicon.png + + + + OpenBSD Webzine contributors + + ${date_updated} EOF -for page in *.html; do - updated="$(date -ur $(stat -f %m ${page}) +%Y-%m-%dT%TZ)" +for page in ../public/issue-*.html ; do + issue=$(echo $page | grep -oE "issue\-[0-9]+") + title=$(echo $issue | awk -F '-' '{ print "Issue #"$NF }') + . ./$issue/metadata.sh + tag="$(echo -n ${issue} | sha256)" - title="${page%-.*}" - tag="$(echo -n ${page} | sha256)" - - cat < -${title} -tag:${domain},2021:${tag} -${updated} - - + cat < + ${title} + tag:${domain},2021:${tag} + ${PUBLISHED_DATE} + + - + EOF done echo "" - -exit diff --git a/issues/make_issue.sh b/issues/make_issue.sh index f8215b2..8ed91a7 100755 --- a/issues/make_issue.sh +++ b/issues/make_issue.sh @@ -18,6 +18,8 @@ test -d "$DIR" || usage test -d ../public/ || die "You must run this from openbsd-webzine/current" ls $DIR/*.html 2>&1 >/dev/null || die "no html file in $DIR" +. ./${DIR}/metadata.sh + if [ "$(stat -f '%i' $DIR)" -eq "$CURINODE" ] then DEST=dev @@ -37,4 +39,4 @@ issue="${1#issue-}" sed -i "s/__ISSUE__/${issue}/g" $DESTFILENAME # replace date -sed -i "s/__DATE__/$(date -u)/" $DESTFILENAME +sed -i "s/__DATE__/${PUBLISHED_DATE}/" $DESTFILENAME