From c67421732e148c768cc83395c143480b2b9b6106 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 22 Dec 2016 00:11:38 +0100
Subject: [PATCH] Move (links to) files meant to be public into separate
 directory.

---
 processor/all.do          | 14 +++++++++++---
 processor/default.html.do |  1 -
 test.sh                   | 12 ++++++++++++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/processor/all.do b/processor/all.do
index 73d0124..3c3a021 100644
--- a/processor/all.do
+++ b/processor/all.do
@@ -1,6 +1,10 @@
 #!/bin/sh
 
+# Set up directories.
 metadata_dir=.meta
+public_dir=public
+cur_dir=$(pwd)
+mkdir -p "$public_dir"
 
 # Remove target files for which no sources files can be found.
 for file in "$metadata_dir"/*.intermediate; do
@@ -37,10 +41,14 @@ done
 for file in "$metadata_dir"/*.intermediate; do
   if test -f "$file"; then
     basename=$(basename "$file")
-    redo-ifchange "${basename%.intermediate}.html"
+    html_file=${basename%.intermediate}.html
+    redo-ifchange "$html_file"
+    ln -sf "$cur_dir/$html_file" "${public_dir}/"
   fi
 done
 
 # Regenerate feed and index pages. Always.
-redo "feed.xml"
-redo "index.html"
+redo feed.xml
+ln -sf "$cur_dir"/feed.xml "${public_dir}/"
+redo index.html
+ln -sf "$cur_dir"/index.html "${public_dir}/"
diff --git a/processor/default.html.do b/processor/default.html.do
index 4371a3a..99be463 100644
--- a/processor/default.html.do
+++ b/processor/default.html.do
@@ -24,6 +24,5 @@ EOF
 
 # Write remaining entry head and body. 
 printf "<title>%s – %s</title>\n</head>\n<body>\n" "$blog_title" "$title_plaintext_escaped"
-#printf "<title>%s – %s</title>\n</head>\n<body>\n" "$blog_title" "$entry_title"
 printf "<h1>%s</h1>\n" "$title_html"
 printf "<section>\n%s\n</section>\n</body>\n</html>" "$body"
diff --git a/test.sh b/test.sh
index c54e48a..8e2a024 100755
--- a/test.sh
+++ b/test.sh
@@ -64,3 +64,15 @@ cat "$original_file" | \
   > "$generated_file"
 diff_test "$expected_file" "$generated_file"
 rm "$generated_file"
+
+# Check symbolic links.
+for file in "$generated_files_dir"/feed.xml "$generated_files_dir"/*.html; do
+  basename=$(basename "$file")
+  linkname=$(readlink "$generated_files_dir/public/$basename")
+  printf "== public/%s symbolic link test ==\n" "$basename"
+  if [ "$working_dir/$generated_files_dir/$basename" = "$linkname" ]; then
+    echo "== test SUCCESS =="
+  else
+    echo "== test FAILURE =="
+  fi
+done
-- 
2.30.2