commit dff8656682f4f918e5e1667ca328dd223533b24c
parent 9cce0f2f451fad74bcab7eb11da7bb42d26d2826
Author: uriel@soma <unknown>
Date: Mon, 16 Feb 2009 03:46:21 +0000
Move comments display to a template. Show a link to login page when required for posting comments.
Diffstat:
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/apps/bridge/app.rc b/apps/bridge/app.rc
@@ -13,18 +13,21 @@ fn conf_enable_comments {
fn bridge_init {
if(~ $#enable_comments 1) {
- cdir=$sitedir$req_path'_werc/comments'
- if(test -d $cdir)
- ll_add handlers_body_foot display_comments $cdir
+ comments_dir=$sitedir$req_path'_werc/comments'
+ if(test -d $comments_dir)
+ ll_add handlers_body_foot template apps/bridge/comments_list.tpl
if({ check_user $groups_allowed_comments || {~ $#logged_user 0 && ! ~ $#allow_new_user_comments 0} } && ! ~ `{ls $local_path.$comment_file_types >[2]/dev/null|wc -l} 0) {
ll_add handlers_body_foot template apps/bridge/foot.tpl
- if(~ $REQUEST_METHOD POST && mk_new_comment $cdir)
+ if(~ $REQUEST_METHOD POST && mk_new_comment $comments_dir)
post_redirect $base_url^$post_arg_document_uri
if not
saved_comment_text=$post_arg_comment_text
}
+ if not
+ ll_add handlers_body_foot echo '<p>To post a comment you need to <a href="/_users/login">login</a> first.'
+
}
}
@@ -53,7 +56,7 @@ fn mk_new_comment {
if(! ~ $#allow_new_user_comments 0) {
if(validate_new_user $"post_arg_comment_user $post_arg_comment_passwd $post_arg_comment_passwd2) {
u=$post_arg_comment_user':'$post_arg_comment_passwd
- dir=$cdir^'_pending'
+ dir=$comments_dir^'_pending'
# XXX: This doesn't work because we then do a redirect.
notify_notes='Saved comment and registration info, they will be enabled when approved by an admin.'
}
@@ -85,15 +88,3 @@ fn mk_new_comment {
notify_errors=$_status
status=$_status
}
-
-fn display_comments {
- echo '<hr /><h2>Comments</h2>'
-
- for(c in `{ls $*/}) {
- if(test -s $c/body) {
- ifs=() { echo '<div class="comment"><h5>By: <i>'`{cat $c/user}'</i></b> ('`{cat $c/posted}')</h5>'}
- cat $c/body | escape_html | sed 's,$,<br />,'
- echo '<hr /></div>'
- }
- }
-}
diff --git a/apps/bridge/comments_list.tpl b/apps/bridge/comments_list.tpl
@@ -0,0 +1,13 @@
+<hr />
+<h2>Comments</h2>
+
+% for(c in `{ls $comments_dir/}) {
+% if(test -s $c/body) {
+ <div class="comment">
+ <h5>By: <i>%(`{cat $c/user}%)</i></b> (%(`{cat $c/posted}%))
+ </h5>
+% cat $c/body | escape_html | sed 's,$,<br />,'
+ <hr /></div>
+% }
+% }
+