From 8673ca16012f00a7c4e6307efaddd004b421b46e Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 26 Apr 2020 16:58:43 +0200 Subject: [PATCH] extract header and footer into functions --- blog-refresh.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/blog-refresh.sh b/blog-refresh.sh index b22d525..6d48456 100755 --- a/blog-refresh.sh +++ b/blog-refresh.sh @@ -4,6 +4,16 @@ output() { echo "$1" >> index.html } +add_header() { + output '

Blog index

' + output '' +} + +add_footer() { + html_entry "legacy" "before 2020" "Older posts" + output '' +} + html_entry() { output '' path="$1" @@ -38,12 +48,9 @@ cd /home/nginx/html/blog if has_updates; then git pull &> /dev/null rm -f index.html - output '

Blog index

' - output '' + add_header ls -ltu src/*.md | tail -n+1 | while read f; do create_entry $f; done - html_entry "legacy" "before 2020" "Older posts" - output '' - output "" + add_footer # Human-readable output for the cron notification echo 'Updated blog to:' git log -1