ref: 00991322acf5d66250a0db1fa578fa301c021b40
parent: 3f89cfc159a24f1851b572c29410a07fe32b7b4a
author: uriel <[email protected]>
date: Fri Oct 17 23:32:13 EDT 2008
Replace blog_dir_handler with a template in lib/feeds/html.tpl
--- a/bin/controller.rc
+++ b/bin/controller.rc
@@ -123,21 +123,6 @@
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 @@
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)
--- /dev/null
+++ b/lib/feeds/html.tpl
@@ -1,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 />