From 57b9f8ec5eebf7fed09da3007c0571bab7d982fa Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 3 Jan 2017 10:12:41 +0100
Subject: [PATCH] Add modification date element to article template.

---
 processor/default.html.do             | 7 +++++--
 processor/metadata/article.tmpl.do    | 2 +-
 test/test_files/bar baz.html.ignoring | 2 +-
 test/test_files/foo.html.ignoring     | 2 +-
 test/test_files/test.html.ignoring    | 2 +-
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/processor/default.html.do b/processor/default.html.do
index 8777d43..7adf89b 100644
--- a/processor/default.html.do
+++ b/processor/default.html.do
@@ -20,7 +20,9 @@ title_html=$(printf "%s" "$title_html" | prep_sed)
 title_plaintext=$(escape_html "$title_plaintext" | prep_sed)
 body=$(cat "$intermediate_file" | sed 1d | prep_sed)
 datetime_created_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
-datetime_created_friendly=$(date -u "+%Y-%m-%d" -d "@${datetime_created_unix}")
+date_created=$(date -u "+%Y-%m-%d" -d "@${datetime_created_unix}")
+datetime_lastmod_unix=$(get_lastmod_date_from_meta_file "$meta_file")
+date_updated=$(date -u "+%Y-%m-%d" -d "@${datetime_lastmod_unix}")
 
 # Put data into template.
 template=$(cat "$template_file")
@@ -28,6 +30,7 @@ printf "%s" "$template" | \
 sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \
 sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \
 sed 's/%ARTICLE_TITLE_HTML%/'"$title_html"'/g' | \
-sed 's/%DATE_CREATED%/'"$datetime_created_friendly"'/g' | \
+sed 's/%DATE_CREATED%/'"$date_created"'/g' | \
+sed 's/%DATE_UPDATED%/'"$date_updated"'/g' | \
 sed 's/%BODY%/'"$body"'/g' | \
 tr '\a' '%'
diff --git a/processor/metadata/article.tmpl.do b/processor/metadata/article.tmpl.do
index 575e433..e945d5b 100644
--- a/processor/metadata/article.tmpl.do
+++ b/processor/metadata/article.tmpl.do
@@ -23,7 +23,7 @@ header p { margin: 0; }
 <article>
 <header>
 <h1>%ARTICLE_TITLE_HTML%</h1>
-<p><time>%DATE_CREATED%</time></p>
+<p>created: <time>%DATE_CREATED%</time> / last update: <time>%DATE_UPDATED%</time></p>
 </header>
 %BODY%
 </article>
diff --git a/test/test_files/bar baz.html.ignoring b/test/test_files/bar baz.html.ignoring
index 7043475..b4167b7 100644
--- a/test/test_files/bar baz.html.ignoring	
+++ b/test/test_files/bar baz.html.ignoring	
@@ -19,7 +19,7 @@ header p { margin: 0; }
 <article>
 <header>
 <h1>foo</h1>
-<p><time>IGNORE</time></p>
+<p>created: <time>IGNORE</time> / last update: <time>IGNORE</time></p>
 </header>
 <h2 id="bar">bar</h2>
 <p>bar</p>
diff --git a/test/test_files/foo.html.ignoring b/test/test_files/foo.html.ignoring
index 490e71a..ba00446 100644
--- a/test/test_files/foo.html.ignoring
+++ b/test/test_files/foo.html.ignoring
@@ -19,7 +19,7 @@ header p { margin: 0; }
 <article>
 <header>
 <h1>a title with some nasty characters: &amp;&lt;&gt;&quot;' %BODY%</h1>
-<p><time>IGNORE</time></p>
+<p>created: <time>IGNORE</time> / last update: <time>IGNORE</time></p>
 </header>
 <p>this text contains some special characters: /;%'&quot;&gt;&lt;&amp;äöüß</p>
 <h2 id="some-sub-heading">some sub-heading</h2>
diff --git a/test/test_files/test.html.ignoring b/test/test_files/test.html.ignoring
index 91687d7..454343f 100644
--- a/test/test_files/test.html.ignoring
+++ b/test/test_files/test.html.ignoring
@@ -19,7 +19,7 @@ header p { margin: 0; }
 <article>
 <header>
 <h1>foo <em>bar</em> <strong>baz</strong></h1>
-<p><time>IGNORE</time></p>
+<p>created: <time>IGNORE</time> / last update: <time>IGNORE</time></p>
 </header>
 <p>foo</p>
 <h2 id="bar">bar</h2>
-- 
2.30.2