home · contact · privacy
Add interpretation of article-specific linkback URL list files.
[redo-blog] / processor / metadata / default.feed_snippet.do
index 872eacfe7a3120ccea73c7aacabacdbc23d45b88..73a2d5649451fc8296405944eaeba4a15afb6325 100644 (file)
@@ -1,5 +1,11 @@
 #!/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")
@@ -7,6 +13,7 @@ meta_file="${1%.feed_snippet}.automatic_metadata"
 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")
@@ -17,11 +24,15 @@ uuid=$(get_uuid_from_meta_file "$meta_file")
 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"