From 5a17d0898d72bc8574601f57f26af8d3e0da2288 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 19 Nov 2016 22:01:58 +0100 Subject: [PATCH] Rename generated meta files, test for them. --- processor/{author.do => author.meta.do} | 0 processor/default.html.do | 5 +++-- processor/feed.xml.do | 28 ++++++++++++++----------- processor/index.html.do | 5 +++-- processor/{title.do => title.meta.do} | 0 processor/{url.do => url.meta.do} | 0 processor/{uuid.do => uuid.meta.do} | 0 test.sh | 15 +++++++++++++ test/test_files/author.meta | 1 + test/test_files/title.meta | 1 + test/test_files/url.meta | 1 + test/test_files/uuid.meta | 1 + 12 files changed, 41 insertions(+), 16 deletions(-) rename processor/{author.do => author.meta.do} (100%) rename processor/{title.do => title.meta.do} (100%) rename processor/{url.do => url.meta.do} (100%) rename processor/{uuid.do => uuid.meta.do} (100%) create mode 100644 test/test_files/author.meta create mode 100644 test/test_files/title.meta create mode 100644 test/test_files/url.meta create mode 100644 test/test_files/uuid.meta diff --git a/processor/author.do b/processor/author.meta.do similarity index 100% rename from processor/author.do rename to processor/author.meta.do diff --git a/processor/default.html.do b/processor/default.html.do index 3ff4132..2a457a5 100644 --- a/processor/default.html.do +++ b/processor/default.html.do @@ -3,11 +3,12 @@ # Pull in global dependencies. . ./helpers.sh intermediate_file="${1%.html}.intermediate" -redo-ifchange title +title_file=title.meta +redo-ifchange "$title_file" redo-ifchange "$intermediate_file" # Build entry data. -blog_title=`read_and_escape_file title | head -1` +blog_title=`read_and_escape_file "$title_file" | head -1` title_html=`cat "$intermediate_file" | head -1` title_plaintext=`echo "$title_html" | html2text` title_plaintext_escaped=`escape_html "$title_plaintext"` diff --git a/processor/feed.xml.do b/processor/feed.xml.do index 2cdb7b2..14ead59 100644 --- a/processor/feed.xml.do +++ b/processor/feed.xml.do @@ -2,21 +2,25 @@ # Pull in global dependencies. . ./helpers.sh -redo-ifchange url -redo-ifchange author -redo-ifchange uuid -redo-ifchange title +url_file=url.meta +author_file=author.meta +uuid_file=uuid.meta +title_file=title.meta +redo-ifchange "$url_file" +redo-ifchange "$author_file" +redo-ifchange "$uuid_file" +redo-ifchange "$title_file" # Build some variables. XML-escape even file contents that should not contain # dangerous characters, just to avoid any XML trouble. -base_url=`cat url | head -1` +base_url=`cat "$url_file" | head -1` url_protocol=`echo $base_url | cut -d ':' -f 1` url_basepath=`echo $base_url | cut -d '/' -f 3-` url_basepath_escaped=`escape_url "$url_basepath"` basepath="$url_protocol""://""$url_basepath_escaped" -title=`read_and_escape_file title | head -1` -author=`read_and_escape_file author | head -1` -uuid=`read_and_escape_file uuid | head -1` +title=`read_and_escape_file "$title_file" | head -1` +author=`read_and_escape_file "$author_file" | head -1` +uuid=`read_and_escape_file "$uuid_file" | head -1` # Write majority of feed head. cat << EOF @@ -47,13 +51,13 @@ for file in $files; do # Build some variables and dependencies. intermediate_file="${file%.*}.intermediate" htmlfile=`escape_url "${file%.*}.html"` + uuid_file="${file%.*}.uuid" redo-ifchange "$intermediate_file" - redo-ifchange "$uuidfile" + redo-ifchange "$uuid_file" title=`read_and_escape_file "$intermediate_file" | head -1` - uuidfile="${file%.*}.uuid" - uuid=`read_and_escape_file "$uuidfile" | head -1` + uuid=`read_and_escape_file "$uuid_file" | head -1` body=`read_and_escape_file "$intermediate_file" | sed 1d` - published=`stat -c%y "$uuidfile"` + published=`stat -c%y "$uuid_file"` published_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$published"` # Write entry. diff --git a/processor/index.html.do b/processor/index.html.do index 8bf6751..2b71ffb 100644 --- a/processor/index.html.do +++ b/processor/index.html.do @@ -2,7 +2,8 @@ # Pull in global dependencies. . ./helpers.sh -redo-ifchange title +title_file=title.meta +redo-ifchange "$title_file" # Write index head. cat << EOF @@ -10,7 +11,7 @@ cat << EOF EOF -blog_title=`read_and_escape_file title | head -1` +blog_title=`read_and_escape_file "$title_file" | head -1` printf "%s\n\n\n" "$blog_title" printf "

%s

\n