From 0dddf8e27165915e413feaa4a6acf234e4ca5d17 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 25 Jan 2017 02:52:08 +0100 Subject: [PATCH] Add captcha files support. --- processor/captchas/default.do | 5 +++++ processor/default.html.do | 3 +++ test.sh | 10 +++++++++- test/test_files/captchas/bar baz | 2 ++ test/test_files/captchas/foo | 2 ++ test/test_files/captchas/te"st | 2 ++ 6 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 processor/captchas/default.do create mode 100644 test/test_files/captchas/bar baz create mode 100644 test/test_files/captchas/foo create mode 100644 test/test_files/captchas/te"st diff --git a/processor/captchas/default.do b/processor/captchas/default.do new file mode 100644 index 0000000..dc28477 --- /dev/null +++ b/processor/captchas/default.do @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ ! -f "$1" ]; then + printf "apple\napple" +fi diff --git a/processor/default.html.do b/processor/default.html.do index c744889..ba163e2 100644 --- a/processor/default.html.do +++ b/processor/default.html.do @@ -10,6 +10,7 @@ prep_url() { # Pull in global dependencies. . ./helpers.sh metadata_dir=metadata +captchas_dir=captchas meta_file="${metadata_dir}/${1%.html}.automatic_metadata" redo-ifchange "$meta_file" intermediate_file="${metadata_dir}/${1%.html}.intermediate" @@ -22,6 +23,8 @@ linkback_tmpl_file="${metadata_dir}"/linkback.tmpl redo-ifchange "$linkback_tmpl_file" replies_file="${1%.html}.links" redo-ifchange "$replies_file" +captcha_file="$captchas_dir/${1%.html}" +redo-ifchange "$captcha_file" # Build entry data. blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed) diff --git a/test.sh b/test.sh index ce50d29..10b6fd9 100755 --- a/test.sh +++ b/test.sh @@ -93,12 +93,20 @@ done # Compare .links files. cd "$working_dir" -for file in "$expected_files_dir"/*.links "$expected_files_dir"/*.captcha; do +for file in "$expected_files_dir"/*.links; do basename=$(basename "$file") cmp_file="$generated_files_dir/$basename" diff_test "$file" "$cmp_file" done +# Compare captcha files. +cd "$working_dir" +for file in "$expected_files_dir"/captchas/*; do + basename=$(basename "$file") + cmp_file="$generated_files_dir/captchas/$basename" + diff_test "$file" "$cmp_file" +done + # Compare generated HTML files. Ignore variable dates. for file in "$expected_files_dir"/*.html.ignoring; do basename=$(basename "$file") diff --git a/test/test_files/captchas/bar baz b/test/test_files/captchas/bar baz new file mode 100644 index 0000000..42bf241 --- /dev/null +++ b/test/test_files/captchas/bar baz @@ -0,0 +1,2 @@ +apple +apple \ No newline at end of file diff --git a/test/test_files/captchas/foo b/test/test_files/captchas/foo new file mode 100644 index 0000000..42bf241 --- /dev/null +++ b/test/test_files/captchas/foo @@ -0,0 +1,2 @@ +apple +apple \ No newline at end of file diff --git a/test/test_files/captchas/te"st b/test/test_files/captchas/te"st new file mode 100644 index 0000000..42bf241 --- /dev/null +++ b/test/test_files/captchas/te"st @@ -0,0 +1,2 @@ +apple +apple \ No newline at end of file -- 2.30.2