From 01a9a12bbfbc21b45c59e4bbc52fbf488776d386 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 23 Sep 2009 13:46:32 -0400 Subject: auto.setup, auto-blog.setup: Fix sanitization of entered wikiname. Closes: #547378 --- IkiWiki/Setup/Automator.pm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 742d67666..d1594d7ea 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -24,15 +24,20 @@ sub prettydir ($) { return $dir; } -sub import (@) { - my $this=shift; - IkiWiki::Setup::merge({@_}); +sub sanitize_wikiname ($) { + my $wikiname=shift; # Sanitize this to avoid problimatic directory names. - $config{wikiname}=~s/[^-A-Za-z0-9_]//g; - if (! length $config{wikiname}) { + $wikiname=~s/[^-A-Za-z0-9_]//g; + if (! length $wikiname) { error gettext("you must enter a wikiname (that contains alphanumerics)"); } + return $wikiname; +} + +sub import (@) { + my $this=shift; + IkiWiki::Setup::merge({@_}); # Avoid overwriting any existing files. foreach my $key (qw{srcdir destdir repository dumpsetup}) { -- cgit v1.2.3 From 3fd8a7f91ccf0f9628a345d7ae08e8bba508410c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 2 Dec 2009 17:22:42 -0500 Subject: cvs: Add missing bit to Automator. --- IkiWiki/Setup/Automator.pm | 3 +++ debian/changelog | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index d1594d7ea..7af93e73c 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -72,6 +72,9 @@ sub import (@) { elsif ($config{rcs} eq 'mercurial') { # TODO } + elsif ($config{rcs} eq 'cvs') { + $config{cvs_wrapper}=$config{repository}."/CVSROOT/post-commit"; + } else { error sprintf(gettext("unsupported revision control system %s"), $config{rcs}); diff --git a/debian/changelog b/debian/changelog index 1408e4dce..c693be513 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20091203) UNRELEASED; urgency=low + + * cvs: Add missing bit to Automator. + + -- Joey Hess Wed, 02 Dec 2009 17:22:21 -0500 + ikiwiki (3.20091202) unstable; urgency=low * meta: Generate meta description tags even when the html scrubber is -- cgit v1.2.3 From 49d8c5b821743355fa60b30e1b2b456c44aaa221 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 1 Feb 2010 15:18:53 -0500 Subject: setup automator: Configure Term::Readline to use bold for prompt, rather than default underline. Closes: #517656 --- IkiWiki/Setup/Automator.pm | 1 + debian/changelog | 2 ++ 2 files changed, 3 insertions(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 7af93e73c..9fee4dcb7 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -15,6 +15,7 @@ sub ask ($$) { my ($question, $default)=@_; my $r=Term::ReadLine->new("ikiwiki"); + $r->ornaments("md,me"); $r->readline(encode_utf8($question)." ", $default); } diff --git a/debian/changelog b/debian/changelog index 5d27b7af0..8e01950a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ ikiwiki (3.20100123) UNRELEASED; urgency=low * template: Preprocess parameters before htmlizing. * img: Fix a bug that could taint @links with undef values. + * setup automator: Configure Term::Readline to use bold for prompt, rather + than default underline. Closes: #517656 -- Joey Hess Tue, 26 Jan 2010 22:25:33 -0500 -- cgit v1.2.3 From a63929f6cc7778ffc4ba57d784cdf2206ec650c7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 11 Feb 2010 22:24:15 -0500 Subject: Group related plugins into sections in the setup file, and drop unused rcs plugins from the setup file. --- IkiWiki/Plugin/anonok.pm | 1 + IkiWiki/Plugin/blogspam.pm | 1 + IkiWiki/Plugin/bzr.pm | 1 + IkiWiki/Plugin/conditional.pm | 1 + IkiWiki/Plugin/cvs.pm | 1 + IkiWiki/Plugin/darcs.pm | 1 + IkiWiki/Plugin/editpage.pm | 1 + IkiWiki/Plugin/git.pm | 1 + IkiWiki/Plugin/htmlscrubber.pm | 1 + IkiWiki/Plugin/httpauth.pm | 1 + IkiWiki/Plugin/inline.pm | 1 + IkiWiki/Plugin/link.pm | 1 + IkiWiki/Plugin/lockedit.pm | 1 + IkiWiki/Plugin/mdwn.pm | 1 + IkiWiki/Plugin/mercurial.pm | 1 + IkiWiki/Plugin/meta.pm | 1 + IkiWiki/Plugin/moderatedcomments.pm | 1 + IkiWiki/Plugin/monotone.pm | 1 + IkiWiki/Plugin/opendiscussion.pm | 1 + IkiWiki/Plugin/openid.pm | 1 + IkiWiki/Plugin/parentlinks.pm | 1 + IkiWiki/Plugin/passwordauth.pm | 1 + IkiWiki/Plugin/recentchanges.pm | 1 + IkiWiki/Plugin/signinedit.pm | 1 + IkiWiki/Plugin/svn.pm | 1 + IkiWiki/Plugin/tla.pm | 1 + IkiWiki/Setup.pm | 32 ++++++++++++++++++++++++++------ IkiWiki/Setup/Standard.pm | 8 ++++++++ debian/changelog | 2 ++ doc/plugins/write.mdwn | 13 ++++++++----- 30 files changed, 70 insertions(+), 11 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Plugin/anonok.pm b/IkiWiki/Plugin/anonok.pm index 243b98920..0e74cbfad 100644 --- a/IkiWiki/Plugin/anonok.pm +++ b/IkiWiki/Plugin/anonok.pm @@ -15,6 +15,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, anonok_pagespec => { type => "pagespec", diff --git a/IkiWiki/Plugin/blogspam.pm b/IkiWiki/Plugin/blogspam.pm index 626c8ec42..c4e5cf390 100644 --- a/IkiWiki/Plugin/blogspam.pm +++ b/IkiWiki/Plugin/blogspam.pm @@ -18,6 +18,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, blogspam_pagespec => { type => 'pagespec', diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 883007367..1ffdc2353 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -36,6 +36,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, bzr_wrapper => { type => "string", diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index aad617812..beeddc672 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -16,6 +16,7 @@ sub getsetup { plugin => { safe => 1, rebuild => undef, + section => "core", }, } diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm index f6db8bc98..26a3e9dd2 100644 --- a/IkiWiki/Plugin/cvs.pm +++ b/IkiWiki/Plugin/cvs.pm @@ -85,6 +85,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, cvsrepo => { type => "string", diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 0d68f27e5..1c9538e83 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -92,6 +92,7 @@ sub getsetup() { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, darcs_wrapper => { type => "string", diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 9211cca89..44fe5514a 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -17,6 +17,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, + section => "core", }, } diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 1eec6aee6..b02f4a5ed 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -68,6 +68,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, git_wrapper => { type => "string", diff --git a/IkiWiki/Plugin/htmlscrubber.pm b/IkiWiki/Plugin/htmlscrubber.pm index a249cdf7a..ee284a45c 100644 --- a/IkiWiki/Plugin/htmlscrubber.pm +++ b/IkiWiki/Plugin/htmlscrubber.pm @@ -40,6 +40,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "core", }, htmlscrubber_skip => { type => "pagespec", diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm index b2bb2701a..478f67446 100644 --- a/IkiWiki/Plugin/httpauth.pm +++ b/IkiWiki/Plugin/httpauth.pm @@ -20,6 +20,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, cgiauthurl => { type => "string", diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 401852513..44919e58c 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -49,6 +49,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "core", }, rss => { type => "boolean", diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm index 4c1add985..3838aec09 100644 --- a/IkiWiki/Plugin/link.pm +++ b/IkiWiki/Plugin/link.pm @@ -20,6 +20,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, + section => "core", }, } diff --git a/IkiWiki/Plugin/lockedit.pm b/IkiWiki/Plugin/lockedit.pm index 74ddbb153..1466e8337 100644 --- a/IkiWiki/Plugin/lockedit.pm +++ b/IkiWiki/Plugin/lockedit.pm @@ -15,6 +15,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, locked_pages => { type => "pagespec", diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm index 3de59ef3d..4ddf097ba 100644 --- a/IkiWiki/Plugin/mdwn.pm +++ b/IkiWiki/Plugin/mdwn.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, # format plugin + section => "core", }, multimarkdown => { type => "boolean", diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index 11fdec529..ea00a3364 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -36,6 +36,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, mercurial_wrapper => { type => "string", diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 55c9ddbd1..5f046cb2a 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -20,6 +20,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "core", }, } diff --git a/IkiWiki/Plugin/moderatedcomments.pm b/IkiWiki/Plugin/moderatedcomments.pm index 2555927b7..afe1ceedf 100644 --- a/IkiWiki/Plugin/moderatedcomments.pm +++ b/IkiWiki/Plugin/moderatedcomments.pm @@ -15,6 +15,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, moderate_users => { type => 'boolean', diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 9502804f1..c33cf7e3a 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -68,6 +68,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, mtn_wrapper => { type => "string", diff --git a/IkiWiki/Plugin/opendiscussion.pm b/IkiWiki/Plugin/opendiscussion.pm index 5a455940b..2805f60ef 100644 --- a/IkiWiki/Plugin/opendiscussion.pm +++ b/IkiWiki/Plugin/opendiscussion.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, } diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index 382d8286f..bb99446b4 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -26,6 +26,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, openidsignup => { type => "string", diff --git a/IkiWiki/Plugin/parentlinks.pm b/IkiWiki/Plugin/parentlinks.pm index e678a057d..728bbc399 100644 --- a/IkiWiki/Plugin/parentlinks.pm +++ b/IkiWiki/Plugin/parentlinks.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, + section => "core", }, } diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm index c07065b7d..4848b47bb 100644 --- a/IkiWiki/Plugin/passwordauth.pm +++ b/IkiWiki/Plugin/passwordauth.pm @@ -19,6 +19,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, account_creation_password => { type => "string", diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 5c7b71aaa..04219b721 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -22,6 +22,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, + section => "core", }, recentchangespage => { type => "string", diff --git a/IkiWiki/Plugin/signinedit.pm b/IkiWiki/Plugin/signinedit.pm index 8b44a68f7..31160c02f 100644 --- a/IkiWiki/Plugin/signinedit.pm +++ b/IkiWiki/Plugin/signinedit.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, + section => "auth", }, } diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index 06b987f51..7d27ec842 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -44,6 +44,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, svnrepo => { type => "string", diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index f4b20a6ec..16d73b136 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -34,6 +34,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, tla_wrapper => { type => "string", diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 8a25ecc57..b21bd7bfe 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -77,7 +77,6 @@ sub merge ($) { sub getsetup () { # Gets all available setup data from all plugins. Returns an # ordered list of [plugin, setup] pairs. - my @ret; # disable logging to syslog while dumping, broken plugins may # whine when loaded @@ -85,27 +84,48 @@ sub getsetup () { $config{syslog}=undef; # Load all plugins, so that all setup options are available. - my @plugins=grep { $_ ne $config{rcs} } sort(IkiWiki::listplugins()); - unshift @plugins, $config{rcs} if $config{rcs}; # rcs plugin 1st + my @plugins=IkiWiki::listplugins(); foreach my $plugin (@plugins) { eval { IkiWiki::loadplugin($plugin) }; if (exists $IkiWiki::hooks{checkconfig}{$plugin}{call}) { my @s=eval { $IkiWiki::hooks{checkconfig}{$plugin}{call}->() }; } } - + + my %sections; foreach my $plugin (@plugins) { if (exists $IkiWiki::hooks{getsetup}{$plugin}{call}) { # use an array rather than a hash, to preserve order my @s=eval { $IkiWiki::hooks{getsetup}{$plugin}{call}->() }; next unless @s; - push @ret, [ $plugin, \@s ], + + # set default section value (note use of shared + # hashref between array and hash) + my %s=@s; + if (! exists $s{plugin} || ! $s{plugin}->{section}) { + $s{plugin}->{section}="misc"; + } + + # only the selected rcs plugin is included + if ($config{rcs} && $plugin eq $config{rcs}) { + $s{plugin}->{section}="core"; + } + elsif ($s{plugin}->{section} eq "rcs") { + next; + } + + push @{$sections{$s{plugin}->{section}}}, [ $plugin, \@s ]; } } $config{syslog}=$syslog; - return @ret; + return map { sort { $a->[0] cmp $b->[0] } @{$sections{$_}} } + sort { # core first, then alphabetical + ($b eq "core") <=> ($a eq "core") + || + $a cmp $b + } keys %sections; } sub dump ($) { diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index 951bcfc56..c99dbb620 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -90,10 +90,18 @@ sub gendump ($) { # disable logging to syslog while dumping $config{syslog}=undef; + my $curr_section; push @ret, dumpvalues(\%setup, IkiWiki::getsetup()); foreach my $pair (IkiWiki::Setup::getsetup()) { my $plugin=$pair->[0]; my $setup=$pair->[1]; + my %s=@{$setup}; + my $section=$s{plugin}->{section}; + if (! defined $curr_section || $curr_section ne $section) { + $curr_section=$section; + push @ret, "", "\t#", "\t# $section plugins", "\t#"; + } + my @values=dumpvalues(\%setup, @{$setup}); if (@values) { push @ret, "", "\t# $plugin plugin", @values; diff --git a/debian/changelog b/debian/changelog index d74abd0f9..f24a453c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ ikiwiki (3.20100123) UNRELEASED; urgency=low * httpauth: Add httpauth_pagespec setting that can be used to limit pages to only being edited via users authed with httpauth. * Allow globs to be used in user() pagespecs. + * Group related plugins into sections in the setup file, and drop + unused rcs plugins from the setup file. -- Joey Hess Tue, 26 Jan 2010 22:25:33 -0500 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 082f0e38f..68454d56c 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -457,6 +457,12 @@ describing the option. There can also be an item named "plugin", which describes the plugin as a whole. For example: return + plugin => { + description => "description of this plugin", + safe => 1, + rebuild => 1, + section => "misc", + }, option_foo => { type => "boolean", description => "enable foo?", @@ -471,11 +477,6 @@ describes the plugin as a whole. For example: safe => 1, rebuild => 0, }, - plugin => { - description => "description of this plugin", - safe => 1, - rebuild => 1, - }, * `type` can be "boolean", "string", "integer", "pagespec", or "internal" (used for values that are not user-visible). The type is @@ -496,6 +497,8 @@ describes the plugin as a whole. For example: the plugin) will require a wiki rebuild, false if no rebuild is needed, and undef if a rebuild could be needed in some circumstances, but is not strictly required. +* `section` can optionally specify which section in the config file + the plugin fits in. ### genwrapper -- cgit v1.2.3 From 0ea2f0936bf9d51f4760fe5a8e57d46d1b6ecce6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Feb 2010 00:51:19 -0500 Subject: add plugin section, and show which plugins need no configuration --- IkiWiki/Setup/Standard.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index c99dbb620..bdf52f25a 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -90,16 +90,24 @@ sub gendump ($) { # disable logging to syslog while dumping $config{syslog}=undef; - my $curr_section; + eval q{use Text::Wrap}; + die $@ if $@; + + my %section_plugins; push @ret, dumpvalues(\%setup, IkiWiki::getsetup()); foreach my $pair (IkiWiki::Setup::getsetup()) { my $plugin=$pair->[0]; my $setup=$pair->[1]; my %s=@{$setup}; my $section=$s{plugin}->{section}; - if (! defined $curr_section || $curr_section ne $section) { - $curr_section=$section; - push @ret, "", "\t#", "\t# $section plugins", "\t#"; + push @{$section_plugins{$section}}, $plugin; + if (@{$section_plugins{$section}} == 1) { + push @ret, "", "\t#", "\t# $section plugins", + sub { + wrap("\t# (", "\t# ", + join(", ", @{$section_plugins{$section}})).")" + }, + "\t#"; } my @values=dumpvalues(\%setup, @{$setup}); @@ -119,7 +127,7 @@ sub gendump ($) { "use IkiWiki::Setup::Standard {"; push @ret, "}"; - return @ret; + return map { ref $_ ? $_->() : $_ } @ret; } 1 -- cgit v1.2.3 From 2d4b84e45f1dc947e8bb9ff92ab543861223ff42 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Feb 2010 01:16:20 -0500 Subject: borders --- IkiWiki/Setup/Standard.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index bdf52f25a..71abb1cfb 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -102,12 +102,12 @@ sub gendump ($) { my $section=$s{plugin}->{section}; push @{$section_plugins{$section}}, $plugin; if (@{$section_plugins{$section}} == 1) { - push @ret, "", "\t#", "\t# $section plugins", + push @ret, "", "\t".("#" x 70), "\t# $section plugins", sub { wrap("\t# (", "\t# ", join(", ", @{$section_plugins{$section}})).")" }, - "\t#"; + "\t".("#" x 70); } my @values=dumpvalues(\%setup, @{$setup}); -- cgit v1.2.3 From 805b3afff7158a7912b06948d134478308b5855b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Feb 2010 04:09:57 -0500 Subject: formatting sillyness --- IkiWiki/Setup/Standard.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index 71abb1cfb..f7a322317 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -104,7 +104,7 @@ sub gendump ($) { if (@{$section_plugins{$section}} == 1) { push @ret, "", "\t".("#" x 70), "\t# $section plugins", sub { - wrap("\t# (", "\t# ", + wrap("\t# (", "\t# ", join(", ", @{$section_plugins{$section}})).")" }, "\t".("#" x 70); -- cgit v1.2.3 From a12c386c86d000971125d70bf22213fd9595ed45 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 27 Feb 2010 16:26:13 -0500 Subject: Add force_overwrite setting to make setup automator overwrite existing files/directories. This can be useful if you're driving the setup automator from another program. --- IkiWiki/Setup/Automator.pm | 22 ++++++++++++---------- debian/changelog | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 9fee4dcb7..79a610e20 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -40,17 +40,19 @@ sub import (@) { my $this=shift; IkiWiki::Setup::merge({@_}); - # Avoid overwriting any existing files. - foreach my $key (qw{srcdir destdir repository dumpsetup}) { - next unless exists $config{$key}; - my $add=""; - my $dir=IkiWiki::dirname($config{$key})."/"; - my $base=IkiWiki::basename($config{$key}); - while (-e $dir.$add.$base) { - $add=1 if ! $add; - $add++; + if (! $config{force_overwrite}) { + # Avoid overwriting any existing files. + foreach my $key (qw{srcdir destdir repository dumpsetup}) { + next unless exists $config{$key}; + my $add=""; + my $dir=IkiWiki::dirname($config{$key})."/"; + my $base=IkiWiki::basename($config{$key}); + while (-e $dir.$add.$base) { + $add=1 if ! $add; + $add++; + } + $config{$key}=$dir.$add.$base; } - $config{$key}=$dir.$add.$base; } # Set up wrapper diff --git a/debian/changelog b/debian/changelog index 1960a1226..bdbd818e1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ ikiwiki (3.20100213) UNRELEASED; urgency=low * Rebuild wikis on upgrade to this version to get the comment counts added to existing pages. * Loosen regexp, to allow empty quoted parameters in directives. + * Add force_overwrite setting to make setup automator overwrite existing + files/directories. -- Joey Hess Sun, 14 Feb 2010 17:02:10 -0500 -- cgit v1.2.3 From 6aaa6e0d245e450315a073f62e27c233cefbe9ec Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 27 Feb 2010 16:36:57 -0500 Subject: Fix admin openid detection in setup automator, and avoid prompting for a password. --- IkiWiki/Setup/Automator.pm | 2 +- debian/changelog | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 79a610e20..9da594e99 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -144,7 +144,7 @@ sub import (@) { # Create admin user(s). foreach my $admin (@{$config{adminuser}}) { - next if $admin=~/^http\?:\/\//; # openid + next if defined IkiWiki::openiduser($admin); # Prompt for password w/o echo. my ($password, $password2); diff --git a/debian/changelog b/debian/changelog index bdbd818e1..832bbaa85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ ikiwiki (3.20100213) UNRELEASED; urgency=low * Loosen regexp, to allow empty quoted parameters in directives. * Add force_overwrite setting to make setup automator overwrite existing files/directories. + * Fix admin openid detection in setup automator, and avoid prompting + for a password. -- Joey Hess Sun, 14 Feb 2010 17:02:10 -0500 -- cgit v1.2.3 From b1dade8d960ce7ccb549e5652d35a8e9dbccf5c6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 14:52:17 -0400 Subject: allow multiple setup file types, and support safe parsing Finally removed the last hardcoding of IkiWiki::Setup::Standard. Take the first "IkiWiki::Setup::*" in the setup file to define the setuptype, and remember that type to use in dumping later. (But it can be overridden using --set, etc.) Also, support setup file types that are not evaled. --- IkiWiki.pm | 7 +++++++ IkiWiki/Setup.pm | 40 +++++++++++++++++++++++++++++----------- IkiWiki/Setup/Standard.pm | 4 +++- 3 files changed, 39 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki.pm b/IkiWiki.pm index 6e333504e..241fb45b7 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -467,6 +467,13 @@ sub getsetup () { safe => 0, rebuild => 0, }, + setuptype => { + type => "internal", + default => "IkiWiki::Setup::Standard", + description => "perl class to use to dump setup file", + safe => 0, + rebuild => 0, + }, allow_symlinks_before_srcdir => { type => "boolean", default => 0, diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index a3fd5ce66..3accf3591 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -1,6 +1,8 @@ #!/usr/bin/perl -# Ikiwiki setup files are perl files that 'use IkiWiki::Setup::foo', -# passing it some sort of configuration data. +# Ikiwiki setup files can be perl files that 'use IkiWiki::Setup::foo', +# passing it some sort of configuration data. Or, they can contain +# the module name at the top, without the 'use', and the whole file is +# then fed into that module. package IkiWiki::Setup; @@ -10,24 +12,39 @@ use IkiWiki; use open qw{:utf8 :std}; use File::Spec; -sub load ($) { +sub load ($;$) { my $setup=IkiWiki::possibly_foolish_untaint(shift); + my $safemode=shift; + $config{setupfile}=File::Spec->rel2abs($setup); #translators: The first parameter is a filename, and the second #translators: is a (probably not translated) error message. open (IN, $setup) || error(sprintf(gettext("cannot read %s: %s"), $setup, $!)); - my $code; + my $content; { local $/=undef; - $code= || error("$setup: $!"); + $content= || error("$setup: $!"); } - - ($code)=$code=~/(.*)/s; close IN; - eval $code; - error("$setup: ".$@) if $@; + if ($content=~/(use\s+)?(IkiWiki::Setup::\w+)/) { + $config{setuptype}=$2; + if ($1) { + error sprintf(gettext("cannot load %s in safe mode"), $setup) + if $safemode; + eval IkiWiki::possibly_foolish_untaint($content); + error("$setup: ".$@) if $@; + } + else { + eval qq{require $config{setuptype}}; + error $@ if $@; + $config{setuptype}->loaddump(IkiWiki::possibly_foolish_untaint($content)); + } + } + else { + error sprintf(gettext("failed to parse %s"), $setup); + } } sub merge ($) { @@ -133,8 +150,9 @@ sub getsetup () { sub dump ($) { my $file=IkiWiki::possibly_foolish_untaint(shift); - require IkiWiki::Setup::Standard; - my @dump=IkiWiki::Setup::Standard::gendump("Setup file for ikiwiki."); + eval qq{require $config{setuptype}}; + error $@ if $@; + my @dump=$config{setuptype}->gendump("Setup file for ikiwiki."); open (OUT, ">", $file) || die "$file: $!"; print OUT "$_\n" foreach @dump; diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index f7a322317..4022ff03c 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -82,8 +82,10 @@ sub dumpvalues ($@) { return @ret; } -sub gendump ($) { +sub gendump ($$) { + my $class=shift; my $description=shift; + my %setup=(%config); my @ret; -- cgit v1.2.3 From 522daa7ea8111482701ce222800096edaf8eb2d2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 15:27:15 -0400 Subject: factored out generic commented line dumping --- IkiWiki/Setup.pm | 94 +++++++++++++++++++++++++++++++++++++++-------- IkiWiki/Setup/Standard.pm | 94 +++++++++-------------------------------------- 2 files changed, 96 insertions(+), 92 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 3accf3591..369ff44d0 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -13,28 +13,28 @@ use open qw{:utf8 :std}; use File::Spec; sub load ($;$) { - my $setup=IkiWiki::possibly_foolish_untaint(shift); + my $file=IkiWiki::possibly_foolish_untaint(shift); my $safemode=shift; - $config{setupfile}=File::Spec->rel2abs($setup); + $config{setupfile}=File::Spec->rel2abs($file); #translators: The first parameter is a filename, and the second #translators: is a (probably not translated) error message. - open (IN, $setup) || error(sprintf(gettext("cannot read %s: %s"), $setup, $!)); + open (IN, $file) || error(sprintf(gettext("cannot read %s: %s"), $file, $!)); my $content; { local $/=undef; - $content= || error("$setup: $!"); + $content= || error("$file: $!"); } close IN; if ($content=~/(use\s+)?(IkiWiki::Setup::\w+)/) { $config{setuptype}=$2; if ($1) { - error sprintf(gettext("cannot load %s in safe mode"), $setup) + error sprintf(gettext("cannot load %s in safe mode"), $file) if $safemode; eval IkiWiki::possibly_foolish_untaint($content); - error("$setup: ".$@) if $@; + error("$file: ".$@) if $@; } else { eval qq{require $config{setuptype}}; @@ -43,10 +43,22 @@ sub load ($;$) { } } else { - error sprintf(gettext("failed to parse %s"), $setup); + error sprintf(gettext("failed to parse %s"), $file); } } +sub dump ($) { + my $file=IkiWiki::possibly_foolish_untaint(shift); + + eval qq{require $config{setuptype}}; + error $@ if $@; + my @dump=$config{setuptype}->gendump("Setup file for ikiwiki."); + + open (OUT, ">", $file) || die "$file: $!"; + print OUT "$_\n" foreach @dump; + close OUT; +} + sub merge ($) { # Merge setup into existing config and untaint. my %setup=%{shift()}; @@ -147,16 +159,68 @@ sub getsetup () { } keys %sections; } -sub dump ($) { - my $file=IkiWiki::possibly_foolish_untaint(shift); +sub commented_dump ($) { + my $dumpline=shift; + + my %setup=(%config); + my @ret; - eval qq{require $config{setuptype}}; - error $@ if $@; - my @dump=$config{setuptype}->gendump("Setup file for ikiwiki."); + # disable logging to syslog while dumping + $config{syslog}=undef; + + eval q{use Text::Wrap}; + die $@ if $@; + + my %section_plugins; + push @ret, commented_dumpvalues($dumpline, \%setup, IkiWiki::getsetup()); + foreach my $pair (IkiWiki::Setup::getsetup()) { + my $plugin=$pair->[0]; + my $setup=$pair->[1]; + my %s=@{$setup}; + my $section=$s{plugin}->{section}; + push @{$section_plugins{$section}}, $plugin; + if (@{$section_plugins{$section}} == 1) { + push @ret, "", "\t".("#" x 70), "\t# $section plugins", + sub { + wrap("\t# (", "\t# ", + join(", ", @{$section_plugins{$section}})).")" + }, + "\t".("#" x 70); + } - open (OUT, ">", $file) || die "$file: $!"; - print OUT "$_\n" foreach @dump; - close OUT; + my @values=commented_dumpvalues($dumpline, \%setup, @{$setup}); + if (@values) { + push @ret, "", "\t# $plugin plugin", @values; + } + } + + return map { ref $_ ? $_->() : $_ } @ret; +} + +sub commented_dumpvalues ($$@) { + my $dumpline=shift; + my $setup=shift; + my @ret; + while (@_) { + my $key=shift; + my %info=%{shift()}; + + next if $key eq "plugin" || $info{type} eq "internal"; + + push @ret, "\t# ".$info{description} if exists $info{description}; + + if (exists $setup->{$key} && defined $setup->{$key}) { + push @ret, $dumpline->($key, $setup->{$key}, $info{type}, ""); + delete $setup->{$key}; + } + elsif (exists $info{example}) { + push @ret, $dumpline->($key, $info{example}, $info{type}, "#"); + } + else { + push @ret, $dumpline->($key, "", $info{type}, "#"); + } + } + return @ret; } 1 diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index 4022ff03c..9c177e497 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -1,7 +1,6 @@ #!/usr/bin/perl # Standard ikiwiki setup module. -# Parameters to import should be all the standard ikiwiki config stuff, -# plus an array of wrappers to set up. +# Parameters to import should be all the standard ikiwiki config stuff. package IkiWiki::Setup::Standard; @@ -13,6 +12,22 @@ sub import { IkiWiki::Setup::merge($_[1]); } +sub gendump ($$) { + my $class=shift; + my $description=shift; + + "#!/usr/bin/perl", + "# $description", + "#", + "# 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 {", + IkiWiki::Setup::commented_dump(\&dumpline), + "}"; +} + sub dumpline ($$$$) { my $key=shift; my $value=shift; @@ -57,79 +72,4 @@ sub dumpline ($$$$) { return "\t$prefix$key => $dumpedvalue,"; } -sub dumpvalues ($@) { - my $setup=shift; - my @ret; - while (@_) { - my $key=shift; - my %info=%{shift()}; - - next if $key eq "plugin" || $info{type} eq "internal"; - - push @ret, "\t# ".$info{description} if exists $info{description}; - - if (exists $setup->{$key} && defined $setup->{$key}) { - push @ret, dumpline($key, $setup->{$key}, $info{type}, ""); - delete $setup->{$key}; - } - elsif (exists $info{example}) { - push @ret, dumpline($key, $info{example}, $info{type}, "#"); - } - else { - push @ret, dumpline($key, "", $info{type}, "#"); - } - } - return @ret; -} - -sub gendump ($$) { - my $class=shift; - my $description=shift; - - my %setup=(%config); - my @ret; - - # disable logging to syslog while dumping - $config{syslog}=undef; - - eval q{use Text::Wrap}; - die $@ if $@; - - my %section_plugins; - push @ret, dumpvalues(\%setup, IkiWiki::getsetup()); - foreach my $pair (IkiWiki::Setup::getsetup()) { - my $plugin=$pair->[0]; - my $setup=$pair->[1]; - my %s=@{$setup}; - my $section=$s{plugin}->{section}; - push @{$section_plugins{$section}}, $plugin; - if (@{$section_plugins{$section}} == 1) { - push @ret, "", "\t".("#" x 70), "\t# $section plugins", - sub { - wrap("\t# (", "\t# ", - join(", ", @{$section_plugins{$section}})).")" - }, - "\t".("#" x 70); - } - - my @values=dumpvalues(\%setup, @{$setup}); - if (@values) { - push @ret, "", "\t# $plugin plugin", @values; - } - } - - unshift @ret, - "#!/usr/bin/perl", - "# $description", - "#", - "# 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 {"; - push @ret, "}"; - - return map { ref $_ ? $_->() : $_ } @ret; -} - 1 -- cgit v1.2.3 From bbe1f2e493f009b49aba6ab83304f9484e37c61d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 15:35:21 -0400 Subject: move generic comment into IkiWiki::Setup --- IkiWiki/Setup.pm | 9 ++++++++- IkiWiki/Setup/Standard.pm | 11 +++-------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 369ff44d0..45f263bc8 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -52,7 +52,14 @@ sub dump ($) { eval qq{require $config{setuptype}}; error $@ if $@; - my @dump=$config{setuptype}->gendump("Setup file for ikiwiki."); + my @dump=$config{setuptype}->gendump( + "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.", + ); open (OUT, ">", $file) || die "$file: $!"; print OUT "$_\n" foreach @dump; diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index 9c177e497..92e97c4b4 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -12,20 +12,15 @@ sub import { IkiWiki::Setup::merge($_[1]); } -sub gendump ($$) { +sub gendump ($@) { my $class=shift; - my $description=shift; "#!/usr/bin/perl", - "# $description", "#", - "# 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.", + (map { "# $_" } @_), "use IkiWiki::Setup::Standard {", IkiWiki::Setup::commented_dump(\&dumpline), - "}"; + "}" } sub dumpline ($$$$) { -- cgit v1.2.3 From 10f8a2c85841d5884ccee096145498af96f06f05 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 15:36:33 -0400 Subject: improve comments --- IkiWiki/Setup/Standard.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index 92e97c4b4..33b578e12 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -1,6 +1,4 @@ #!/usr/bin/perl -# Standard ikiwiki setup module. -# Parameters to import should be all the standard ikiwiki config stuff. package IkiWiki::Setup::Standard; @@ -8,6 +6,7 @@ use warnings; use strict; use IkiWiki; +# Parameters to import should be all the standard ikiwiki config, in a hash. sub import { IkiWiki::Setup::merge($_[1]); } -- cgit v1.2.3 From 19a794b4829c548a7f5b9dc22e22c24d7f28bad8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 15:44:28 -0400 Subject: parameterized indent --- IkiWiki/Setup.pm | 20 +++++++++++--------- IkiWiki/Setup/Standard.pm | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 45f263bc8..a71a12d9d 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -166,8 +166,9 @@ sub getsetup () { } keys %sections; } -sub commented_dump ($) { +sub commented_dump ($$) { my $dumpline=shift; + my $indent=shift; my %setup=(%config); my @ret; @@ -179,7 +180,7 @@ sub commented_dump ($) { die $@ if $@; my %section_plugins; - push @ret, commented_dumpvalues($dumpline, \%setup, IkiWiki::getsetup()); + push @ret, commented_dumpvalues($dumpline, $indent, \%setup, IkiWiki::getsetup()); foreach my $pair (IkiWiki::Setup::getsetup()) { my $plugin=$pair->[0]; my $setup=$pair->[1]; @@ -187,25 +188,26 @@ sub commented_dump ($) { my $section=$s{plugin}->{section}; push @{$section_plugins{$section}}, $plugin; if (@{$section_plugins{$section}} == 1) { - push @ret, "", "\t".("#" x 70), "\t# $section plugins", + push @ret, "", $indent.("#" x 70), "$indent# $section plugins", sub { - wrap("\t# (", "\t# ", + wrap("$indent# (", "$indent# ", join(", ", @{$section_plugins{$section}})).")" }, - "\t".("#" x 70); + $indent.("#" x 70); } - my @values=commented_dumpvalues($dumpline, \%setup, @{$setup}); + my @values=commented_dumpvalues($dumpline, $indent, \%setup, @{$setup}); if (@values) { - push @ret, "", "\t# $plugin plugin", @values; + push @ret, "", "$indent# $plugin plugin", @values; } } return map { ref $_ ? $_->() : $_ } @ret; } -sub commented_dumpvalues ($$@) { +sub commented_dumpvalues ($$$@) { my $dumpline=shift; + my $indent=shift; my $setup=shift; my @ret; while (@_) { @@ -214,7 +216,7 @@ sub commented_dumpvalues ($$@) { next if $key eq "plugin" || $info{type} eq "internal"; - push @ret, "\t# ".$info{description} if exists $info{description}; + push @ret, "$indent# ".$info{description} if exists $info{description}; if (exists $setup->{$key} && defined $setup->{$key}) { push @ret, $dumpline->($key, $setup->{$key}, $info{type}, ""); diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index 33b578e12..c85069304 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -18,7 +18,7 @@ sub gendump ($@) { "#", (map { "# $_" } @_), "use IkiWiki::Setup::Standard {", - IkiWiki::Setup::commented_dump(\&dumpline), + IkiWiki::Setup::commented_dump(\&dumpline, "\t"), "}" } -- cgit v1.2.3 From bba513a3e52170dc06b545a44f2d859ae4b757b5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 15:50:59 -0400 Subject: Add support for setup files written in YAML. Not the default. (Yet?) --- IkiWiki/Setup/Yaml.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 1 + 2 files changed, 44 insertions(+) create mode 100644 IkiWiki/Setup/Yaml.pm (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm new file mode 100644 index 000000000..ba9192faf --- /dev/null +++ b/IkiWiki/Setup/Yaml.pm @@ -0,0 +1,43 @@ +#!/usr/bin/perl + +package IkiWiki::Setup::Yaml; + +use warnings; +use strict; +use IkiWiki; +use YAML; + +sub loaddump ($$) { + my $class=shift; + my $content=shift; + + IkiWiki::Setup::merge(Load($content)); +} + +sub gendump ($@) { + my $class=shift; + + "# IkiWiki::Setup::Yaml - YAML formatted setup file", + "#", + (map { "# $_" } @_), + "#", + IkiWiki::Setup::commented_dump(\&dumpline, "") +} + + +sub dumpline ($$$$) { + my $key=shift; + my $value=shift; + my $type=shift; + my $prefix=shift; + + $YAML::UseHeader=0; + my $dump=Dump({$key => $value}); + chomp $dump; + if (length $prefix) { + $dump=join("", map { $prefix.$_ } split(/\n/, $dump)); + } + return $dump; +} + +1 diff --git a/debian/changelog b/debian/changelog index 73f6fcff8..e020b380f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,7 @@ ikiwiki (3.20100313) UNRELEASED; urgency=low for security or other reasons. Closes: #447267 (Thanks to Aaron Wilson for the original patch.) * Allow wrappers to be built using tcc. + * Add support for setup files written in YAML. -- Joey Hess Sat, 13 Mar 2010 14:48:10 -0500 -- cgit v1.2.3 From 3b08789e6fb5809dd9b8f51f5c5e7df1d78e6930 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 16:09:07 -0400 Subject: load YAML on demand so as not to break test suite if YAML is not avilable --- IkiWiki/Setup/Yaml.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index ba9192faf..c7ff1988e 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -5,17 +5,21 @@ package IkiWiki::Setup::Yaml; use warnings; use strict; use IkiWiki; -use YAML; sub loaddump ($$) { my $class=shift; my $content=shift; + eval q{use YAML}; + die $@ if $@; IkiWiki::Setup::merge(Load($content)); } sub gendump ($@) { my $class=shift; + + eval q{use YAML}; + die $@ if $@; "# IkiWiki::Setup::Yaml - YAML formatted setup file", "#", -- cgit v1.2.3 From dc128dd829bfd08dba5d6929956d9064e7d37b81 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 17:54:58 -0400 Subject: fix newlines in commented defaults --- IkiWiki/Setup/Yaml.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index c7ff1988e..0fc273675 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -39,7 +39,7 @@ sub dumpline ($$$$) { my $dump=Dump({$key => $value}); chomp $dump; if (length $prefix) { - $dump=join("", map { $prefix.$_ } split(/\n/, $dump)); + $dump=join("\n", map { $prefix.$_ } split(/\n/, $dump)); } return $dump; } -- cgit v1.2.3 From aea5bf9b40f6676e93f987c28d9f2aa23608f5da Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 21 Mar 2010 14:51:47 -0400 Subject: reset setuptype to standard after an automator setup file is loaded so a standard file is generated (by default) --- IkiWiki/Setup/Automator.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 9da594e99..9f694e18e 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -39,6 +39,7 @@ sub sanitize_wikiname ($) { sub import (@) { my $this=shift; IkiWiki::Setup::merge({@_}); + $config{setuptype}='Standard'; if (! $config{force_overwrite}) { # Avoid overwriting any existing files. -- cgit v1.2.3 From 440e18bc15389780833fc8b9c04116a97eeaeaa2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 21 Mar 2010 14:59:21 -0400 Subject: reset setuptype first, actually so setup file can override default --- IkiWiki/Setup/Automator.pm | 2 +- debian/changelog | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 9f694e18e..e9a572450 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -38,8 +38,8 @@ sub sanitize_wikiname ($) { sub import (@) { my $this=shift; - IkiWiki::Setup::merge({@_}); $config{setuptype}='Standard'; + IkiWiki::Setup::merge({@_}); if (! $config{force_overwrite}) { # Avoid overwriting any existing files. diff --git a/debian/changelog b/debian/changelog index e020b380f..4d0639a58 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -ikiwiki (3.20100313) UNRELEASED; urgency=low +ikiwiki (3.20100320) UNRELEASED; urgency=low * websetup: Add websetup_unsafe to allow marking other settings as unsafe. -- cgit v1.2.3 From 271449062a2a3fa897aff7f5bb40d6b5da06a1a8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 24 Mar 2010 14:30:38 -0400 Subject: use YAML::Any to allow faster versions to be used if available --- IkiWiki/Setup/Yaml.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index 0fc273675..58cba4222 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -10,7 +10,7 @@ sub loaddump ($$) { my $class=shift; my $content=shift; - eval q{use YAML}; + eval q{use YAML::Any}; die $@ if $@; IkiWiki::Setup::merge(Load($content)); } @@ -18,7 +18,7 @@ sub loaddump ($$) { sub gendump ($@) { my $class=shift; - eval q{use YAML}; + eval q{use YAML::Any}; die $@ if $@; "# IkiWiki::Setup::Yaml - YAML formatted setup file", -- cgit v1.2.3 From 3166479fe4b170bf6ffd3f06c1422f65f7bbfe7e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 24 Mar 2010 14:53:32 -0400 Subject: fall back from YAML::Any to just YAML for portabilty to old YAML in Debian stable that lacks the former. --- IkiWiki/Setup/Yaml.pm | 2 ++ ikiwiki.in | 1 + 2 files changed, 3 insertions(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index 58cba4222..8ad44eb4a 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -11,6 +11,7 @@ sub loaddump ($$) { my $content=shift; eval q{use YAML::Any}; + eval q{use YAML} if $@; die $@ if $@; IkiWiki::Setup::merge(Load($content)); } @@ -19,6 +20,7 @@ sub gendump ($@) { my $class=shift; eval q{use YAML::Any}; + eval q{use YAML} if $@; die $@ if $@; "# IkiWiki::Setup::Yaml - YAML formatted setup file", diff --git a/ikiwiki.in b/ikiwiki.in index 7028bdb7d..a8343ed0f 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -102,6 +102,7 @@ sub getconfig () { die gettext("usage: --set-yaml var=value"), "\n"; } eval q{use YAML::Any}; + eval q{use YAML} if $@; die $@ if $@; $config{$var}=Load($val); }, -- cgit v1.2.3 From eb06a0135511fc5b5422f07ca5344ce114402a61 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 24 Mar 2010 16:12:35 -0400 Subject: use perl YAML for dumping Only it understands $YAML::UseHeader --- IkiWiki/Setup/Yaml.pm | 8 ++++---- debian/changelog | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index 8ad44eb4a..8b876e297 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -19,10 +19,6 @@ sub loaddump ($$) { sub gendump ($@) { my $class=shift; - eval q{use YAML::Any}; - eval q{use YAML} if $@; - die $@ if $@; - "# IkiWiki::Setup::Yaml - YAML formatted setup file", "#", (map { "# $_" } @_), @@ -37,7 +33,11 @@ sub dumpline ($$$$) { my $type=shift; my $prefix=shift; + eval q{use YAML::Old}; + eval q{use YAML} if $@; + die $@ if $@; $YAML::UseHeader=0; + my $dump=Dump({$key => $value}); chomp $dump; if (length $prefix) { diff --git a/debian/changelog b/debian/changelog index e7499b6f2..12dd0dc02 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -ikiwiki (3.20100320) UNRELEASED; urgency=low +ikiwiki (3.20100324) UNRELEASED; urgency=low * websetup: Add websetup_unsafe to allow marking other settings as unsafe. -- cgit v1.2.3 From 021952969933388021001b259462406cbc94c2a6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 24 Mar 2010 16:19:50 -0400 Subject: fix unicode with YAML::Syck Syck-- it doesn't use unicode by default?! Hello, 2010 calling.. --- IkiWiki/Setup/Yaml.pm | 1 + ikiwiki.in | 1 + 2 files changed, 2 insertions(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm index 8b876e297..904784728 100644 --- a/IkiWiki/Setup/Yaml.pm +++ b/IkiWiki/Setup/Yaml.pm @@ -13,6 +13,7 @@ sub loaddump ($$) { eval q{use YAML::Any}; eval q{use YAML} if $@; die $@ if $@; + $YAML::Syck::ImplicitUnicode=1; IkiWiki::Setup::merge(Load($content)); } diff --git a/ikiwiki.in b/ikiwiki.in index 1758399ea..b62962ad8 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -103,6 +103,7 @@ sub getconfig () { } eval q{use YAML::Any}; eval q{use YAML} if $@; + $YAML::Syck::ImplicitUnicode=1; die $@ if $@; $config{$var}=Load($val."\n"); }, -- cgit v1.2.3 From 0d07bca315d19e6e957072004393138db6f33d3d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 28 Mar 2010 17:17:07 -0400 Subject: fix printing of $@, which is clobbered by the call to gettext problem reported by viric --- IkiWiki/Setup/Automator.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index e9a572450..38e0d4422 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -124,9 +124,10 @@ sub import (@) { IkiWiki::run_hooks(checkconfig => sub { shift->() }); }; if ($@) { + my $err=$@; print STDERR sprintf(gettext("** Disabling plugin %s, since it is failing with this message:"), $plugin)."\n"; - print STDERR "$@\n"; + print STDERR "$err\n"; push @{$bakconfig{disable_plugins}}, $plugin; } } -- cgit v1.2.3 From 891238e075f0c4716ec8f51d5832745b0348ab77 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 29 Mar 2010 11:54:18 -0400 Subject: add warning messages about bzr and mercurial hooks that are not correctly setup --- IkiWiki/Setup/Automator.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 38e0d4422..402212150 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -72,9 +72,11 @@ sub import (@) { } elsif ($config{rcs} eq 'bzr') { # TODO + print STDERR "warning: do not know how to set up the bzr_wrapper hook!\n"; } elsif ($config{rcs} eq 'mercurial') { # TODO + print STDERR "warning: do not know how to set up the mercurial_wrapper hook!\n"; } elsif ($config{rcs} eq 'cvs') { $config{cvs_wrapper}=$config{repository}."/CVSROOT/post-commit"; -- cgit v1.2.3 From e466d11fd363b4758bc4f624ff73664d89891f9e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 29 Mar 2010 13:17:32 -0400 Subject: add warning about incomplete tla support --- IkiWiki/Setup/Automator.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'IkiWiki/Setup') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 402212150..2dcb424e5 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -78,6 +78,10 @@ sub import (@) { # TODO print STDERR "warning: do not know how to set up the mercurial_wrapper hook!\n"; } + elsif ($config{rcs} eq 'tla') { + # TODO + print STDERR "warning: do not know how to set up the tla_wrapper hook!\n"; + } elsif ($config{rcs} eq 'cvs') { $config{cvs_wrapper}=$config{repository}."/CVSROOT/post-commit"; } -- cgit v1.2.3