]> sipb.mit.edu Git - ikiwiki.git/commitdiff
smcvpostcomment: allow commenting to be closed
authorSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Mon, 17 Nov 2008 10:42:01 +0000 (10:42 +0000)
committerSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Thu, 11 Dec 2008 21:14:02 +0000 (21:14 +0000)
IkiWiki/Plugin/smcvpostcomment.pm

index 40ffe816425722d89852bf37ee59479dbfe398f5..22958c84aa900f40c28e99da4901c2e0c095ac49 100644 (file)
@@ -48,7 +48,9 @@ sub preprocess (@) { #{{{
        }
 
        my $page = $params{page};
-       $pagestate{$page}{PLUGIN()}{comments} = 1;
+       $pagestate{$page}{PLUGIN()}{comments} = defined $params{closed}
+               ? (not IkiWiki::yesno($params{closed}))
+               : 1;
        $pagestate{$page}{PLUGIN()}{allowhtml} = IkiWiki::yesno($params{allowhtml});
        $pagestate{$page}{PLUGIN()}{allowdirectives} = IkiWiki::yesno($params{allowdirectives});
        $pagestate{$page}{PLUGIN()}{commit} = defined $params{commit}
@@ -60,7 +62,11 @@ sub preprocess (@) { #{{{
        $formtemplate->param(cgiurl => $config{cgiurl});
        $formtemplate->param(page => $params{page});
 
-       if ($params{preview}) {
+       if (not $pagestate{$page}{PLUGIN()}{comments}) {
+               $formtemplate->param("disabled" =>
+                       gettext('comments are closed'));
+       }
+       elsif ($params{preview}) {
                $formtemplate->param("disabled" =>
                        gettext('not available during Preview'));
        }