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 package IkiWiki::Setup;
17 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;
30 my $dumpedvalue=Dumper($value);
32 $dumpedvalue=~s/^\t//;
34 return "\t$prefix$key=$dumpedvalue,";
37 sub dumpvalues ($@) { #{{{
44 push @ret, "\t# ".$info{description} if exists $info{description};
46 if (exists $setup->{$key} && defined $setup->{$key}) {
47 push @ret, dumpline($key, $setup->{$key}, "");
48 delete $setup->{$key};
50 elsif (exists $info{default}) {
51 push @ret, dumpline($key, $info{default}, "#");
53 elsif (exists $info{example}) {
54 push @ret, dumpline($key, $info{example}, "#");
66 foreach my $id (sort keys %{$IkiWiki::hooks{getsetup}}) {
67 # use an array rather than a hash, to preserve order
68 my @s=$IkiWiki::hooks{getsetup}{$id}{call}->();
70 push @ret, "\t# $id plugin";
71 push @ret, dumpvalues(\%setup, @s);
76 push @ret, "\t# other";
77 foreach my $key (sort keys %setup) {
78 push @ret, dumpline($key, $setup{$key}, "");
82 unshift @ret, "#!/usr/bin/perl
83 # Setup file for ikiwiki.
84 # Passing this to ikiwiki --setup will make ikiwiki generate wrappers and
87 # Remember to re-run ikiwiki --setup any time you edit this file.
89 use IkiWiki::Setup::Standard {";
92 open (OUT, ">", $file) || die "$file: $!";
93 print OUT "$_\n" foreach @ret;