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
$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 ($) {
# 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;
* 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 <joeyh@debian.org> Tue, 26 Jan 2010 22:25:33 -0500
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?",
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
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