]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/comments.pm
fix default values for config settings
[ikiwiki.git] / IkiWiki / Plugin / comments.pm
index 1eb256da9bc5ec3e198025fa81c3ffe3b3c65dfb..83f67869c06b6d68b58050373ea3e26b9dd9aa00 100644 (file)
@@ -17,7 +17,7 @@ use constant CANCEL => "Cancel";
 
 my $postcomment;
 
-sub import { #{{{
+sub import {
        hook(type => "checkconfig", id => 'comments',  call => \&checkconfig);
        hook(type => "getsetup", id => 'comments',  call => \&getsetup);
        hook(type => "preprocess", id => '_comment', call => \&preprocess);
@@ -26,9 +26,9 @@ sub import { #{{{
        hook(type => "pagetemplate", id => "comments", call => \&pagetemplate);
        hook(type => "cgi", id => "comments", call => \&linkcgi);
        IkiWiki::loadplugin("inline");
-} # }}}
+}
 
-sub getsetup () { #{{{
+sub getsetup () {
        return
                plugin => {
                        safe => 1,
@@ -39,7 +39,6 @@ sub getsetup () { #{{{
                comments_shown_pagespec => {
                        type => 'pagespec',
                        example => 'blog/*',
-                       default => '',
                        description => 'PageSpec for pages where comments will be shown inline',
                        link => 'ikiwiki/PageSpec',
                        safe => 1,
@@ -48,7 +47,6 @@ sub getsetup () { #{{{
                comments_open_pagespec => {
                        type => 'pagespec',
                        example => 'blog/* and created_after(close_old_comments)',
-                       default => '',
                        description => 'PageSpec for pages where new comments can be posted',
                        link => 'ikiwiki/PageSpec',
                        safe => 1,
@@ -56,7 +54,6 @@ sub getsetup () { #{{{
                },
                comments_pagename => {
                        type => 'string',
-                       example => 'comment_',
                        default => 'comment_',
                        description => 'Base name for comments, e.g. "comment_" for pages like "sandbox/comment_12"',
                        safe => 0, # manual page moving required
@@ -64,7 +61,6 @@ sub getsetup () { #{{{
                },
                comments_allowdirectives => {
                        type => 'boolean',
-                       default => 0,
                        example => 0,
                        description => 'Interpret directives in comments?',
                        safe => 1,
@@ -72,7 +68,6 @@ sub getsetup () { #{{{
                },
                comments_allowauthor => {
                        type => 'boolean',
-                       default => 0,
                        example => 0,
                        description => 'Allow anonymous commenters to set an author name?',
                        safe => 1,
@@ -81,22 +76,32 @@ sub getsetup () { #{{{
                comments_commit => {
                        type => 'boolean',
                        example => 1,
-                       default => 1,
                        description => 'commit comments to the VCS',
                        # old uncommitted comments are likely to cause
                        # confusion if this is changed
                        safe => 0,
                        rebuild => 0,
                },
-} #}}}
+}
+
+sub checkconfig () {
+       $config{comments_commit} = 1
+               unless defined $config{comments_commit};
+       $config{comments_shown_pagespec} = ''
+               unless defined $config{comments_shown_pagespec};
+       $config{comments_open_pagespec} = ''
+               unless defined $config{comments_open_pagespec};
+       $config{comments_pagename} = 'comment_'
+               unless defined $config{comments_pagename};
+}
 
-sub htmlize { # {{{
+sub htmlize {
        my %params = @_;
        return $params{content};
-} # }}}
+}
 
 # FIXME: copied verbatim from meta
-sub safeurl ($) { #{{{
+sub safeurl ($) {
        my $url=shift;
        if (exists $IkiWiki::Plugin::htmlscrubber::{safe_url_regexp} &&
            defined $IkiWiki::Plugin::htmlscrubber::safe_url_regexp) {
@@ -105,9 +110,9 @@ sub safeurl ($) { #{{{
        else {
                return 1;
        }
-} #}}}
+}
 
-sub preprocess { # {{{
+sub preprocess {
        my %params = @_;
        my $page = $params{page};
 
@@ -206,16 +211,10 @@ sub preprocess { # {{{
        # FIXME: hard-coded HTML (although it's just to set an ID)
        return "<div id=\"$anchor\">$content</div>" if $anchor;
        return $content;
-} # }}}
-
-sub checkconfig () { #{{{
-       $config{comments_commit} = 1 unless defined $config{comments_commit};
-       $config{comments_pagename} = 'comment_'
-               unless defined $config{comments_pagename};
-} #}}}
+}
 
 # This is exactly the same as recentchanges_link :-(
-sub linkcgi ($) { #{{{
+sub linkcgi ($) {
        my $cgi=shift;
        if (defined $cgi->param('do') && $cgi->param('do') eq "commenter") {
 
@@ -245,7 +244,7 @@ sub linkcgi ($) { #{{{
 
 # FIXME: basically the same logic as recentchanges
 # returns (author URL, pretty-printed version)
-sub linkuser ($) { # {{{
+sub linkuser ($) {
        my $user = shift;
        my $oiduser = eval { IkiWiki::openiduser($user) };
 
@@ -262,10 +261,10 @@ sub linkuser ($) { # {{{
                                        : "$user")
                        ), $user);
        }
-} # }}}
+}
 
 # Mostly cargo-culted from IkiWiki::plugin::editpage
-sub sessioncgi ($$) { #{{{
+sub sessioncgi ($$) {
        my $cgi=shift;
        my $session=shift;
 
@@ -468,7 +467,7 @@ sub sessioncgi ($$) { #{{{
        if ($form->submitted eq POST_COMMENT && $form->validate) {
                my $file = "$location._comment";
 
-               IkiWiki::checksessionexpiry($session, $cgi->param('sid'));
+               IkiWiki::checksessionexpiry($cgi, $session);
 
                # FIXME: could probably do some sort of graceful retry
                # on error? Would require significant unwinding though
@@ -512,9 +511,9 @@ sub sessioncgi ($$) { #{{{
        }
 
        exit;
-} #}}}
+}
 
-sub pagetemplate (@) { #{{{
+sub pagetemplate (@) {
        my %params = @_;
 
        my $page = $params{page};
@@ -583,7 +582,7 @@ sub pagetemplate (@) { #{{{
                $template->param(commentauthorurl =>
                        $pagestate{$page}{comments}{commentauthorurl});
        }
-} # }}}
+}
 
 package IkiWiki::PageSpec;