2 # Standard ikiwiki setup module.
3 # Parameters to import should be all the standard ikiwiki config stuff,
4 # plus an array of wrappers to set up.
6 package IkiWiki::Setup::Standard;
13 IkiWiki::Setup::merge($_[1]);
16 sub dumpline ($$$$) { #{{{
22 eval q{use Data::Dumper};
24 local $Data::Dumper::Terse=1;
25 local $Data::Dumper::Indent=1;
26 local $Data::Dumper::Pad="\t";
27 local $Data::Dumper::Sortkeys=1;
28 local $Data::Dumper::Quotekeys=0;
31 if (($type eq 'boolean' || $type eq 'integer') && $value=~/^[0-9]+$/) {
35 elsif (ref $value eq 'ARRAY' && @$value && ! grep { /[^\S]/ } @$value) {
36 # dump simple array as qw{}
37 $dumpedvalue="[qw{".join(" ", @$value)."}]";
40 $dumpedvalue=Dumper($value);
43 # add to second and subsequent lines
44 my @lines=split(/\n/, $dumpedvalue);
46 for (my $x=0; $x <= $#lines; $x++) {
47 $lines[$x] =~ s/^\t//;
48 $dumpedvalue.="\t".($x ? $prefix : "").$lines[$x]."\n";
51 $dumpedvalue=~s/^\t//;
55 return "\t$prefix$key => $dumpedvalue,";
58 sub dumpvalues ($@) { #{{{
65 next if $key eq "plugin" || $info{type} eq "internal";
67 push @ret, "\t# ".$info{description} if exists $info{description};
69 if (exists $setup->{$key} && defined $setup->{$key}) {
70 push @ret, dumpline($key, $setup->{$key}, $info{type}, "");
71 delete $setup->{$key};
73 elsif (exists $info{example}) {
74 push @ret, dumpline($key, $info{example}, $info{type}, "#");
77 push @ret, dumpline($key, "", $info{type}, "#");
83 sub gendump ($) { #{{{
84 my $description=shift;
88 # disable logging to syslog while dumping
89 $config{syslog}=undef;
91 push @ret, dumpvalues(\%setup, IkiWiki::getsetup());
92 foreach my $pair (IkiWiki::Setup::getsetup()) {
93 my $plugin=$pair->[0];
95 my @values=dumpvalues(\%setup, @{$setup});
97 push @ret, "", "\t# $plugin plugin", @values;
105 "# Passing this to ikiwiki --setup will make ikiwiki generate",
106 "# wrappers and build the wiki.",
108 "# Remember to re-run ikiwiki --setup any time you edit this file.",
109 "use IkiWiki::Setup::Standard {";