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 ($$$) { #{{{
21 eval q{use Data::Dumper};
23 local $Data::Dumper::Terse=1;
24 local $Data::Dumper::Indent=1;
25 local $Data::Dumper::Pad="\t";
26 local $Data::Dumper::Sortkeys=1;
27 local $Data::Dumper::Quotekeys=0;
29 my $dumpedvalue=Dumper($value);
31 $dumpedvalue=~s/^\t//;
33 return "\t$prefix$key=$dumpedvalue,";
36 sub dumpvalues ($@) { #{{{
43 push @ret, "\t# ".$info{description} if exists $info{description};
45 if (exists $setup->{$key} && defined $setup->{$key}) {
46 push @ret, dumpline($key, $setup->{$key}, "");
47 delete $setup->{$key};
49 elsif (exists $info{default}) {
50 push @ret, dumpline($key, $info{default}, "#");
52 elsif (exists $info{example}) {
53 push @ret, dumpline($key, $info{example}, "#");
60 my $file=IkiWiki::possibly_foolish_untaint(shift);
65 foreach my $id (sort keys %{$IkiWiki::hooks{getsetup}}) {
66 # use an array rather than a hash, to preserve order
67 my @s=$IkiWiki::hooks{getsetup}{$id}{call}->();
69 push @ret, "\t# $id plugin";
70 push @ret, dumpvalues(\%setup, @s);
75 push @ret, "\t# other";
76 foreach my $key (sort keys %setup) {
77 push @ret, dumpline($key, $setup{$key}, "");
81 unshift @ret, "#!/usr/bin/perl
82 # Setup file for ikiwiki.
83 # Passing this to ikiwiki --setup will make ikiwiki generate wrappers and
86 # Remember to re-run ikiwiki --setup any time you edit this file.
88 use IkiWiki::Setup::Standard {";
91 open (OUT, ">", $file) || die "$file: $!";
92 print OUT "$_\n" foreach @ret;