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;
12 $IkiWiki::Setup::raw_setup=$_[1];
15 sub dumpline ($$$) { #{{{
20 my $dumpedvalue=Dumper($value);
22 $dumpedvalue=~s/^\t//;
24 return "\t$prefix$key=$dumpedvalue,";
27 sub dumpsetup ($@) { #{{{
34 push @ret, "\t# ".$info{description} if exists $info{description};
36 if (exists $setup->{$key} && defined $setup->{$key}) {
37 push @ret, dumpline($key, $setup->{$key}, "");
38 delete $setup->{$key};
40 elsif (exists $info{default}) {
41 push @ret, dumpline($key, $info{default}, "#");
43 elsif (exists $info{example}) {
44 push @ret, dumpline($key, $info{example}, "#");
53 eval q{use Data::Dumper};
55 local $Data::Dumper::Terse=1;
56 local $Data::Dumper::Indent=1;
57 local $Data::Dumper::Pad="\t";
58 local $Data::Dumper::Sortkeys=1;
59 local $Data::Dumper::Quotekeys=0;
62 foreach my $id (sort keys %{$IkiWiki::hooks{getsetup}}) {
63 # use an array rather than a hash, to preserve order
64 my @s=$IkiWiki::hooks{getsetup}{$id}{call}->();
66 push @ret, "\t# $id plugin";
67 push @ret, dumpsetup(\%setup, @s);
72 push @ret, "\t# other";
73 foreach my $key (sort keys %setup) {
74 push @ret, dumpline($key, $setup{$key}, "");
78 unshift @ret, "#!/usr/bin/perl
79 # Setup file for ikiwiki.
80 # Passing this to ikiwiki --setup will make ikiwiki generate wrappers and
83 # Remember to re-run ikiwiki --setup any time you edit this file.
85 use IkiWiki::Setup::Standard {";