Skip to content

Commit

Permalink
Merge pull request #381 from perladvent/oalders/build-single-year
Browse files Browse the repository at this point in the history
Add --single-year option to site builder
  • Loading branch information
oalders authored Dec 20, 2023
2 parents 6e6dfcd + 8dac630 commit 70b0b4d
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions script/build-site.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,62 @@
#!/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

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
Expand All @@ -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

0 comments on commit 70b0b4d

Please sign in to comment.