Introduction
Introduction Statistics Contact Development Disclaimer Help
Further progress with blagh app, atom feeds and rss feeds are mostly working. -…
git clone git://git.suckless.org/swerc
Log
Files
Refs
README
---
commit ad0edd17ccdc444f9d9df925774535930bfa3969
parent 66840ad19037234f9f7d85c70a348bd0117016a2
Author: [email protected] <unknown>
Date: Sun, 28 Dec 2008 21:37:03 +0100
Further progress with blagh app, atom feeds and rss feeds are mostly working.
Diffstat:
M apps/blagh/app.rc | 42 ++++++++++++++++++-----------…
A lib/_apps/blagh/atom.tpl | 141 +++++++++++++++++++++++++++++…
A lib/_apps/blagh/rss20.tpl | 61 +++++++++++++++++++++++++++++…
3 files changed, 227 insertions(+), 17 deletions(-)
---
diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc
@@ -5,35 +5,43 @@ fn blagh_init {
# Should not match sub-dirs!
if(! ~ $#blaghDirs 0) {
# && test -d / `{echo '-a -d '^$req_path^$blaghDirs}
+ blagh_uri=`{echo $req_path|sed 's/index\.(atom|rss)$//'}
+ blagh_url=$base_uri^$blagh_root_path
+ blagh_root=$sitedir^$blagh_uri
- if(~ $req_path */[0-9][0-9][0-9][0-9]/ */[0-9][0-9][0-9][0-9]/[0-9][0-…
+ if(~ $req_path */[0-9][0-9][0-9][0-9]/ */[0-9][0-9][0-9][0-9]/[0-9][0-…
status='Use default handler'
- if not if(~ $req_path */index) {
+ if not if(~ $req_path */index */) {
app_body_handler='blagh_body'
- #u=`{cleanname $baseuri^`{basename -d '/'^$uri}|sed 's,:/,://,'} #…
- u=`{cleanname $baseuri^$req_path'index}
+ u=$blagh_uri'index'
extraHeaders=$"extraHeaders ^ \
-'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss"…
-'<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.at…
+ '<link rel="alternate" type="application/rss+xml" title="RSS" href…
+<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.ato…
}
- if not if(~ $req_path */index.atom)
- app_body_handler='blagh_body'
- if not if(~ $req_path */index.rss)
- app_body_handler='blagh_body'
+ if not {
+ response_format=raw
+ if(~ $req_path */index.atom)
+ master_template=_apps/blagh/atom.tpl
+ if not if(~ $req_path */index.rss)
+ master_template=_apps/blagh/rss20.tpl
+ if not
+ dprint XXXX $req_path
+ }
}
+ status=()
}
fn blagh_body {
- d=$sitedir$req_path^$blaghDirs^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-…
- posts=`{ls -F $d >[2]/dev/null | sed -n 's,/\./,/|/,; /\/$/p' | sort -r '…
- for(p in $posts)
- show_post $p | $formatter
+ for(p in `{get_post_list $blagh_root^$blaghDirs}) {
+ l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'}
+ sed '1s!.*![&]('$l')!' < $p/index.md | $formatter
+ }
}
-fn show_post {
- l=`{echo $1 | sed 's|'$sitedir$req_path'||'}
- sed '1s|.*|[&]('$l')|' < $1/index.md
+fn get_post_list {
+ d=$*^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/
+ ls -F $d >[2]/dev/null | sed -n 's,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 …
}
diff --git a/lib/_apps/blagh/atom.tpl b/lib/_apps/blagh/atom.tpl
@@ -0,0 +1,141 @@
+Content-Type: application/atom+xml
+
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- TODO: See for more info:http://www.tbray.org/ongoing/When/200x/2005/07/27…
+%{
+dprint XXX
+fn statpost {
+ f = $1
+
+ updated = `{/bin/date --rfc-3339'=seconds' -r $f |tr ' ' 'T'}
+ post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!' -e 's/…
+ title=`{read $f}
+ # Not used: date=`{/bin/date -Rd `{basename $f |sed 's/(^[0-9\-]*).*/\1/; …
+ # 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 i…
+ by=$stat(2)
+ ifs=() { summary=`{cat $f/index.md | crop_text 512 ... | $formatter } }
+}
+updated = `{/bin/date --rfc-3339'=seconds' |sed 's/ /T/'}
+%}
+
+<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:thr="http://purl.org/syndication/thread/1.0">
+
+ <link rel="self" href="%($req_path%)"/>
+ <id>%($req_path%)</id>
+ <icon>/favicon.ico</icon>
+
+ <title>%($siteTitle%)</title>
+ <subtitle>%($siteSubTitle%)</subtitle>
+
+ <!-- <updated>2008-09-24T12:47:00-04:00</updated> -->
+ <updated>%($updated%)</updated>
+ <link href="."/>
+
+%{
+ for(f in `{get_post_list $blagh_root$blaghDirs}) {
+ statpost $f
+%}
+ <entry>
+ <!-- Maybe we should be smarter, see: http://diveintomark.org/archives…
+ <id>%($post_uri%)</id>
+ <link href="%($post_uri%)"/>
+ <title>%($title%)</title>
+ <!-- <link rel="replies" href="2899.atom" thr:count="0"/> -->
+ <author>
+ <name>%($by%)</name>
+ </author>
+
+
+ <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+ %($summary%)
+ </div></content>
+
+ <updated>%($updated%)</updated>
+ </entry>
+
+
+% }
+
+</feed>
+
+% exit
+
+<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:thr="http://purl.org/syndication/thread/1.0">
+ <link rel="self" href="http://intertwingly.net/blog/index.atom"/>
+ <id>http://intertwingly.net/blog/index.atom</id>
+ <icon>../favicon.ico</icon>
+
+ <title>Sam Ruby</title>
+ <subtitle>It’s just data</subtitle>
+ <author>
+ <name>Sam Ruby</name>
+ <email>[email protected]</email>
+ <uri>/blog/</uri>
+ </author>
+ <updated>2008-09-24T12:47:00-04:00</updated>
+ <link href="/blog/"/>
+ <link rel="license" href="http://creativecommons.org/licenses/BSD/"/>
+
+ <entry>
+ <id>tag:intertwingly.net,2004:2899</id>
+ <link href="/blog/2008/09/11/RubyConf-2008"/>
+ <link rel="replies" href="2899.atom" thr:count="0"/>
+ <title>RubyConf 2008</title>
+ <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+
+<p>My <a href="http://www.rubyconf.org/talks/14">proposal</a> has been accepte…
+<p>I had originally requested a slot on Saturday.  My current slot requires m…
+
+ </div></content>
+ <updated>2008-09-11T06:51:36-04:00</updated>
+ </entry>
+
+ <entry>
+ <id>tag:intertwingly.net,2004:2898</id>
+ <link href="/blog/2008/09/10/Small-Updates"/>
+ <link rel="replies" href="2898.atom" thr:count="8" thr:updated="2008-09-10…
+ <title>Small Updates</title>
+ <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+
+ <p><a href="http://hublog.hubmed.org/archives/001744.html">Alf Eaton</a>: …
+<p>I don’t know what publishing software you use, but I see you provide an A…
+
+ </div></summary>
+ <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+
+<p><a href="http://hublog.hubmed.org/archives/001744.html"><cite>Alf Eaton</ci…
+<p>I don’t know what publishing software you use, but I see you provide an A…
+<p>More specifically, if you have a minor update and leave the updated date al…
+
+ </div></content>
+ <updated>2008-09-10T10:18:47-04:00</updated>
+ </entry>
+
+ <entry>
+ <id>tag:intertwingly.net,2004:2897</id>
+ <link href="/blog/2008/09/07/SVG-via-CSS"/>
+ <link rel="replies" href="2897.atom" thr:count="10" thr:updated="2008-09-1…
+ <title>SVG via CSS</title>
+ <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+
+ <p>Now that I have my weblog looking reasonably consistent between Gecko a…
+<p>Frankly, my first reaction to this was mixed.  The pluses for SVG in CSS i…
+
+ </div></summary>
+
+ <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+
+<p>Now that I have my weblog looking reasonably consistent between Gecko and W…
+<p>Meanwhile, Robert O’Callahan has been exploring <a href="http://weblogs.m…
+
+ </div></content>
+ <updated>2008-09-07T11:12:29-04:00</updated>
+ </entry>
+
+</feed>
+
diff --git a/lib/_apps/blagh/rss20.tpl b/lib/_apps/blagh/rss20.tpl
@@ -0,0 +1,61 @@
+Content-Type: text/xml; charset=utf-8
+
+<?xml version="1.0" encoding="UTF-8"?>
+
+%{
+fn statpost {
+ f = $1
+ post_uri = `{echo $f | sed 's,^'$sitedir',,'}
+ title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
+ 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 $stat(1)} # Not used because it is unreliable
+ post_uri=$base_url^`{cleanname `{echo -n $post_uri | sed 's/\.(md|tpl)…
+ by=$stat(2)
+ ifs=() {
+ summary=`{awk -v max'='1024 '{
+ nc += 1 + length;
+ if(nc > max) {
+ print substr($0, 1, nc - max) "..."
+ exit
+ }
+ print
+ }' $f |fmt -j| sed 's/\]\]>/Fucking goddamn XML garbage/g'}
+ }
+}
+
+%}
+
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+ <channel>
+ <atom:link href="%('http://'$site^$req_path%)" rel="self" type…
+ <title>%($siteTitle%)</title>
+ <link>%($req_path%)</link>
+ <description>%($blogDesc%)</description>
+ <language>en-us</language>
+ <generator>Tom Duff's rc, and Kris Maglione's clever hackery</…
+%{
+ # <webMaster>[email protected] (Uriel)</webMaster>
+ for(f in `{sortedBlogPostList $blogDirs}) {
+ 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…
+ #if(~ $#last_build_date 0) {
+ #last_build_date='<lastBuildDate>'^$"mdate'</l…
+ #echo $last_build_date
+ #}
+%}
+ <item>
+ <title>%($title%)</title>
+ <author>%($by%)@noreply.cat-v.org (%($by%))</author>
+ <link>%($uri%)</link>
+ <guid isPermaLink="true">%($uri%)</guid>
+ <pubDate>%($date%)</pubDate>
+ <description><![CDATA[<pre>%($summary%)</pre>]]></desc…
+ </item>
+% }
+
+ </channel>
+</rss>
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.