wrapper setup reorg

Flattened the wrapper setup, as this lets it be handled better by the
setup generation code.
master
Joey Hess 2008-07-26 21:00:11 -04:00
parent 4604fadf0a
commit c83fd4a328
10 changed files with 194 additions and 53 deletions

View File

@ -82,11 +82,26 @@ sub getsetup () { #{{{
cgiurl => {
type => "string",
default => '',
examples => "http://example.com/wiki/ikiwiki.cgi",
example => "http://example.com/wiki/ikiwiki.cgi",
description => "url to the ikiwiki.cgi",
safe => 1,
rebuild => 1,
},
cgi_wrapper => {
type => "string",
default => '',
example => "/var/www/wiki/ikiwiki.cgi",
description => "cgi executable to generate",
safe => 0, # file
rebuild => 0,
},
cgi_wrappermode => {
type => "string",
default => '06755',
description => "mode for cgi_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
rcs => {
type => "string",
default => '',
@ -117,33 +132,6 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
wrappers => {
type => "string",
example => [
{
cgi => 1,
wrapper => "/var/www/wiki/ikiwiki.cgi",
wrappermode => "06755",
},
],
description => "definitions of wrappers to generate",
safe => 0,
rebuild => 0,
},
wrapper => {
type => "internal",
default => undef,
description => "wrapper filename",
safe => 0,
rebuild => 0,
},
wrappermode => {
type => "internal",
default => undef,
description => "mode of wrapper file",
safe => 0,
rebuild => 0,
},
templatedir => {
type => "string",
default => "$installdir/share/ikiwiki/templates",
@ -158,6 +146,13 @@ sub getsetup () { #{{{
safe => 0, # path
rebuild => 0,
},
wrappers => {
type => "internal",
default => [],
description => "wrappers to generate",
safe => 0,
rebuild => 0,
},
underlaydirs => {
type => "internal",
default => [],

View File

@ -8,11 +8,36 @@ use IkiWiki;
use Encode;
use open qw{:utf8 :std};
hook(type => "checkconfig", id => "bzr", call => sub { #{{{
if (! defined $config{diffurl}) {
$config{diffurl}="";
}
if (exists $config{bzr_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{bzr_wrapper},
wrappermode => (defined $config{bzr_wrappermode} ? $config{bzr_wrappermode} : "06755"),
};
}
}); #}}}
hook(type => "getsetup", id => "bzr", call => sub { #{{{
return
bzr_wrapper => {
type => "string",
#example => "", # FIXME add example
description => "bzr post-commit executable to generate",
safe => 0, # file
rebuild => 0,
},
bzr_wrappermode => {
type => "string",
example => '06755',
description => "mode for bzr_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
historyurl => {
type => "string",
default => "",
#example => "", # FIXME add example
description => "url to show file history, using loggerhead ([[file]] substituted)",
safe => 1,
@ -20,7 +45,6 @@ hook(type => "getsetup", id => "bzr", call => sub { #{{{
},
diffurl => {
type => "string",
default => "",
example => "http://example.com/revision?start_revid=[[r2]]#[[file]]-s",
description => "url to view a diff, using loggerhead ([[file]] and [[r2]] substituted)",
safe => 1,

View File

@ -12,19 +12,41 @@ my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate Git sha1sums
my $dummy_commit_msg = 'dummy commit'; # message to skip in recent changes
hook(type => "checkconfig", id => "git", call => sub { #{{{
if (! defined $config{diffurl}) {
$config{diffurl}="";
}
if (! defined $config{gitorigin_branch}) {
$config{gitorigin_branch}="origin";
}
if (! defined $config{gitmaster_branch}) {
$config{gitmaster_branch}="master";
}
if (exists $config{git_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{git_wrapper},
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
}); #}}}
hook(type => "getsetup", id => "git", call => sub { #{{{
return
git_wrapper => {
type => "string",
example => "/git/wiki.git/hooks/post-update",
description => "git post-update executable to generate",
safe => 0, # file
rebuild => 0,
},
git_wrappermode => {
type => "string",
example => '06755',
description => "mode for git_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
historyurl => {
type => "string",
default => "",
example => "http://git.example.com/gitweb.cgi?p=wiki.git;a=history;f=[[file]]",
description => "gitweb url to show file history ([[file]] substituted)",
safe => 1,
@ -32,7 +54,6 @@ hook(type => "getsetup", id => "git", call => sub { #{{{
},
diffurl => {
type => "string",
default => "",
example => "http://git.example.com/gitweb.cgi?p=wiki.git;a=blobdiff;h=[[sha1_to]];hp=[[sha1_from]];hb=[[sha1_parent]];f=[[file]]",
description => "gitweb url to show a diff ([[sha1_to]], [[sha1_from]], [[sha1_parent]], and [[file]] substituted)",
safe => 1,
@ -40,14 +61,14 @@ hook(type => "getsetup", id => "git", call => sub { #{{{
},
gitorigin_branch => {
type => "string",
default => "origin",
example => "origin",
description => "where to pull and push changes (set to empty string to disable)",
safe => 0, # paranoia
rebuild => 0,
},
gitmaster_branch => {
type => "string",
default => "master",
example => "master",
description => "branch that the wiki is stored in",
safe => 0, # paranoia
rebuild => 0,

View File

@ -8,11 +8,36 @@ use IkiWiki;
use Encode;
use open qw{:utf8 :std};
hook(type => "checkconfig", id => "mercurial", call => sub { #{{{
if (! defined $config{diffurl}) {
$config{diffurl}="";
}
if (exists $config{mercurial_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{mercurial_wrapper},
wrappermode => (defined $config{mercurial_wrappermode} ? $config{mercurial_wrappermode} : "06755"),
};
}
}); #}}}
hook(type => "getsetup", id => "mercurial", call => sub { #{{{
return
mercurial_wrapper => {
type => "string",
#example => # FIXME add example
description => "mercurial post-commit executable to generate",
safe => 0, # file
rebuild => 0,
},
mercurial_wrappermode => {
type => "string",
example => '06755',
description => "mode for mercurial_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
historyurl => {
type => "string",
default => "",
example => "http://example.com:8000/log/tip/[[file]]",
description => "url to hg serve'd repository, to show file history ([[file]] substituted)",
safe => 1,
@ -20,7 +45,6 @@ hook(type => "getsetup", id => "mercurial", call => sub { #{{{
},
diffurl => {
type => "string",
default => "",
example => "http://localhost:8000/?fd=[[r2]];file=[[file]]",
description => "url to hg serve'd repository, to show diff ([[file]] and [[r2]] substituted)",
safe => 1,

View File

@ -40,13 +40,33 @@ hook(type => "checkconfig", id => "monotone", call => sub { #{{{
if ($version < 0.38) {
error("Monotone version too old, is $version but required 0.38");
}
if (exists $config{mtn_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{mtn_wrapper},
wrappermode => (defined $config{mtn_wrappermode} ? $config{mtn_wrappermode} : "06755"),
};
}
}); #}}}
hook(type => "getsetup", id => "monotone", call => sub { #{{{
return
mtn_wrapper => {
type => "string",
example => "/srv/mtn/wiki/_MTN/ikiwiki-netsync-hook",
description => "monotone netsync hook executable to generate",
safe => 0, # file
rebuild => 0,
},
mtn_wrappermode => {
type => "string",
example => '06755',
description => "mode for mtn_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
mtnkey => {
type => "string",
default => "",
example => 'web@example.com',
description => "your monotone key",
safe => 1,
@ -54,7 +74,6 @@ hook(type => "getsetup", id => "monotone", call => sub { #{{{
},
historyurl => {
type => "string",
default => "",
example => "http://viewmtn.example.com/branch/head/filechanges/com.example.branch/[[file]]",
description => "viewmtn url to show file history ([[file]] substituted)",
safe => 1,
@ -62,7 +81,6 @@ hook(type => "getsetup", id => "monotone", call => sub { #{{{
},
diffurl => {
type => "string",
default => "",
example => "http://viewmtn.example.com/revision/diff/[[r1]]/with/[[r2]]/[[file]]",
description => "viewmtn url to show a diff ([[r1]], [[r2]], and [[file]] substituted)",
safe => 1,
@ -70,14 +88,13 @@ hook(type => "getsetup", id => "monotone", call => sub { #{{{
},
mtnsync => {
type => "boolean",
default => 0,
example => 0,
description => "sync on update and commit?",
safe => 0, # paranoia
rebuild => 0,
},
mtnrootdir => {
type => "string",
default => "",
description => "path to your workspace (defaults to the srcdir; specify if the srcdir is a subdirectory of the workspace)",
safe => 0, # path
rebuild => 0,

View File

@ -8,6 +8,9 @@ use IkiWiki;
use POSIX qw(setlocale LC_CTYPE);
hook(type => "checkconfig", id => "svn", call => sub { #{{{
if (! defined $config{diffurl}) {
$config{diffurl}="";
}
if (! defined $config{svnpath}) {
$config{svnpath}="trunk";
}
@ -17,13 +20,18 @@ hook(type => "checkconfig", id => "svn", call => sub { #{{{
$config{svnpath}=~s/\/$//;
$config{svnpath}=~s/^\///;
}
if (exists $config{svn_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{svn_wrapper},
wrappermode => (defined $config{svn_wrappermode} ? $config{svn_wrappermode} : "04755"),
};
}
}); #}}}
hook(type => "getsetup", id => "svn", call => sub { #{{{
return
svnrepo => {
type => "string",
default => "",
example => "/svn/wiki",
description => "subversion repository location",
safe => 0, # path
@ -31,14 +39,27 @@ hook(type => "getsetup", id => "svn", call => sub { #{{{
},
svnpath => {
type => "string",
default => "trunk",
example => "trunk",
description => "path inside repository where the wiki is located",
safe => 0, # paranoia
rebuild => 0,
},
svn_wrapper => {
type => "string",
example => "/svn/wikirepo/hooks/post-commit",
description => "svn post-commit executable to generate",
safe => 0, # file
rebuild => 0,
},
svn_wrappermode => {
type => "string",
example => '04755',
description => "mode for svn_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
historyurl => {
type => "string",
default => "",
example => "http://svn.example.org/trunk/[[file]]",
description => "viewvc url to show file history ([[file]] substituted)",
safe => 1,
@ -46,7 +67,6 @@ hook(type => "getsetup", id => "svn", call => sub { #{{{
},
diffurl => {
type => "string",
default => "",
example => "http://svn.example.org/trunk/[[file]]?root=wiki&amp;r1=[[r1]]&amp;r2=[[r2]]",
description => "viewvc url to show a diff ([[file]], [[r1]], and [[r2]] substituted)",
safe => 1,

View File

@ -6,11 +6,36 @@ use warnings;
use strict;
use IkiWiki;
hook(type => "checkconfig", id => "tla", call => sub { #{{{
if (! defined $config{diffurl}) {
$config{diffurl}="";
}
if (exists $config{tla_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{tla_wrapper},
wrappermode => (defined $config{tla_wrappermode} ? $config{tla_wrappermode} : "06755"),
};
}
}); #}}}
hook(type => "getsetup", id => "tla", call => sub { #{{{
return
tla_wrapper => {
type => "string",
#example => "", # TODO example
description => "tla post-commit executable to generate",
safe => 0, # file
rebuild => 0,
},
tla_wrappermode => {
type => "string",
example => '06755',
description => "mode for tla_wrapper (can safely be made suid)",
safe => 0,
rebuild => 0,
},
historyurl => {
type => "string",
default => "",
#example => "", # TODO example
description => "url to show file history ([[file]] substituted)",
safe => 1,
@ -18,7 +43,6 @@ hook(type => "getsetup", id => "tla", call => sub { #{{{
},
diffurl => {
type => "string",
default => "",
#example => "", # TODO example
description => "url to show a diff ([[file]] and [[rev]] substituted)",
safe => 1,

View File

@ -48,7 +48,13 @@ sub load ($) { # {{{
$config{$c}=IkiWiki::possibly_foolish_untaint($setup{$c});
}
elsif (ref $setup{$c} eq 'ARRAY') {
$config{$c}=[map { IkiWiki::possibly_foolish_untaint($_) } @{$setup{$c}}]
if ($c eq 'wrappers') {
# backwards compatability code
$config{$c}=$setup{$c};
}
else {
$config{$c}=[map { IkiWiki::possibly_foolish_untaint($_) } @{$setup{$c}}]
}
}
elsif (ref $setup{$c} eq 'HASH') {
foreach my $key (keys %{$setup{$c}}) {
@ -60,6 +66,14 @@ sub load ($) { # {{{
$config{$c}=undef;
}
}
if (exists $config{cgi_wrapper}) {
push @{$config{wrappers}}, {
cgi => 1,
wrapper => $config{cgi_wrapper},
wrappermode => (defined $config{cgi_wrappermode} ? $config{cgi_wrappermode} : "06755"),
};
}
} #}}}
sub dump ($) { #{{{

2
debian/changelog vendored
View File

@ -3,6 +3,8 @@ ikiwiki (2.60) UNRELEASED; urgency=low
* Add getsetup hook, all plugins that add fields to %config should use it.
* ikiwiki --dumpsetup can generate a nice setup file snapshotting ikiwiki's
current configuration.
* The way wrappers are defined in the setup file has changed. Old setup
files will continue to work, for now.
-- Joey Hess <joeyh@debian.org> Mon, 21 Jul 2008 11:35:46 -0400

View File

@ -101,7 +101,7 @@ with ikiwiki's many features.
Let's first enable a key wiki feature and set up [[CGI]] to allow
editing the wiki from the web. Just edit ikiwiki.setup, uncomment the
block for the cgi wrapper, make sure the filename for the cgi wrapper
settings for the `cgi_wrapper`, make sure the filename for the cgi wrapper
is ok, run `ikiwiki --setup ikiwiki.setup`, and you're done!
There are lots of other configuration options in ikiwiki.setup that you
@ -193,11 +193,11 @@ about using the git repositories.
Once your wiki is checked in to the revision control system,
you should configure ikiwiki to use revision control. Edit your
ikiwiki.setup, and uncomment the lines for the revision control system
ikiwiki.setup, set `rcs` to the the revision control system
you chose to use. Be sure to set `svnrepo` to $REPOSITORY, if using
subversion. Uncomment the block for the wrapper for your revision
control system, and configure the wrapper path in that block
appropriately (for Git, it should be `$REPOSITORY/hooks/post-update`).
subversion. Uncomment the configuration for the wrapper for your revision
control system, and configure the wrapper path appropriately
(for Git, it should be `$REPOSITORY/hooks/post-update`).
Once it's all set up, run `ikiwiki --setup ikiwiki.setup` once more.
Now you should be able to edit files in $SRCDIR, and use your revision