shithub: werc

Download patch

ref: 12823b51dae119112db5ce356866912ea1fdcae8
parent: 7f28dcfddf3e322b1fc0e8d68887300c756eb087
author: sl <[email protected]>
date: Mon Dec 9 14:37:43 EST 2019

apps/blagh/rss20.tpl: correctly generate accurate dates for <lastBuildDate> and <pubDate>.

--- a/apps/blagh/rss20.tpl
+++ b/apps/blagh/rss20.tpl
@@ -3,11 +3,8 @@
 %{
 fn statpost {
     f = $1
-
     post_uri = `{echo $f | sed 's,^'$sitedir',,'}
-    #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
     title=`{read $f/index.md}
-    date=`{ndate -m}	# rss 2.0 spec says pubDate should conform to rfc822
     post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!'}}^'/'
     by=`{ls -m $f | sed 's/^\[//g; s/].*$//g' >[2]/dev/null}
     ifs=() {summary=`{ cat $f/index.md |strip_title_from_md_file| ifs=$difs {$formatter | escape_html} }}
@@ -25,15 +22,13 @@
         <generator><![CDATA[Tom Duff's rc, and Kris Maglione's clever hackery]]></generator>
 %{
         # <webMaster>[email protected] (Uriel)</webMaster>
-        for(f in `{get_post_list $blagh_root$blagh_dirs}) {
+	# rfc822 last time channel content changed.
+	lbd=`{ndate -m `{date `{mtime `{ls $blagh_root$blagh_dirs | grep -e '[0-9][0-9][0-9][0-9]' | tail -1} | awk '{print $1}'}}}
+	echo '<lastBuildDate>'$"lbd'</lastBuildDate>'
+	# rfc822 publication date for content in the channel.
+	pubdate=`{ndate -m}
+        for(f in `{get_post_list $blagh_root$blagh_dirs}){
             statpost $f
-            # Hack to aproximate the last build date 
-            #(use the mdate from last posted item)
-            # Commented out for now because maybe a wrong value is worse than no value
-            #if(~ $#last_build_date 0) {
-                #last_build_date='<lastBuildDate>'^$"mdate'</lastBuildDate>'
-                #echo $last_build_date
-            #}
 %}
         <item>
             <title><![CDATA[%($title%)]]></title>
@@ -40,10 +35,9 @@
             <author><![CDATA[%($by%)@noreply.cat-v.org (%($by%))]]></author>
             <link>%($post_uri%)</link>
             <guid isPermaLink="true">%($post_uri%)</guid>
-            <pubDate>%($date%)</pubDate>
+            <pubDate>%($pubdate%)</pubDate>
             <description> %($summary%) </description>
         </item>
 %        }
-
     </channel>
 </rss>