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::raw_setup=$_[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') {
35 elsif ($type eq 'string' && ref $value eq 'ARRAY' && @$value &&
36 ! grep { /[^-A-Za-z0-9_]/ } @$value) {
37 # dump simple array as qw{}
38 $dumpedvalue="[qw{ ".join(" ", @$value)." }]";
41 $dumpedvalue=Dumper($value);
44 # add to second and subsequent lines
45 my @lines=split(/\n/, $dumpedvalue);
47 for (my $x=0; $x <= $#lines; $x++) {
48 $lines[$x] =~ s/^\t//;
49 $dumpedvalue.="\t".($x ? $prefix : "").$lines[$x]."\n";
52 $dumpedvalue=~s/^\t//;
56 return "\t$prefix$key => $dumpedvalue,";
59 sub dumpvalues ($@) { #{{{
66 next if $info{type} eq "internal";
68 push @ret, "\t# ".$info{description} if exists $info{description};
70 if (exists $setup->{$key} && defined $setup->{$key}) {
71 push @ret, dumpline($key, $setup->{$key}, $info{type}, "");
72 delete $setup->{$key};
74 elsif (exists $info{example}) {
75 push @ret, dumpline($key, $info{example}, $info{type}, "#");
81 sub gendump ($) { #{{{
82 my $description=shift;
86 # disable logging to syslog while dumping
89 push @ret, "\t# basic setup";
90 push @ret, dumpvalues(\%setup, IkiWiki::getsetup());
92 # Load all plugins, so that all setup options are available.
93 # (But skip a few problematic external demo plugins.)
94 my @plugins=grep { ! /^(externaldemo|pythondemo|\Q$config{rcs}\E)$/ }
95 sort(IkiWiki::listplugins());
96 unshift @plugins, $config{rcs} if $config{rcs}; # rcs plugin 1st
97 foreach my $plugin (@plugins) {
98 eval { IkiWiki::loadplugin($plugin) };
99 if (exists $IkiWiki::hooks{checkconfig}{$plugin}{call}) {
100 my @s=eval { $IkiWiki::hooks{checkconfig}{$plugin}{call}->() };
104 foreach my $id (@plugins) {
105 if (exists $IkiWiki::hooks{getsetup}{$id}{call}) {
106 # use an array rather than a hash, to preserve order
107 my @s=eval { $IkiWiki::hooks{getsetup}{$id}{call}->() };
109 push @ret, "", "\t# $id plugin";
110 push @ret, dumpvalues(\%setup, @s);
118 "# Passing this to ikiwiki --setup will make ikiwiki generate",
119 "# wrappers and build the wiki.",
121 "# Remember to re-run ikiwiki --setup any time you edit this file.",
122 "use IkiWiki::Setup::Standard {";