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);
43 $dumpedvalue=~s/^\t//;
46 return "\t$prefix$key => $dumpedvalue,";
49 sub dumpvalues ($@) { #{{{
56 next if $info{type} eq "internal";
58 push @ret, "\t# ".$info{description} if exists $info{description};
60 if (exists $setup->{$key} && defined $setup->{$key}) {
61 push @ret, dumpline($key, $setup->{$key}, $info{type}, "");
62 delete $setup->{$key};
64 elsif (exists $info{default} && defined $info{default}) {
65 push @ret, dumpline($key, $info{default}, $info{type}, "#");
67 elsif (exists $info{example}) {
68 push @ret, dumpline($key, $info{example}, $info{type}, "#");
74 sub gendump ($) { #{{{
75 my $description=shift;
79 push @ret, "\t# basic setup";
80 push @ret, dumpvalues(\%setup, IkiWiki::getsetup());
82 # Load all plugins, so that all setup options are available.
83 my @plugins=grep { ! /externaldemo|pythondemo/ } sort(IkiWiki::listplugins());
84 foreach my $plugin (@plugins) {
85 eval { IkiWiki::loadplugin($plugin) };
86 if (exists $IkiWiki::hooks{checkconfig}{$plugin}{call}) {
87 my @s=eval { $IkiWiki::hooks{checkconfig}{$plugin}{call}->() };
90 unshift @plugins, $config{rcs} if $config{rcs};
92 foreach my $id (@plugins) {
93 my $title="\t# $id".($id ne $config{rcs} ? " plugin" : "");
94 if (exists $IkiWiki::hooks{getsetup}{$id}{call}) {
95 # use an array rather than a hash, to preserve order
96 my @s=eval { $IkiWiki::hooks{getsetup}{$id}{call}->() };
98 push @ret, "", $title;
99 push @ret, dumpvalues(\%setup, @s);
107 "# Passing this to ikiwiki --setup will make ikiwiki generate",
108 "# wrappers and build the wiki.",
110 "# Remember to re-run ikiwiki --setup any time you edit this file.",
111 "use IkiWiki::Setup::Standard {";