You can then enter the directory and run redo there. This will generate article
.html files from all .md and .rst files, plus a ./index.html, and a ./feed.xml.
-These files will be linked to symbolically in a directory ./public/.
+These files will be linked to symbolically in a directory ./public/. If you
+provide a file suffixed .links to basename of an article file, these links will
+be added as article-specific linkbacks to the .html file and the feed entry.
Some metadata files will also be generated below ./metadata/: For each article,
there will be generated a .automatic_metadata (to contain an article's UUID,
pandoc-formatted article content like title and body); furthermore, files for
data used in ./feed.xml and ./index.html will, if non-existant, be built there
and can be edited to customize the blog – namely the files url, author, title,
-index.tmpl, index_snippet.tmpl, article.tmpl. A blog-specific UUID and creation
-date is stored in ./metadata/automatic_metadata
+index.tmpl, index_snippet.tmpl, article.tmpl, linkback.tmpl. A blog-specific
+UUID and creation date is stored in ./metadata/automatic_metadata
recipe to remotely manage a redo blog with git
----------------------------------------------
#!/bin/sh
+# Handle URL from .links file.
+prep_url() {
+ url=$(printf "%s" "$(escape_html "$1")" | prep_sed)
+ template=$(cat "$linkback_tmpl_file")
+ printf "%s" "$template" | sed 's/%URL%/'"$url"'/g' | tr '\a' '%' | prep_sed
+}
+
# Pull in global dependencies.
. ./helpers.sh
metadata_dir=metadata
redo-ifchange "$intermediate_file"
title_file="${metadata_dir}"/title
redo-ifchange "$title_file"
-template_file="${metadata_dir}"/article.tmpl
-redo-ifchange "$template_file"
+article_tmpl_file="${metadata_dir}"/article.tmpl
+redo-ifchange "$article_tmpl_file"
+linkback_tmpl_file="${metadata_dir}"/linkback.tmpl
+redo-ifchange "$linkback_tmpl_file"
+replies_file="${1%.html}.links"
# Build entry data.
blog_title=$(read_and_escape_file "$title_file" | head -1 | prep_sed)
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}")
+if test -f "$replies_file"; then
+ replies=$(while read line; do prep_url "$line"; done < "$replies_file")
+fi
# Put data into template.
-template=$(cat "$template_file")
+template=$(cat "$article_tmpl_file")
printf "%s" "$template" | \
sed 's/%BLOG_TITLE%/'"$blog_title"'/g' | \
sed 's/%ARTICLE_TITLE_ESCAPED%/'"$title_plaintext"'/g' | \
sed 's/%DATE_CREATED%/'"$date_created"'/g' | \
sed 's/%DATE_UPDATED%/'"$date_updated"'/g' | \
sed 's/%BODY%/'"$body"'/g' | \
+sed 's/%LINKBACKS%/'"$replies"'/g' | \
tr '\a' '%'
<p>created: <time>%DATE_CREATED%</time> / last update: <time>%DATE_UPDATED%</time></p>
</header>
%BODY%
+<footer>
+Links back:
+<ul>%LINKBACKS%
+</ul>
+</footer>
</article>
EOF
fi
#!/bin/sh
+# Handle URL from .links file.
+prep_url() {
+ url=$(escape_html "$1")
+ printf "\n<link href=\"%s\" rel=\"replies\">%s</link>" "$url" "$url"
+}
+
# Pull in dependencies.
. ../helpers.sh
src_file=$(get_source_file "$1")
redo-ifchange "$meta_file"
intermediate_file="${1%.feed_snippet}.intermediate"
redo-ifchange "$intermediate_file"
+replies_file="${src_file%.*}.links"
# Get variables, write entry.
html_file=$(escape_url "${1%.feed_snippet}.html")
published_unix=$(get_creation_date_from_meta_file_seconds "$meta_file")
published_rfc3339=$(date -u "+%Y-%m-%dT%TZ" -d "@${published_unix}")
body=$(read_and_escape_file "$intermediate_file" | sed 1d)
+if test -f "$replies_file"; then
+ replies=$(while read line; do prep_url "$line"; done < "$replies_file")
+fi
printf "<entry>\n"
printf "<title type=\"html\">%s</title>\n" "$title"
printf "<id>urn:uuid:%s</id>\n" "$uuid"
printf "<updated>%s</updated>\n" "$lastmod_rfc3339"
printf "<published>%s</published>\n" "$published_rfc3339"
-printf "<link href=\"%s%s\" rel=\"alternate\" type=\"text/html\" />\n" "$(get_basepath)" "${html_file}"
-printf "<content type=\"html\">\n%s\n</content>\n" "$body"
+printf "<link href=\"%s%s\" rel=\"alternate\" type=\"text/html\" />" "$(get_basepath)" "${html_file}"
+printf "%s" "$replies"
+printf "\n<content type=\"html\">\n%s\n</content>\n" "$body"
printf "</entry>\n"
--- /dev/null
+#!/bin/sh
+
+if [ ! -f "$1" ]; then
+ printf "\n%s" "<li><a href=\"%URL%\">%URL%</a></li>"
+fi
cp "$working_dir/$expected_files_dir"/bar\ baz.md .
redo
cp "$working_dir/$expected_files_dir"/foo.rst .
+cp "$working_dir/$expected_files_dir"/foo.links .
redo
# Test file modification tracking.
<p>bar</p>
<h3 id="bar-1">bar</h3>
<p>bar</p>
+<footer>
+Links back:
+<ul>
+</ul>
+</footer>
</article>
\ No newline at end of file
<updated>IGNORE</updated>
<published>IGNORE</published>
<link href="http://example.org/foo.html" rel="alternate" type="text/html" />
+<link href="http://example.org/" rel="replies">http://example.org/</link>
+<link href="http://example.com/some"what'danger<>us%URL" rel="replies">http://example.com/some"what'danger<>us%URL</link>
<content type="html">
<p>this text contains some special characters: /;%'&quot;&gt;&lt;&amp;äöüß</p>
<h2 id="some-sub-heading">some sub-heading</h2>
<p>and more than one paragraph</p>
<h2 id="another-sub-heading">another sub-heading</h2>
<p>note that should be ignored but \ should give a backlash</p>
+<footer>
+Links back:
+<ul>
+<li><a href="http://example.org/">http://example.org/</a></li>
+<li><a href="http://example.com/some"what'danger<>us%URL">http://example.com/some"what'danger<>us%URL</a></li>
+</ul>
+</footer>
</article>
\ No newline at end of file
--- /dev/null
+http://example.org/
+http://example.com/some"what'danger<>us%URL
<p>foo</p>
<h2 id="bar">bar</h2>
<p>baz</p>
+<footer>
+Links back:
+<ul>
+</ul>
+</footer>
</article>
\ No newline at end of file