shithub: werc

Download patch

ref: cbfeb6d94bb83c10d71effd316ca380377c33445
parent: 528ffdd59f635817fc01499e403d079949ed960d
author: sl <[email protected]>
date: Sat Dec 7 16:55:44 EST 2019

apps/blagh/: fix rss (passes validation), partially fix atom (does not pass validation)

--- a/apps/blagh/app.rc
+++ b/apps/blagh/app.rc
@@ -74,15 +74,14 @@
     # An user can add this on their own using handlers_body_head anyway.
     #echo '<div style="text-align:right">(<a href="index.rss">RSS Feed</a>|<a href="index.atom">Atom Feed</a>)</div>'
 
-    { # XXX Not sure why this fixes issues with blog setup, probably bug in fltr_cache!
+    # XXX Not sure why this fixes issues with blog setup, probably bug in fltr_cache!
     for(p in `{get_post_list $blagh_root^$blagh_dirs}) {
         l=`{echo -n $p|sed 's!'$sitedir^'/?(.*)([0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])(/[^/]+/)!\2 /\1\2\3!'}
         sed '1s!.*![&]('^$l(2)^') ('^$l(1)^')!' < $p/index.md 
         echo # Needed extra \n so markdown doesn't mess up the formatting, probably can be done in sed.
-    }
+    } | $formatter
     # XXX BUG! Markdown [references] break because multiple markdown documents are merged. Should format each blog post independently.
     # TODO: use fltr_cache directly, that can fix the previous bug plus provide a perf boost by caching title generation.
-    } | $formatter 
 }
 
 fn get_post_list {
--- a/apps/blagh/atom.tpl
+++ b/apps/blagh/atom.tpl
@@ -5,11 +5,9 @@
 fn statpost {
     f = $1
 
-    updated = `{datet `{mtime $f | awk '{print $1}'}}
+    updated = `{date -t `{mtime $f | awk '{print $1}'}}	# wtf doesn't this validate?
     post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!'}}^'/'
     title=`{read $f/index.md}
-    # Not used: date=`{/bin/date -Rd `{basename $f |sed 's/(^[0-9\-]*).*/\1/; s/-[0-9]$//'}}
-    # TODO: use mtime(1) and ls(1) instead of lunix's stat(1)
     #stat=`{stat -c '%Y %U' $f}
     #mdate=`{/bin/date -Rd `{mtime $f|awk '{print $1}' }} # Not used because it is unreliable
     by=`{ls -m $f | sed 's/^\[//g; s/].*$//g' >[2]/dev/null}
@@ -16,7 +14,7 @@
     #ifs=() { summary=`{cat $f/index.md | crop_text 1024 ... | $formatter } }
     ifs=() { summary=`{cat $f/index.md | strip_title_from_md_file | ifs=$difs {$formatter} } }
 }
-updated = `{datet}
+updated = `{ndate -t}
 %}
 
 <feed xmlns="http://www.w3.org/2005/Atom"
@@ -33,7 +31,6 @@
     <title><![CDATA[%($siteTitle%)]]></title>
     <subtitle><![CDATA[%($siteSubTitle%)]]></subtitle>
 
-% # <updated>2008-09-24T12:47:00-04:00</updated>
     <updated>%($updated%)</updated>
     <link href="."/>
 
@@ -49,9 +46,9 @@
         <author><name><![CDATA[%($by%)]]></name></author>
 
 
-        <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
-            <![CDATA[%($summary%)]]>
-        </div></content>
+        <content type="html">
+            %($summary%)
+        </content>
 
         <updated>%($updated%)</updated>
     </entry>
--- a/apps/blagh/rss20.tpl
+++ b/apps/blagh/rss20.tpl
@@ -7,10 +7,7 @@
     post_uri = `{echo $f | sed 's,^'$sitedir',,'}
     #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
     title=`{read $f/index.md}
-    date=`{date `{mtime $f | awk '{print $1}'}} # rss 2.0 spec says pubDate should conform to rfc822
-    # TODO: use mtime(1) and ls(1) instead of lunix's stat(1)
-    #stat=`{stat -c '%Y %U' $f}
-    #mdate=`{/bin/date -Rd $stat(1)} # Not used because it is unreliable
+    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} }}
@@ -44,7 +41,7 @@
             <link>%($post_uri%)</link>
             <guid isPermaLink="true">%($post_uri%)</guid>
             <pubDate>%($date%)</pubDate>
-            <description><![CDATA[%($summary%)]]></description>
+            <description> %($summary%) </description>
         </item>
 %        }