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 c3d7645c7c
commit 4640183908
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. # 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>' #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}) { 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!'} 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 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. 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. # 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. # 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 { fn get_post_list {

View file

@ -5,18 +5,16 @@
fn statpost { fn statpost {
f = $1 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'!!'}}^'/' post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!'}}^'/'
title=`{read $f/index.md} 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} #stat=`{stat -c '%Y %U' $f}
#mdate=`{/bin/date -Rd `{mtime $f|awk '{print $1}' }} # Not used because it is unreliable #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} 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 | crop_text 1024 ... | $formatter } }
ifs=() { summary=`{cat $f/index.md | strip_title_from_md_file | ifs=$difs {$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" <feed xmlns="http://www.w3.org/2005/Atom"
@ -33,7 +31,6 @@ updated = `{datet}
<title><![CDATA[%($siteTitle%)]]></title> <title><![CDATA[%($siteTitle%)]]></title>
<subtitle><![CDATA[%($siteSubTitle%)]]></subtitle> <subtitle><![CDATA[%($siteSubTitle%)]]></subtitle>
% # <updated>2008-09-24T12:47:00-04:00</updated>
<updated>%($updated%)</updated> <updated>%($updated%)</updated>
<link href="."/> <link href="."/>
@ -49,9 +46,9 @@ updated = `{datet}
<author><name><![CDATA[%($by%)]]></name></author> <author><name><![CDATA[%($by%)]]></name></author>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"> <content type="html">
<![CDATA[%($summary%)]]> %($summary%)
</div></content> </content>
<updated>%($updated%)</updated> <updated>%($updated%)</updated>
</entry> </entry>

View file

@ -7,10 +7,7 @@ fn statpost {
post_uri = `{echo $f | sed 's,^'$sitedir',,'} post_uri = `{echo $f | sed 's,^'$sitedir',,'}
#title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
title=`{read $f/index.md} title=`{read $f/index.md}
date=`{date `{mtime $f | awk '{print $1}'}} # rss 2.0 spec says pubDate should conform to rfc822 date=`{ndate -m} # 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
post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!'}}^'/' post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!'}}^'/'
by=`{ls -m $f | sed 's/^\[//g; s/].*$//g' >[2]/dev/null} 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} }} 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> <link>%($post_uri%)</link>
<guid isPermaLink="true">%($post_uri%)</guid> <guid isPermaLink="true">%($post_uri%)</guid>
<pubDate>%($date%)</pubDate> <pubDate>%($date%)</pubDate>
<description><![CDATA[%($summary%)]]></description> <description> %($summary%) </description>
</item> </item>
% } % }