]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/comments.pm
fix previous buggy merge
[git.ikiwiki.info.git] / IkiWiki / Plugin / comments.pm
index 3a0465dbb833fd0485d133bb39ee3ebc1daebf46..833bedf25dcbad59a6f1dc3faed0f5c764b03db9 100644 (file)
@@ -343,8 +343,6 @@ sub sessioncgi ($$) {
                error(gettext("bad page name"));
        }
 
                error(gettext("bad page name"));
        }
 
-       # FIXME: is this right? Or should we be using the candidate subpage
-       # (whatever that might mean) as the base URL?
        my $baseurl = urlto($page, undef, 1);
 
        $form->title(sprintf(gettext("commenting on %s"),
        my $baseurl = urlto($page, undef, 1);
 
        $form->title(sprintf(gettext("commenting on %s"),
@@ -469,9 +467,21 @@ sub sessioncgi ($$) {
        }
 
        if ($form->submitted eq POST_COMMENT && $form->validate) {
        }
 
        if ($form->submitted eq POST_COMMENT && $form->validate) {
-               my $file = "$location._comment";
-
                IkiWiki::checksessionexpiry($cgi, $session);
                IkiWiki::checksessionexpiry($cgi, $session);
+               
+               $postcomment=1;
+               IkiWiki::check_content(content => $form->field('editcontent'),
+                       subject => $form->field('subject'),
+                       $config{comments_allowauthor} ? (
+                               author => $form->field('author'),
+                               url => $form->field('url'),
+                       ) : (),
+                       page => $location,
+                       cgi => $cgi, session => $session
+               );
+               $postcomment=0;
+               
+               my $file = "$location._comment";
 
                # FIXME: could probably do some sort of graceful retry
                # on error? Would require significant unwinding though
 
                # FIXME: could probably do some sort of graceful retry
                # on error? Would require significant unwinding though
@@ -604,6 +614,12 @@ sub pagetemplate (@) {
                }
        }
 
                }
        }
 
+       # everything below this point is only relevant to the comments
+       # themselves
+       if (!exists $commentstate{$page}) {
+               return;
+       }
+
        if ($template->query(name => 'commentuser')) {
                $template->param(commentuser =>
                        $commentstate{$page}{commentuser});
        if ($template->query(name => 'commentuser')) {
                $template->param(commentuser =>
                        $commentstate{$page}{commentuser});
@@ -628,6 +644,14 @@ sub pagetemplate (@) {
                $template->param(commentauthorurl =>
                        $commentstate{$page}{commentauthorurl});
        }
                $template->param(commentauthorurl =>
                        $commentstate{$page}{commentauthorurl});
        }
+
+       if ($template->query(name => 'removeurl') &&
+           IkiWiki::Plugin::remove->can("check_canremove") &&
+           length $config{cgiurl}) {
+               $template->param(removeurl => IkiWiki::cgiurl(do => 'remove',
+                       page => $page));
+               $template->param(have_actions => 1);
+       }
 }
 
 package IkiWiki::PageSpec;
 }
 
 package IkiWiki::PageSpec;