]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Setup/Standard.pm
improve formatting
[ikiwiki.git] / IkiWiki / Setup / Standard.pm
index b26df006b9d3e1d0ae58249ed4417f0f3c9f3746..dd9368986af9d7647df70dcb115142a0fe9a194c 100644 (file)
@@ -1,54 +1,68 @@
 #!/usr/bin/perl
 # Standard ikiwiki setup module.
 # Parameters to import should be all the standard ikiwiki config stuff,
-# plus hashes for cgiwrapper and svnwrapper, which specify any differing
-# config stuff for them and cause the wrappers to be made.
+# plus an array of wrappers to set up.
+
+package IkiWiki::Setup::Standard;
 
 use warnings;
 use strict;
-use IkiWiki::Wrapper;
-use IkiWiki::Render;
 
-package IkiWiki::Setup::Standard;
+sub import { #{{{
+       $IkiWiki::Setup::raw_setup=$_[1];
+} #}}}
+
+sub generate (@) { #{{{
+       my %setup=@_;
+
+       eval q{use Data::Dumper};
+       error($@) if $@;
+       local $Data::Dumper::Terse=1;
+       local $Data::Dumper::Sortkeys=1;
+       local $Data::Dumper::Pad="\t";
+
+       my @ret="#!/usr/bin/perl
+# Setup file for ikiwiki.
+# Passing this to ikiwiki --setup will make ikiwiki generate wrappers and
+# build the wiki.
+#
+# Remember to re-run ikiwiki --setup any time you edit this file.
+
+use IkiWiki::Setup::Standard {";
 
-sub import {
-       IkiWiki::setup_standard(@_);
-}
+       foreach my $id (sort keys %{$IkiWiki::hooks{getsetup}}) {
+               my @setup=$IkiWiki::hooks{getsetup}{$id}{call}->();
+               return unless @setup;
+               push @ret, "\t# $id plugin";
+               while (@setup) {
+                       my $key=shift @setup;
+                       my %info=%{shift @setup};
        
-package IkiWiki;
-
-sub setup_standard {
-       my %setup=%{$_[1]};
-
-       if (! $config{refresh}) {
-               debug("generating wrappers..");
-               my %startconfig=(%config);
-               foreach my $wrapper (@{$setup{wrappers}}) {
-                       %config=(%startconfig, verbose => 0, %setup, %{$wrapper});
-                       checkconfig();
-                       gen_wrapper();
+                       push @ret, "\t# ".$info{description} if exists $info{description};
+       
+                       my $value=undef;
+                       my $prefix="#";
+                       if (exists $setup{$key} && defined $setup{$key}) {
+                               $value=$setup{$key};
+                               $prefix="";
+                       }
+                       elsif (exists $info{default}) {
+                               $value=$info{default};
+                       }
+                       elsif (exists $info{example}) {
+                               $value=$info{example};
+                       }
+       
+                       my $dumpedvalue=Dumper($value);
+                       chomp $dumpedvalue;
+                       $dumpedvalue=~/^\t//;
+                       push @ret, "\t$prefix$key=$dumpedvalue,";
                }
-               %config=(%startconfig);
-       }
-       foreach my $c (keys %setup) {
-               $config{$c}=possibly_foolish_untaint($setup{$c})
-                       if defined $setup{$c} && ! ref $setup{$c};
+               push @ret, "";
        }
-       if (! $config{refresh}) {
-               $config{rebuild}=1;
-               debug("rebuilding wiki..");
-       }
-       else {
-               debug("refreshing wiki..");
-       }
-
-       checkconfig();
-       lockwiki();
-       loadindex();
-       refresh();
 
-       debug("done");
-       saveindex();
-}
+       push @ret, "}";
+       return @ret;
+} #}}}
 
 1