From 8dac63080c7456218383a983ee3c96122d3c56d9 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 16 Dec 2023 12:59:53 -0500 Subject: [PATCH] Add --single-year option to site builder --- script/build-site.sh | 48 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/script/build-site.sh b/script/build-site.sh index 2f5d87b72..26ae23bad 100755 --- a/script/build-site.sh +++ b/script/build-site.sh @@ -1,8 +1,36 @@ #!/bin/bash +# Usage ./script/build-site.sh +# +# To build just a single year +# ./script/build-site.sh --single-year 2023 +# +# To build the entire month for the current year +# ./script/build-site.sh --single-year 2023 --today 2023-12-31 + pwd set -eu -o pipefail +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -s | --single-year) + single_year="$2" + shift + shift + ;; + -t | --today) + today="$2" + shift + shift + ;; + *) + echo "Unknown option: $key" + exit 1 + ;; + esac +done + site=out rm -rf $site mkdir $site @@ -10,13 +38,25 @@ mkdir $site perl mkarchives $site for year in $(seq 2000 2010); do + if [[ "${single_year:-}" && $single_year -ne $year ]]; then + continue + fi + echo "copying $year" cp -R "$year" out/ done for year in $(seq 2011 2023); do + if [[ ${single_year:-} && $single_year -ne $year ]]; then + continue + fi mkdir "$site/$year" cd "$year" - advcal -c advent.ini -o "../$site/$year" --https + + if [[ ${today:-} ]]; then + advcal -c advent.ini -o "../$site/$year" --https --today "$today" + else + advcal -c advent.ini -o "../$site/$year" --https + fi pwd cp -R share/static/* "../$site/$year" if [[ -e "$year.css" ]]; then @@ -30,6 +70,6 @@ cp RSS.xml out/ cp -R images out/ cp favicon.ico out/ -Markdown.pl contact.mkdn > out/contact.html -Markdown.pl FAQ.mkdn > out/FAQ.html -Markdown.pl FAQ-submit.mkdn > out/FAQ-submit.html +Markdown.pl contact.mkdn >out/contact.html +Markdown.pl FAQ.mkdn >out/FAQ.html +Markdown.pl FAQ-submit.mkdn >out/FAQ-submit.html