can now dump fully functional setup files
authorJoey Hess <joey@kodama.kitenet.net>
Sat, 26 Jul 2008 19:34:38 +0000 (15:34 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Sat, 26 Jul 2008 19:34:38 +0000 (15:34 -0400)
IkiWiki.pm
IkiWiki/Setup.pm
IkiWiki/Setup/Standard.pm
ikiwiki.in

index 7b6c4d622a34ab51fa5927cf3b9c7c4a459484ea..edbec77d62ed55f977f97c6f8b476d06c65c6676 100644 (file)
@@ -142,6 +142,27 @@ sub getsetup () { #{{{
                safe => 0, # paranoia
                rebuild => 0,
        },
+       wrappers => {
+               type => "string",
+               default => undef,
+               description => "definitions of wrappers to generate",
+               safe => 0,
+               rebuild => 0,
+       },
+       wrapper => {
+               type => "internal",
+               default => undef,
+               description => "wrapper filename",
+               safe => 0,
+               rebuild => 0,
+       },
+       wrappermode => {
+               type => "internal",
+               default => undef,
+               description => "mode of wrapper file",
+               safe => 0,
+               rebuild => 0,
+       },
        templatedir => {
                type => "string",
                default => "$installdir/share/ikiwiki/templates",
@@ -250,6 +271,14 @@ sub getsetup () { #{{{
                rebuild => 0,
        },
 
+       exclude => {
+               type => "string",
+               default => undef,
+               example => '\.wav$',
+               description => "regexp of source files to ignore",
+               safe => 0, # regexp
+               rebuild => 1,
+       },
        wiki_file_prune_regexps => {
                type => "internal",
                default => [qr/(^|\/)\.\.(\/|$)/, qr/^\./, qr/\/\./,
@@ -324,20 +353,6 @@ sub getsetup () { #{{{
                safe => 0,
                rebuild => 0,
        },
-       wrapper => {
-               type => "internal",
-               default => undef,
-               description => "wrapper file to generate",
-               safe => 0,
-               rebuild => 0,
-       },
-       wrappermode => {
-               type => "internal",
-               default => undef,
-               description => "mode of wrapper file",
-               safe => 0,
-               rebuild => 0,
-       },
        setup => {
                type => "internal",
                default => undef,
@@ -345,13 +360,27 @@ sub getsetup () { #{{{
                safe => 0,
                rebuild => 0,
        },
-       plugin => {
+       default_plugins => {
                type => "internal",
                default => [qw{mdwn link inline htmlscrubber passwordauth
                                openid signinedit lockedit conditional
                                recentchanges parentlinks}],
-               description => "enabled plugins",
-               safe => 0,
+               description => "plugins to enable by default",
+               safe => 1,
+               rebuild => 1,
+       },
+       add_plugins => {
+               type => "string",
+               default => [],
+               description => "plugins to add to the default configuration",
+               safe => 1,
+               rebuild => 1,
+       },
+       disable_plugins => {
+               type => "string",
+               default => [],
+               description => "plugins to disable",
+               safe => 1,
                rebuild => 1,
        },
        libdir => {
@@ -434,7 +463,7 @@ sub loadplugins () { #{{{
                unshift @INC, possibly_foolish_untaint($config{libdir});
        }
 
-       loadplugin($_) foreach @{$config{plugin}};
+       loadplugin($_) foreach @{$config{default_plugins}}, @{$config{add_plugins}};
 
        run_hooks(getopt => sub { shift->() });
        if (grep /^-/, @ARGV) {
index b67d1a45417149758f7b6ce2cfc882ba02ed51af..9c45a8baf30081d792abfcc70da8609e8fc1b437 100644 (file)
@@ -36,17 +36,15 @@ sub load ($) { # {{{
        $raw_setup=undef;
 
        # Merge setup into existing config and untaint.
-       $setup{plugin}=$config{plugin};
        if (exists $setup{add_plugins}) {
-               push @{$setup{plugin}}, @{$setup{add_plugins}};
-               delete $setup{add_plugins};
+               push @{$setup{add_plugins}}, @{$config{add_plugins}};
        }
        if (exists $setup{exclude}) {
                push @{$config{wiki_file_prune_regexps}}, $setup{exclude};
        }
        foreach my $c (keys %setup) {
                if (defined $setup{$c}) {
-                       if (! ref $setup{$c}) {
+                       if (! ref $setup{$c} || ref $setup{$c} eq 'Regexp') {
                                $config{$c}=IkiWiki::possibly_foolish_untaint($setup{$c});
                        }
                        elsif (ref $setup{$c} eq 'ARRAY') {
index d88dc9e1c266aada900195c0e9c33d0db5fd5fd5..ed4331d6143cc5086b6aa02b31144bad86aafa8a 100644 (file)
@@ -29,15 +29,21 @@ sub dumpline ($$$$) { #{{{
        
        my $dumpedvalue;
        if ($type eq 'boolean' || $type eq 'integer') {
+               # avoid quotes
                $dumpedvalue=$value;
        }
+       elsif ($type eq 'string' && ref $value eq 'ARRAY' && @$value &&
+           ! grep { /[^-A-Za-z0-9_]/ } @$value) {
+               # dump simple array as qw{}
+               $dumpedvalue="[qw{ ".join(" ", @$value)." }]";
+       }
        else {
                $dumpedvalue=Dumper($value);
                chomp $dumpedvalue;
                $dumpedvalue=~s/^\t//;
        }
        
-       return "\t$prefix$key=$dumpedvalue,";
+       return "\t$prefix$key => $dumpedvalue,";
 } #}}}
 
 sub dumpvalues ($@) { #{{{
index 70e44541c4a193d0a311270f348de95df78121bc..8cb8a476939a211a862cc2c185f64d783831dfdb 100755 (executable)
@@ -28,7 +28,7 @@ sub getconfig () { #{{{
                        "refresh!" => \$config{refresh},
                        "post-commit" => \$config{post_commit},
                        "render=s" => \$config{render},
-                       "wrappers!" => \$config{wrappers},
+                       "wrappers!" => \$config{genwrappers},
                        "usedirs!" => \$config{usedirs},
                        "prefix-directives!" => \$config{prefix_directives},
                        "getctime" => \$config{getctime},
@@ -68,7 +68,7 @@ sub getconfig () { #{{{
                                $config{wrappermode}=possibly_foolish_untaint($_[1])
                        },
                        "plugin=s@" => sub {
-                               push @{$config{plugin}}, $_[1];
+                               push @{$config{add_plugins}}, $_[1];
                        },
                        "disable-plugin=s@" => sub {
                                push @{$config{disable_plugins}}, $_[1];
@@ -112,13 +112,15 @@ sub main () { #{{{
        if ($config{setup}) {
                require IkiWiki::Setup;
                IkiWiki::Setup::load($config{setup});
-               if (! $config{render} && ! $config{dumpsetup} &&
-                   (! $config{refresh} || $config{wrappers})) {
+               if (@{$config{wrappers}} && 
+                   ! $config{render} && ! $config{dumpsetup} &&
+                   (! $config{refresh} || $config{genwrappers})) {
                        debug(gettext("generating wrappers.."));
                        require IkiWiki::Wrapper;
                        my %origconfig=(%config);
                        my @wrappers=@{$config{wrappers}};
                        delete $config{wrappers};
+                       delete $config{genwrappers};
                        foreach my $wrapper (@wrappers) {
                                %config=(%origconfig,
                                        rebuild => 0,