home · contact · privacy
Add captcha files support.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 25 Jan 2017 01:52:08 +0000 (02:52 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 25 Jan 2017 01:52:08 +0000 (02:52 +0100)
processor/captchas/default.do [new file with mode: 0644]
processor/default.html.do
test.sh
test/test_files/captchas/bar baz [new file with mode: 0644]
test/test_files/captchas/foo [new file with mode: 0644]
test/test_files/captchas/te&quot;st [new file with mode: 0644]

diff --git a/processor/captchas/default.do b/processor/captchas/default.do
new file mode 100644 (file)
index 0000000..dc28477
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ ! -f "$1" ]; then
+  printf "apple\napple"
+fi
index c744889405bbe8e4f8b9070b18cd02828d994882..ba163e2e29f32369cd2075f5d282cd6b46879326 100644 (file)
@@ -10,6 +10,7 @@ prep_url() {
 # Pull in global dependencies.
 . ./helpers.sh
 metadata_dir=metadata
 # 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"
 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"
 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)
 
 # Build entry data.
 blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed)
diff --git a/test.sh b/test.sh
index ce50d29a7a50aef30fa56e48c973e663a2276336..10b6fd91c57940c5f30f843832480d1f7fd8c191 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -93,12 +93,20 @@ done
 
 # Compare .links files.
 cd "$working_dir"
 
 # 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
 
   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")
 # 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 (file)
index 0000000..42bf241
--- /dev/null
@@ -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 (file)
index 0000000..42bf241
--- /dev/null
@@ -0,0 +1,2 @@
+apple
+apple
\ No newline at end of file
diff --git a/test/test_files/captchas/te&quot;st b/test/test_files/captchas/te&quot;st
new file mode 100644 (file)
index 0000000..42bf241
--- /dev/null
@@ -0,0 +1,2 @@
+apple
+apple
\ No newline at end of file