From 0a52e8fd82d80bdd1290f49c3187d3f72db39c75 Mon Sep 17 00:00:00 2001 From: joey Date: Wed, 15 Mar 2006 03:24:34 +0000 Subject: [PATCH] config files now based on perl modules add MakeMaker foo for module --- IkiWiki/Setup/Standard.pm | 33 +++++++++++++++++++++++++++++++++ Makefile | 7 ------- Makefile.PL | 29 +++++++++++++++++++++++++++++ doc/bugs.mdwn | 2 -- doc/ikiwiki.setup | 36 ++++++++++++++++++++---------------- doc/setup.mdwn | 4 ++-- doc/todo.mdwn | 9 --------- ikiwiki | 16 ++-------------- 8 files changed, 86 insertions(+), 50 deletions(-) create mode 100644 IkiWiki/Setup/Standard.pm delete mode 100644 Makefile create mode 100755 Makefile.PL diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm new file mode 100644 index 000000000..7be4f891a --- /dev/null +++ b/IkiWiki/Setup/Standard.pm @@ -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 index 94e66ce74..000000000 --- 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 index 000000000..1e9d374a4 --- /dev/null +++ b/Makefile.PL @@ -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'], +); diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index 8ceff9aae..812a2c5ff 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -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. -* 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, diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index e8048c3b0..c03092b7a 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -5,7 +5,7 @@ # # Remember to re-run ikiwiki --setup any time you edit this file. -%setup=( +use IkiWiki::Setup::Standard { wikiname => "MyWiki", # Be sure to customise these.. @@ -21,21 +21,25 @@ 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, -); +} diff --git a/doc/setup.mdwn b/doc/setup.mdwn index d72cac71a..fe590c415 100644 --- a/doc/setup.mdwn +++ b/doc/setup.mdwn @@ -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. - 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 @@ -62,7 +62,7 @@ optional support for commits 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! diff --git a/doc/todo.mdwn b/doc/todo.mdwn index 2b4da3c4f..7565c5b59 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -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.. -## 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 diff --git a/ikiwiki b/ikiwiki index 72b4ab771..dd4177800 100755 --- a/ikiwiki +++ b/ikiwiki @@ -10,7 +10,8 @@ use Getopt::Long; 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_.:\/+]+$)/, @@ -1165,21 +1166,8 @@ sub setup () { # {{{ ($code)=$code=~/(.*)/s; close IN; - my (%setup); 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; } #}}} -- 2.26.2