From 838247fc2e2b0f594d92f2e9b871aa84826cec0a Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 23 Aug 2021 21:49:04 -0500 Subject: [PATCH] Add song quotes to home page Since we're pre-rendering the page now, we can't select a song quote on the server side. Instead, we'll use JavaScript to fetch the song quotes as a JSON document and choose a random song from there. The JSON document is converted from the YAML source at build time with a simple Python script. --- ci/Containerfile | 2 ++ ci/build.sh | 7 +++++++ sass/style.scss | 24 +++++++++++++++++++++++ songquotes.yml | 45 ++++++++++++++++++++++++++++++++++++++++++++ templates/base.html | 2 +- templates/index.html | 38 +++++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 songquotes.yml diff --git a/ci/Containerfile b/ci/Containerfile index 9431b75..f7a735b 100644 --- a/ci/Containerfile +++ b/ci/Containerfile @@ -6,6 +6,8 @@ RUN apk update && \ apk add zola --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ && \ apk add \ openssh-client-default \ + python3 \ + py3-ruamel.yaml \ rsync \ && \ rm -rf /var/cache/apk/* diff --git a/ci/build.sh b/ci/build.sh index df66631..df57139 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -1 +1,8 @@ zola build --base-url / + +python3 /dev/fd/3 < songquotes.yml > public/songquotes.json 3< - +{% block after_content %}{% endblock %}