]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki.pm
add news item for ikiwiki 2.64
[git.ikiwiki.info.git] / IkiWiki.pm
index 2139aa7d13b775f1fa60f60f02c995732fe216b9..4e4da11c5a016daa9d04c0b6ee04df7f786a14a7 100644 (file)
@@ -41,6 +41,28 @@ sub getsetup () { #{{{
                safe => 1,
                rebuild => 1,
        },
                safe => 1,
                rebuild => 1,
        },
+       adminemail => {
+               type => "string",
+               default => undef,
+               example => 'me@example.com',
+               description => "contact email for wiki",
+               safe => 1,
+               rebuild => 0,
+       },
+       adminuser => {
+               type => "string",
+               default => [],
+               description => "users who are wiki admins",
+               safe => 1,
+               rebuild => 0,
+       },
+       banned_users => {
+               type => "string",
+               default => [],
+               description => "users who are banned from the wiki",
+               safe => 1,
+               rebuild => 0,
+       },
        srcdir => {
                type => "string",
                default => undef,
        srcdir => {
                type => "string",
                default => undef,
@@ -57,21 +79,6 @@ sub getsetup () { #{{{
                safe => 0, # path
                rebuild => 1,
        },
                safe => 0, # path
                rebuild => 1,
        },
-       adminuser => {
-               type => "string",
-               default => [],
-               description => "user names of wiki admins",
-               safe => 1,
-               rebuild => 0,
-       },
-       adminemail => {
-               type => "string",
-               default => undef,
-               example => 'me@example.com',
-               description => "contact email for wiki",
-               safe => 1,
-               rebuild => 0,
-       },
        url => {
                type => "string",
                default => '',
        url => {
                type => "string",
                default => '',
@@ -114,7 +121,7 @@ sub getsetup () { #{{{
                type => "internal",
                default => [qw{mdwn link inline htmlscrubber passwordauth
                                openid signinedit lockedit conditional
                type => "internal",
                default => [qw{mdwn link inline htmlscrubber passwordauth
                                openid signinedit lockedit conditional
-                               recentchanges parentlinks}],
+                               recentchanges parentlinks editpage}],
                description => "plugins to enable by default",
                safe => 0,
                rebuild => 1,
                description => "plugins to enable by default",
                safe => 0,
                rebuild => 1,
@@ -165,14 +172,14 @@ sub getsetup () { #{{{
        },
        verbose => {
                type => "boolean",
        },
        verbose => {
                type => "boolean",
-               default => 0,
+               example => 1,
                description => "display verbose messages when building?",
                safe => 1,
                rebuild => 0,
        },
        syslog => {
                type => "boolean",
                description => "display verbose messages when building?",
                safe => 1,
                rebuild => 0,
        },
        syslog => {
                type => "boolean",
-               default => 0,
+               example => 1,
                description => "log to syslog?",
                safe => 1,
                rebuild => 0,
                description => "log to syslog?",
                safe => 1,
                rebuild => 0,
@@ -198,6 +205,14 @@ sub getsetup () { #{{{
                safe => 1,
                rebuild => 1,
        },
                safe => 1,
                rebuild => 1,
        },
+       sslcookie => {
+               type => "boolean",
+               default => 0,
+               description => "only send cookies over SSL connections?",
+               advanced => 1,
+               safe => 1,
+               rebuild => 0,
+       },
        default_pageext => {
                type => "string",
                default => "mdwn",
        default_pageext => {
                type => "string",
                default => "mdwn",
@@ -229,14 +244,6 @@ sub getsetup () { #{{{
                safe => 0,
                rebuild => 1,
        },
                safe => 0,
                rebuild => 1,
        },
-       sslcookie => {
-               type => "boolean",
-               default => 0,
-               description => "only send cookies over SSL connections?",
-               advanced => 1,
-               safe => 1,
-               rebuild => 0,
-       },
        userdir => {
                type => "string",
                default => "",
        userdir => {
                type => "string",
                default => "",
@@ -294,13 +301,6 @@ sub getsetup () { #{{{
                safe => 0, # regexp
                rebuild => 1,
        },
                safe => 0, # regexp
                rebuild => 1,
        },
-       banned_users => {
-               type => "string",
-               default => [],
-               description => "users who are banned from the wiki",
-               safe => 1,
-               rebuild => 0,
-       },
        wiki_file_prune_regexps => {
                type => "internal",
                default => [qr/(^|\/)\.\.(\/|$)/, qr/^\./, qr/\/\./,
        wiki_file_prune_regexps => {
                type => "internal",
                default => [qr/(^|\/)\.\.(\/|$)/, qr/^\./, qr/\/\./,
@@ -312,9 +312,15 @@ sub getsetup () { #{{{
                safe => 0,
                rebuild => 1,
        },
                safe => 0,
                rebuild => 1,
        },
+       wiki_file_chars => {
+               type => "string",
+               description => "specifies the characters that are allowed in source filenames",
+               default => "-[:alnum:]+/.:_",
+               safe => 0,
+               rebuild => 1,
+       },
        wiki_file_regexp => {
                type => "internal",
        wiki_file_regexp => {
                type => "internal",
-               default => qr/(^[-[:alnum:]_.:\/+]+$)/,
                description => "regexp of legal source files",
                safe => 0,
                rebuild => 1,
                description => "regexp of legal source files",
                safe => 0,
                rebuild => 1,
@@ -354,6 +360,13 @@ sub getsetup () { #{{{
                safe => 0,
                rebuild => 0,
        },
                safe => 0,
                rebuild => 0,
        },
+       setup => {
+               type => "internal",
+               default => undef,
+               description => "running in setup mode",
+               safe => 0,
+               rebuild => 0,
+       },
        refresh => {
                type => "internal",
                default => 0,
        refresh => {
                type => "internal",
                default => 0,
@@ -375,10 +388,17 @@ sub getsetup () { #{{{
                safe => 0,
                rebuild => 0,
        },
                safe => 0,
                rebuild => 0,
        },
-       setup => {
+       setupfile => {
                type => "internal",
                default => undef,
                type => "internal",
                default => undef,
-               description => "setup file to read",
+               description => "path to setup file",
+               safe => 0,
+               rebuild => 0,
+       },
+       allow_symlinks_before_srcdir => {
+               type => "string",
+               default => 0,
+               description => "allow symlinks in the path leading to the srcdir (potentially insecure)",
                safe => 0,
                rebuild => 0,
        },
                safe => 0,
                rebuild => 0,
        },
@@ -406,6 +426,10 @@ sub checkconfig () { #{{{
                        $gettext_obj=undef;
                }
        }
                        $gettext_obj=undef;
                }
        }
+               
+       if (! defined $config{wiki_file_regexp}) {
+               $config{wiki_file_regexp}=qr/(^[$config{wiki_file_chars}]+$)/;
+       }
 
        if (ref $config{ENV} eq 'HASH') {
                foreach my $val (keys %{$config{ENV}}) {
 
        if (ref $config{ENV} eq 'HASH') {
                foreach my $val (keys %{$config{ENV}}) {
@@ -464,7 +488,9 @@ sub loadplugins () { #{{{
                unshift @INC, possibly_foolish_untaint($config{libdir});
        }
 
                unshift @INC, possibly_foolish_untaint($config{libdir});
        }
 
-       loadplugin($_) foreach @{$config{default_plugins}}, @{$config{add_plugins}};
+       foreach my $plugin (@{$config{default_plugins}}, @{$config{add_plugins}}) {
+               loadplugin($plugin);
+       }
        
        if ($config{rcs}) {
                if (exists $IkiWiki::hooks{rcs}) {
        
        if ($config{rcs}) {
                if (exists $IkiWiki::hooks{rcs}) {
@@ -494,7 +520,11 @@ sub loadplugin ($) { #{{{
        foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef,
                         "$installdir/lib/ikiwiki") {
                if (defined $dir && -x "$dir/plugins/$plugin") {
        foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef,
                         "$installdir/lib/ikiwiki") {
                if (defined $dir && -x "$dir/plugins/$plugin") {
-                       require IkiWiki::Plugin::external;
+                       eval { require IkiWiki::Plugin::external };
+                       if ($@) {
+                               my $reason=$@;
+                               error(sprintf(gettext("failed to load external plugin needed for %s plugin: %s"), $plugin, $reason));
+                       }
                        import IkiWiki::Plugin::external "$dir/plugins/$plugin";
                        $loaded_plugins{$plugin}=1;
                        return 1;
                        import IkiWiki::Plugin::external "$dir/plugins/$plugin";
                        $loaded_plugins{$plugin}=1;
                        return 1;
@@ -761,7 +791,7 @@ sub bestlink ($$) { #{{{
                elsif (exists $pagecase{lc $l}) {
                        return $pagecase{lc $l};
                }
                elsif (exists $pagecase{lc $l}) {
                        return $pagecase{lc $l};
                }
-       } while $cwd=~s!/?[^/]+$!!;
+       } while $cwd=~s{/?[^/]+$}{};
 
        if (length $config{userdir}) {
                my $l = "$config{userdir}/".lc($link);
 
        if (length $config{userdir}) {
                my $l = "$config{userdir}/".lc($link);
@@ -799,13 +829,16 @@ sub pagetitle ($;$) { #{{{
 
 sub titlepage ($) { #{{{
        my $title=shift;
 
 sub titlepage ($) { #{{{
        my $title=shift;
-       $title=~s/([^-[:alnum:]:+\/.])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
+       # support use w/o %config set
+       my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
+       $title=~s/([^$chars]|_)/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
        return $title;
 } #}}}
 
 sub linkpage ($) { #{{{
        my $link=shift;
        return $title;
 } #}}}
 
 sub linkpage ($) { #{{{
        my $link=shift;
-       $link=~s/([^-[:alnum:]:+\/._])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
+       my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
+       $link=~s/([^$chars])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
        return $link;
 } #}}}
 
        return $link;
 } #}}}
 
@@ -1043,6 +1076,8 @@ sub preprocess ($$$;$$) { #{{{
                my $prefix=shift;
                my $command=shift;
                my $params=shift;
                my $prefix=shift;
                my $command=shift;
                my $params=shift;
+               $params="" if ! defined $params;
+
                if (length $escape) {
                        return "[[$prefix$command $params]]";
                }
                if (length $escape) {
                        return "[[$prefix$command $params]]";
                }