swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit 7edbdf479153d1dc4e631f0f7732fdc23364e062
parent 820d33d22289533d84ae95c2ceb0d4fe094b0cb7
Author: uriel@suckless.org <unknown>
Date:   Fri,  6 Jun 2008 09:39:07 +0200

* s/formater/formatter/g
* Fix rss validator warnings
* Fix xhtml validator errors (properly close <link /> tag and remove align= attribute).
Diffstat:
Mbin/controller.rc | 32++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/bin/controller.rc b/bin/controller.rc @@ -8,8 +8,8 @@ ifs='/' { cd .. # default config -formater=markdown.pl -formater=md_cache # markdown cacher +formatter=markdown.pl +formatter=md_cache # markdown cacher site=$SERVER_NAME sitedir=sites/$site headers=inc/headers.tpl @@ -31,9 +31,11 @@ dirfilter = '/\/[._]/d; s,^\./,,; s,\.md$,,; s,\.html,,;' # Sidebar fn menu { lsArgs = ( '-F' ) - if (! ~ $#blogDirs 0) { + # XXX will not work properly for $#blogDirs > 1 and matching is hackish + if ( (!~ $#inBlog 0) || ! ~ $#blogDirs 0 && (~ $blogDirs^/ *$1 *$1/) ) { # Work in progress XXX lsArgs = ($lsArgs -r) } + ls $lsArgs $1 | sed $dirfilter | awk -F/ ' BEGIN { print "<ul class=\"sidebar\">" } END { print "</ul>" } @@ -88,8 +90,8 @@ fn blogTitle { fn genbody { if ( test -f $body.md ) { if ( ! ~ $#inBlog 0 ) - blogTitle $body.md | $formater - $formater < $body.md + blogTitle $body.md | $formatter + $formatter < $body.md } if not if ( test -f $body.tpl ) template.awk $body.tpl | rc $rcargs @@ -107,13 +109,15 @@ fn genbody { ls -F `{ basename -d $body } | sed -e $dirfilter' s,^'$sitedir'/.*/([^$].*),<li><a href="\1">\1</a></li>,' echo '</ul>' } - if not if(~ $#blogDirs 0) + if not if(~ $#blogDirs 0) { + #echo 'Status: 404 Not Found\n\n' # should go before starting to print body template.awk inc/404.tpl | rc $rcargs + } if(! ~ $#blogDirs 0) { if ( ! ~ $blogTitle '' ) echo '<h1>'$"blogTitle'</h1>' - echo '<div align="right">(<a href="index.rss">rss feed</a>)</div>' + echo '<div style="text-align:right">(<a href="index.rss">rss feed</a>)</div>' for ( f in `{ sortedBlogPostList $blogDirs } ) { #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } #du=`{ls -l $f} @@ -121,7 +125,7 @@ fn genbody { blogTitle $f cat $f echo - } | $formater + } | $formatter } } @@ -136,7 +140,7 @@ if (! ~ $args '') { } fpath=$sitedir -for ( i in '' $args ) { +for ( i in ('' $args) ) { fpath = $fpath/$i # We don't want blog settings to cascade into posts, note that we are inBlog instead if ( ! ~ $#blogDirs 0 && ! ~ $body */indexrss */[bB]log */[bB]log/ ) { @@ -167,7 +171,7 @@ if(! ~ $#blogDirs 0) { rssuri=`{basename -d $uri} rssuri=$baseuri`{cleanname $"rssuri^/index.rss} extraHeaders=$"extraHeaders ^ \ - '<link rel="alternate" type="application/rss+xml" title="RSS" href="'$rssuri'"> + '<link rel="alternate" type="application/rss+xml" title="RSS" href="'$rssuri'" /> ' } @@ -221,20 +225,21 @@ cat <<'!' | template Content-Type: text/xml; charset=utf-8 <?xml version="1.0" encoding="UTF-8"?> -<rss version="2.0"> +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> + <atom:link href="%('http://'$site^$REQUEST_URI%)" rel="self" type="application/rss+xml" /> <title>%($siteTitle%)</title> <link>%($uri%)</link> <description>%($blogDesc%)</description> <language>en-us</language> <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator> - <webMaster>Uriel Mangado &lt;uriel99@gmail.com&gt;</webMaster> + <webMaster>uriel99+rss@gmail.com (Uriel)</webMaster> %{ for(f in `{sortedBlogPostList $blogDirs}) { statpost $f %} <item> <title>%($title%)</title> - <author>%($by%)@noreply.cat-v.org</author> + <author>%($by%)@noreply.cat-v.org (%($by%))</author> <link>%($uri%)</link> <guid isPermaLink="true">%($uri%)</guid> <pubDate>%($date%)</pubDate> @@ -244,4 +249,3 @@ Content-Type: text/xml; charset=utf-8 </channel> </rss> ! -