swerc

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

commit 1593675967bded6a056cb7edae7e86a67e230828
parent 985d99c6b829b906f951422659f4e918eb2fab4c
Author: uriel@engel.se.cat-v.org <unknown>
Date:   Sat, 18 Oct 2008 03:32:13 +0200

Replace blog_dir_handler with a template in lib/feeds/html.tpl
Diffstat:
Mbin/controller.rc | 17+----------------
Alib/feeds/html.tpl | 22++++++++++++++++++++++
2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/bin/controller.rc b/bin/controller.rc @@ -123,21 +123,6 @@ fn dir_listing_handler { fn 404_handler { template `{ get_lib_file 404.tpl } } -fn blog_dir_handler { - blogDirs = $* - - if (! ~ $blogTitle '') - echo '<h1>'$"blogTitle'</h1>' - - echo '<div style="text-align:right">(<a href="index.rss">rss feed</a>)</div>' - - for (f in `{ sortedBlogPostList $blogDirs }) { - gen_blog_post_title $f - cat $f - echo - } | $formatter -} - fn blog_post_handler { gen_blog_post_title $1 | $formatter $formatter < $1 @@ -203,7 +188,7 @@ fn select_handler { extraHeaders=$"extraHeaders ^ \ '<link rel="alternate" type="application/rss+xml" title="RSS" href="'$rssuri'" /> ' - set_handler blog_dir_handler $blogDirs + set_handler tpl_handler lib/feeds/html.tpl } # Global tpl (eg sitemap.tpl) diff --git a/lib/feeds/html.tpl b/lib/feeds/html.tpl @@ -0,0 +1,22 @@ +% if (! ~ $blogTitle '') +% echo '<h1>'$"blogTitle'</h1>' + +<div style="text-align:right">(<a href="index.rss">rss feed</a>)</div> + +%{ +for (f in `{ sortedBlogPostList $blogDirs }) { + gen_blog_post_title $f + cat $f + echo +} | $formatter + +# TODO Should check if user has perms and so on +get_user +if(~ $#logged_user 1) { +%} +<form method="POST" action="/_apps/blog/post_form"> +% echo '<input type="text" name="target_blog_dir" value="'^$blogDirs(1)^'" />' + <input type="submit" name="Submit" value="New post" /> +</form> +% } +<hr />