config files now based on perl modules
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 15 Mar 2006 03:24:34 +0000 (03:24 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 15 Mar 2006 03:24:34 +0000 (03:24 +0000)
add MakeMaker foo for module

IkiWiki/Setup/Standard.pm [new file with mode: 0644]
Makefile [deleted file]
Makefile.PL [new file with mode: 0755]
doc/bugs.mdwn
doc/ikiwiki.setup
doc/setup.mdwn
doc/todo.mdwn
ikiwiki

diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm
new file mode 100644 (file)
index 0000000..7be4f89
--- /dev/null
@@ -0,0 +1,33 @@
+#!/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.
+
+package IkiWiki::Setup::Standard;
+
+use warnings;
+use strict;
+
+sub import {
+       my %setup=%{$_[1]};
+
+
+       ::debug("generating wrappers..");
+       foreach my $wrapper (@{$setup{wrapper}}) {
+               ::gen_wrapper(%::config, %setup, %{$wrapper});
+       }
+
+       ::debug("rebuilding wiki..");
+       foreach my $c (keys %setup) {
+               $::config{$c}=::possibly_foolish_untaint($setup{$c})
+                       if defined $setup{$c} && ! ref $setup{$c};
+       }
+       $::config{rebuild}=1;
+       ::refresh();
+
+       ::debug("done");
+       ::saveindex();
+}
+
+1
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 94e66ce..0000000
--- a/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-       ./ikiwiki doc templates html --wikiname="ikiwiki" --verbose \
-               --nosvn --exclude=/discussion
-
-clean:
-       rm -rf html
-       rm -rf doc/.ikiwiki
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100755 (executable)
index 0000000..1e9d374
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use ExtUtils::MakeMaker;
+
+# Add a few more targets.
+sub MY::postamble {
+q{
+all:: extra_build
+clean:: extra_clean
+install:: extra_install
+pure_install:: extra_install
+
+extra_build:
+       ./ikiwiki doc templates html --wikiname="ikiwiki" --verbose \
+               --nosvn --exclude=/discussion
+
+extra_clean:
+       rm -rf html
+       rm -rf doc/.ikiwiki
+
+extra_install:
+}
+}
+
+WriteMakefile(
+       'NAME'          => 'IkiWiki',
+       'EXE_FILES'     => ['ikiwiki'],
+);
index 8ceff9aae4c6de5514229e6f698b49ce0142ca79..812a2c5ffadc86bec5595aa969a73f11c511e0c6 100644 (file)
@@ -4,8 +4,6 @@
   to point to it, but will forget to update the linkbacks in Foo/Baz.
   And if Foo/Bar/Baz is then removed, it forgets to update Foo/Bar to link
   back to Foo/Baz.
   to point to it, but will forget to update the linkbacks in Foo/Baz.
   And if Foo/Bar/Baz is then removed, it forgets to update Foo/Bar to link
   back to Foo/Baz.
-* Foo/Bar/Baz shows up as Bar/Baz in the linkbacks on page Foo/Bar. Should
-  show as just Baz there.
 * If I try to do a web commit, to a svn+ssh repo, it fails with
   "Host key verification failed."
   I think that the setuid isn't fully taking; it should be running as me,
 * If I try to do a web commit, to a svn+ssh repo, it fails with
   "Host key verification failed."
   I think that the setuid isn't fully taking; it should be running as me,
index e8048c3b0a3a1fcc49e8bd275a66e32e500340be..c03092b7acd5b1e28242a02ef9867ef3b596e7a3 100644 (file)
@@ -5,7 +5,7 @@
 #
 # Remember to re-run ikiwiki --setup any time you edit this file.
 
 #
 # Remember to re-run ikiwiki --setup any time you edit this file.
 
-%setup=(
+use IkiWiki::Setup::Standard {
        wikiname => "MyWiki",
 
        # Be sure to customise these..
        wikiname => "MyWiki",
 
        # Be sure to customise these..
        svn => 1,
        svnrepo => "/svn/wiki",
 
        svn => 1,
        svnrepo => "/svn/wiki",
 
-       # The svn wrapper.
-       svnwrapper => {
-               # Note that this will overwrite any exsting post-commit hoo
-               # script, which may not be what you want.
-               wrapper => "$config{svnrepo}/hooks/post-commit",
-               wrappermode => 04755,
-       },
+       wrappers => [
+               {
+                       # The svn wrapper.
+                       # Note that this will overwrite any exsting
+                       # post-commit hook script, which may not be
+                       # what you want.
+                       wrapper => "$config{svnrepo}/hooks/post-commit",
+                       wrappermode => 04755,
+               },
+               {
+                       # The cgi wrapper.
+                       #cgiwrapper => {
+                       #       cgi => 1,
+                       #       wrapper => "/var/www/wiki/ikiwiki.cgi",
+                       #       wrappermode => 06755,
+                       #},
+               },
+       ],
        
        
-       # The cgi wrapper.
-       #cgiwrapper => {
-       #       cgi => 1,
-       #       wrapper => "/var/www/wiki/ikiwiki.cgi",
-       #       wrappermode => 06755,
-       #},
-
        # Can anonymous web users edit pages?
        #anonok => 1,
        # Can anonymous web users edit pages?
        #anonok => 1,
-);
+}
index d72cac71a5c37a68c4c81acf8ffe8e404b1ea725..fe590c415cb6d9ad06f516f258e1384c9bb8c6a7 100644 (file)
@@ -54,7 +54,7 @@ optional support for commits from the web.
    directories, and read through and configure the rest of the file to your
    liking.
 
    directories, and read through and configure the rest of the file to your
    liking.
 
-   Note that the default file has a block to configure a svnwraper. This
+   Note that the default file has a block to configure a svn wrapper. This
    sets up a [[post-commit]] hook to update the wiki.
 
    When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it
    sets up a [[post-commit]] hook to update the wiki.
 
    When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it
@@ -62,7 +62,7 @@ optional support for commits from the web.
 
 8. Set up [[CGI]] to allow editing the wiki from the web.
 
 
 8. Set up [[CGI]] to allow editing the wiki from the web.
 
-   Just edit ikiwiki.setup, uncomment the block for the cgiwrapper, make
+   Just edit ikiwiki.setup, uncomment the block for the cgi wrapper, make
    sure the filename for the cgi wrapper is ok, run 
    `ikiwiki --setup ikiwiki.setup`, and you're done!
 
    sure the filename for the cgi wrapper is ok, run 
    `ikiwiki --setup ikiwiki.setup`, and you're done!
 
index 2b4da3c4f003ea5eaaea086f3acd137937de2f70..7565c5b5934373f189068729c78cf1b0228c81a3 100644 (file)
@@ -77,15 +77,6 @@ recentchanges that goes to the diff for any listed change.
 Possibly add "next 100" link to it, but OTOH, you can just use svn log if
 you need that data..
 
 Possibly add "next 100" link to it, but OTOH, you can just use svn log if
 you need that data..
 
-## setup classes
-
-The setup files should "use WikiWiki::Setup" and the like at the top, and
-indeed could just be one big use that passes all params to the module's
-importer. The module then handles running ikiwiki functions. This would
-allow for different types of setup files for more than just the one
-hardcoded thing there is now, and would probably be good for upgrades,
-incompatible changes, etc, too.
-
 ## base wiki
 
 Need a toned down version of this wiki with a basic frontpage, sandbox and
 ## base wiki
 
 Need a toned down version of this wiki with a basic frontpage, sandbox and
diff --git a/ikiwiki b/ikiwiki
index 72b4ab77192cb4248739e1cadbc9775cdb03256c..dd417780096502b756e2d15b7026828edc413941 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -10,7 +10,8 @@ use Getopt::Long;
 
 my (%links, %oldlinks, %oldpagemtime, %renderedfiles, %pagesources);
 
 
 my (%links, %oldlinks, %oldpagemtime, %renderedfiles, %pagesources);
 
-my %config=( #{{{
+# Holds global config settings, also used by some modules.
+our %config=( #{{{
        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
        wiki_link_regexp => qr/\[\[([^\s]+)\]\]/,
        wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
        wiki_link_regexp => qr/\[\[([^\s]+)\]\]/,
        wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
@@ -1165,21 +1166,8 @@ sub setup () { # {{{
        ($code)=$code=~/(.*)/s;
        close IN;
 
        ($code)=$code=~/(.*)/s;
        close IN;
 
-       my (%setup);
        eval $code;
        error($@) if $@;
        eval $code;
        error($@) if $@;
-       
-       gen_wrapper(%config, %setup, %{$setup{cgiwrapper}}) if $setup{cgiwrapper};
-       gen_wrapper(%config, %setup, %{$setup{svnwrapper}}) if $setup{svnwrapper};
-       
-       print "$setup{wikiname} setup complete, now forcing a rebuild\n";
-       foreach my $c (keys %setup) {
-               $config{$c}=possibly_foolish_untaint($setup{$c})
-                       if defined $setup{$c} && ! ref $setup{$c};
-       }
-       $config{rebuild}=1;
-       refresh();
-       saveindex();
        exit;
 } #}}}
 
        exit;
 } #}}}