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

This commit is contained in:
stanley lieber 2019-12-07 21:55:44 -05:00
parent 4f42153162
commit 81969a371d
3 changed files with 9 additions and 16 deletions

View File

@ -74,15 +74,14 @@ fn blagh_body {
# 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 {

View File

@ -5,18 +5,16 @@
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}
#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 @@ updated = `{datet}
<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 @@ updated = `{datet}
<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>

View File

@ -7,10 +7,7 @@ fn statpost {
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 @@ fn statpost {
<link>%($post_uri%)</link>
<guid isPermaLink="true">%($post_uri%)</guid>
<pubDate>%($date%)</pubDate>
<description><![CDATA[%($summary%)]]></description>
<description> %($summary%) </description>
</item>
% }