websetup form display done
parent
b0f4767448
commit
4708aeceb3
|
@ -13,7 +13,8 @@ use open qw{:utf8 :std};
|
||||||
|
|
||||||
use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
|
use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
|
||||||
%pagestate %renderedfiles %oldrenderedfiles %pagesources
|
%pagestate %renderedfiles %oldrenderedfiles %pagesources
|
||||||
%destsources %depends %hooks %forcerebuild $gettext_obj};
|
%destsources %depends %hooks %forcerebuild $gettext_obj
|
||||||
|
%loaded_plugins};
|
||||||
|
|
||||||
use Exporter q{import};
|
use Exporter q{import};
|
||||||
our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
|
our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
|
||||||
|
@ -486,6 +487,7 @@ sub loadplugin ($) { #{{{
|
||||||
if (defined $dir && -x "$dir/plugins/$plugin") {
|
if (defined $dir && -x "$dir/plugins/$plugin") {
|
||||||
require IkiWiki::Plugin::external;
|
require IkiWiki::Plugin::external;
|
||||||
import IkiWiki::Plugin::external "$dir/plugins/$plugin";
|
import IkiWiki::Plugin::external "$dir/plugins/$plugin";
|
||||||
|
$loaded_plugins{$plugin}=1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,6 +497,7 @@ sub loadplugin ($) { #{{{
|
||||||
if ($@) {
|
if ($@) {
|
||||||
error("Failed to load plugin $mod: $@");
|
error("Failed to load plugin $mod: $@");
|
||||||
}
|
}
|
||||||
|
$loaded_plugins{$plugin}=1;
|
||||||
return 1;
|
return 1;
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ sub import { #{{{
|
||||||
sub getsetup () { #{{{
|
sub getsetup () { #{{{
|
||||||
return
|
return
|
||||||
anonok_pagespec => {
|
anonok_pagespec => {
|
||||||
type => "string",
|
type => "pagespec",
|
||||||
example => "*/discussion",
|
example => "*/discussion",
|
||||||
description => "PageSpec to limit which pages anonymous users can edit",
|
description => "PageSpec to limit which pages anonymous users can edit",
|
||||||
description_html => htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).
|
description_html => htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).
|
||||||
|
|
|
@ -22,7 +22,7 @@ sub getsetup () { #{{{
|
||||||
rebuild => 0,
|
rebuild => 0,
|
||||||
},
|
},
|
||||||
allowed_attachments => {
|
allowed_attachments => {
|
||||||
type => "string",
|
type => "pagespec",
|
||||||
example => "mimetype(image/*) and maxsize(50kb)",
|
example => "mimetype(image/*) and maxsize(50kb)",
|
||||||
description => "enhanced PageSpec specifying what attachments are allowed",
|
description => "enhanced PageSpec specifying what attachments are allowed",
|
||||||
description_html => htmllink("", "",
|
description_html => htmllink("", "",
|
||||||
|
|
|
@ -15,7 +15,7 @@ sub import { #{{{
|
||||||
sub getsetup () { #{{{
|
sub getsetup () { #{{{
|
||||||
return
|
return
|
||||||
locked_pages => {
|
locked_pages => {
|
||||||
type => "string",
|
type => "pagespec",
|
||||||
example => "!*/Discussion",
|
example => "!*/Discussion",
|
||||||
description => "PageSpec controlling which pages are locked",
|
description => "PageSpec controlling which pages are locked",
|
||||||
description_html => htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).
|
description_html => htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).
|
||||||
|
|
|
@ -5,46 +5,114 @@ use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use IkiWiki 2.00;
|
use IkiWiki 2.00;
|
||||||
|
|
||||||
|
my @rcs_plugins=(qw{git svn bzr mercurial monotone tla norcs});
|
||||||
|
my @default_force_plugins=(qw{amazon_s3});
|
||||||
|
|
||||||
sub import { #{{{
|
sub import { #{{{
|
||||||
hook(type => "sessioncgi", id => "websetup",
|
hook(type => "checkconfig", id => "websetup", call => \&checkconfig);
|
||||||
call => \&sessioncgi);
|
hook(type => "getsetup", id => "websetup", call => \&getsetup);
|
||||||
|
hook(type => "sessioncgi", id => "websetup", call => \&sessioncgi);
|
||||||
hook(type => "formbuilder_setup", id => "websetup",
|
hook(type => "formbuilder_setup", id => "websetup",
|
||||||
call => \&formbuilder_setup);
|
call => \&formbuilder_setup);
|
||||||
} # }}}
|
} # }}}
|
||||||
|
|
||||||
sub addfields ($$@) {
|
sub getsetup () { #{{{
|
||||||
my $form=shift;
|
return
|
||||||
my $section=shift;
|
websetup_force_plugins => {
|
||||||
|
type => "string",
|
||||||
|
example => \@default_force_plugins,
|
||||||
|
description => "list of plugins that cannot be enabled/disabled via the web interface",
|
||||||
|
safe => 0,
|
||||||
|
rebuild => 0,
|
||||||
|
},
|
||||||
|
} #}}}
|
||||||
|
|
||||||
|
sub checkconfig () { #{{{
|
||||||
|
if (! exists $config{websetup_force_plugins}) {
|
||||||
|
$config{websetup_force_plugins}=\@default_force_plugins;
|
||||||
|
}
|
||||||
|
} #}}}
|
||||||
|
|
||||||
|
sub formatexample ($) { #{{{
|
||||||
|
my $example=shift;
|
||||||
|
|
||||||
|
if (defined $example && ! ref $example && length $example) {
|
||||||
|
return "<br/ ><small>Example: <tt>$example</tt></small>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
} #}}}
|
||||||
|
|
||||||
|
sub showfields ($$$@) { #{{{
|
||||||
|
my $form=shift;
|
||||||
|
my $plugin=shift;
|
||||||
|
my $enabled=shift;
|
||||||
|
|
||||||
|
my @show;
|
||||||
while (@_) {
|
while (@_) {
|
||||||
my $key=shift;
|
my $key=shift;
|
||||||
my %info=%{shift()};
|
my %info=%{shift()};
|
||||||
|
|
||||||
next if ! $info{safe} || $info{type} eq "internal";
|
# skip complex, unsafe, or internal settings
|
||||||
|
next if ref $config{$key} || ! $info{safe} || $info{type} eq "internal";
|
||||||
|
# these are handled specially, so don't show
|
||||||
|
next if $key eq 'add_plugins' || $key eq 'disable_plugins';
|
||||||
|
|
||||||
|
push @show, $key, \%info;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0 unless @show;
|
||||||
|
|
||||||
|
my $section=defined $plugin ? $plugin." ".gettext("plugin") : gettext("main");
|
||||||
|
|
||||||
|
if (defined $plugin) {
|
||||||
|
if (! showplugintoggle($form, $plugin, $enabled, $section) && ! $enabled) {
|
||||||
|
# plugin not enabled and cannot be, so skip showing
|
||||||
|
# its configuration
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (@show) {
|
||||||
|
my $key=shift @show;
|
||||||
|
my %info=%{shift @show};
|
||||||
|
|
||||||
my $description=exists $info{description_html} ? $info{description_html} : $info{description};
|
my $description=exists $info{description_html} ? $info{description_html} : $info{description};
|
||||||
|
|
||||||
my $value=$config{$key};
|
my $value=$config{$key};
|
||||||
# multiple plugins can have the same key
|
# multiple plugins can have the same field
|
||||||
my $name=$section.".".$key;
|
my $name=defined $plugin ? $plugin.".".$key : $key;
|
||||||
|
|
||||||
if ($info{type} eq "string") {
|
if ($info{type} eq "string") {
|
||||||
$form->field(
|
$form->field(
|
||||||
name => $name,
|
name => $name,
|
||||||
label => $description,
|
label => $description,
|
||||||
comment => exists $info{example} && length $info{example} && $info{example} ne $value ? "<br/ ><small>Example: <tt>$info{example}</tt></small>" : "",
|
comment => defined $value && length $value ? "" : formatexample($info{example}),
|
||||||
type => "text",
|
type => "text",
|
||||||
value => $value,
|
value => $value,
|
||||||
size => 60,
|
size => 60,
|
||||||
fieldset => $section,
|
fieldset => $section,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
elsif ($info{type} eq "pagespec") {
|
||||||
|
$form->field(
|
||||||
|
name => $name,
|
||||||
|
label => $description,
|
||||||
|
comment => formatexample($info{example}),
|
||||||
|
type => "text",
|
||||||
|
value => $value,
|
||||||
|
size => 60,
|
||||||
|
validate => \&IkiWiki::pagespec_valid,
|
||||||
|
fieldset => $section,
|
||||||
|
);
|
||||||
|
}
|
||||||
elsif ($info{type} eq "integer") {
|
elsif ($info{type} eq "integer") {
|
||||||
$form->field(
|
$form->field(
|
||||||
name => $name,
|
name => $name,
|
||||||
label => $description,
|
label => $description,
|
||||||
type => "text",
|
type => "text",
|
||||||
value => $value,
|
value => $value,
|
||||||
|
size => 5,
|
||||||
validate => '/^[0-9]+$/',
|
validate => '/^[0-9]+$/',
|
||||||
fieldset => $section,
|
fieldset => $section,
|
||||||
);
|
);
|
||||||
|
@ -60,7 +128,29 @@ sub addfields ($$@) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return 1;
|
||||||
|
} #}}}
|
||||||
|
|
||||||
|
sub showplugintoggle ($$$$) { #{{{
|
||||||
|
my $form=shift;
|
||||||
|
my $plugin=shift;
|
||||||
|
my $enabled=shift;
|
||||||
|
my $section=shift;
|
||||||
|
|
||||||
|
return 0 if (grep { $_ eq $plugin } @{$config{websetup_force_plugins}}, @rcs_plugins);
|
||||||
|
|
||||||
|
$form->field(
|
||||||
|
name => "enable.$plugin",
|
||||||
|
label => "",
|
||||||
|
type => "checkbox",
|
||||||
|
options => [ [ 1 => sprintf(gettext("enable %s?"), $plugin) ] ],
|
||||||
|
value => $enabled,
|
||||||
|
fieldset => $section,
|
||||||
|
);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} #}}}
|
||||||
|
|
||||||
sub showform ($$) { #{{{
|
sub showform ($$) { #{{{
|
||||||
my $cgi=shift;
|
my $cgi=shift;
|
||||||
|
@ -81,6 +171,7 @@ sub showform ($$) { #{{{
|
||||||
charset => "utf-8",
|
charset => "utf-8",
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
javascript => 0,
|
javascript => 0,
|
||||||
|
reset => 1,
|
||||||
params => $cgi,
|
params => $cgi,
|
||||||
action => $config{cgiurl},
|
action => $config{cgiurl},
|
||||||
template => {type => 'div'},
|
template => {type => 'div'},
|
||||||
|
@ -97,14 +188,28 @@ sub showform ($$) { #{{{
|
||||||
|
|
||||||
$form->field(name => "do", type => "hidden", value => "setup",
|
$form->field(name => "do", type => "hidden", value => "setup",
|
||||||
force => 1);
|
force => 1);
|
||||||
addfields($form, gettext("main"), IkiWiki::getsetup());
|
showfields($form, undef, undef, IkiWiki::getsetup());
|
||||||
|
|
||||||
|
# record all currently enabled plugins before all are loaded
|
||||||
|
my %enabled_plugins=%IkiWiki::loaded_plugins;
|
||||||
|
|
||||||
|
# per-plugin setup
|
||||||
require IkiWiki::Setup;
|
require IkiWiki::Setup;
|
||||||
|
my %plugins=map { $_ => 1 } IkiWiki::listplugins();
|
||||||
foreach my $pair (IkiWiki::Setup::getsetup()) {
|
foreach my $pair (IkiWiki::Setup::getsetup()) {
|
||||||
my $plugin=$pair->[0];
|
my $plugin=$pair->[0];
|
||||||
my $setup=$pair->[1];
|
my $setup=$pair->[1];
|
||||||
addfields($form, $plugin." ".gettext("plugin"), @{$setup});
|
|
||||||
|
# skip all rcs plugins except for the one in use
|
||||||
|
next if $plugin ne $config{rcs} && grep { $_ eq $plugin } @rcs_plugins;
|
||||||
|
|
||||||
|
delete $plugins{$plugin} if showfields($form, $plugin, $enabled_plugins{$plugin}, @{$setup});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# list all remaining plugins (with no setup options) at the end
|
||||||
|
showplugintoggle($form, $_, $enabled_plugins{$_}, gettext("other plugins"))
|
||||||
|
foreach sort keys %plugins;
|
||||||
|
|
||||||
if ($form->submitted eq "Cancel") {
|
if ($form->submitted eq "Cancel") {
|
||||||
IkiWiki::redirect($cgi, $config{url});
|
IkiWiki::redirect($cgi, $config{url});
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,8 +32,7 @@ sub dumpline ($$$$) { #{{{
|
||||||
# avoid quotes
|
# avoid quotes
|
||||||
$dumpedvalue=$value;
|
$dumpedvalue=$value;
|
||||||
}
|
}
|
||||||
elsif ($type eq 'string' && ref $value eq 'ARRAY' && @$value &&
|
elsif (ref $value eq 'ARRAY' && @$value && ! grep { /[^-A-Za-z0-9_]/ } @$value) {
|
||||||
! grep { /[^-A-Za-z0-9_]/ } @$value) {
|
|
||||||
# dump simple array as qw{}
|
# dump simple array as qw{}
|
||||||
$dumpedvalue="[qw{ ".join(" ", @$value)." }]";
|
$dumpedvalue="[qw{ ".join(" ", @$value)." }]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,9 +396,10 @@ describing the option. For example:
|
||||||
rebuild => 0,
|
rebuild => 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
* `type` can be "boolean", "string", "integer", or "internal"
|
* `type` can be "boolean", "string", "integer", "pagespec",
|
||||||
(used for values that are not user-visible). The type is the type of
|
or "internal" (used for values that are not user-visible). The type is
|
||||||
the leaf values; the `%config` option may be an array or hash of these.
|
the type of the leaf values; the `%config` option may be an array or
|
||||||
|
hash of these.
|
||||||
* `example` can be set to an example value.
|
* `example` can be set to an example value.
|
||||||
* `description` is a short description of the option.
|
* `description` is a short description of the option.
|
||||||
* `description_html` is an optional short description, that can contain html
|
* `description_html` is an optional short description, that can contain html
|
||||||
|
|
|
@ -18,7 +18,7 @@ The plugin could have these config options:
|
||||||
websetup_exclude => [qw{option_baz}],
|
websetup_exclude => [qw{option_baz}],
|
||||||
# list of plugins that cannot be enabled/disabled via the web
|
# list of plugins that cannot be enabled/disabled via the web
|
||||||
# interface
|
# interface
|
||||||
websetup_unconfigurable_plugins => [qw{git svn bzr mercurial monotone tla}]
|
websetup_force_plugins => [qw{git svn bzr mercurial monotone tla}]
|
||||||
|
|
||||||
Leaning toward just making it write out to the same setup file, rather than
|
Leaning toward just making it write out to the same setup file, rather than
|
||||||
writing to a subsidiary setup file. However, this would mean that any
|
writing to a subsidiary setup file. However, this would mean that any
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2008-08-01 17:10-0400\n"
|
"POT-Creation-Date: 2008-08-02 15:27-0400\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -24,7 +24,7 @@ msgstr ""
|
||||||
msgid "login failed, perhaps you need to turn on cookies?"
|
msgid "login failed, perhaps you need to turn on cookies?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:189 ../IkiWiki/CGI.pm:539
|
#: ../IkiWiki/CGI.pm:189 ../IkiWiki/CGI.pm:538
|
||||||
msgid "Your login session has expired."
|
msgid "Your login session has expired."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -40,38 +40,38 @@ msgstr ""
|
||||||
msgid "Admin"
|
msgid "Admin"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:280
|
#: ../IkiWiki/CGI.pm:279
|
||||||
msgid "Preferences saved."
|
msgid "Preferences saved."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:339
|
#: ../IkiWiki/CGI.pm:338
|
||||||
#, perl-format
|
#, perl-format
|
||||||
msgid "%s is not an editable page"
|
msgid "%s is not an editable page"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:450 ../IkiWiki/Plugin/brokenlinks.pm:24
|
#: ../IkiWiki/CGI.pm:449 ../IkiWiki/Plugin/brokenlinks.pm:24
|
||||||
#: ../IkiWiki/Plugin/inline.pm:306 ../IkiWiki/Plugin/opendiscussion.pm:17
|
#: ../IkiWiki/Plugin/inline.pm:306 ../IkiWiki/Plugin/opendiscussion.pm:17
|
||||||
#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:78
|
#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:78
|
||||||
#: ../IkiWiki/Render.pm:148
|
#: ../IkiWiki/Render.pm:148
|
||||||
msgid "discussion"
|
msgid "discussion"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:506
|
#: ../IkiWiki/CGI.pm:505
|
||||||
#, perl-format
|
#, perl-format
|
||||||
msgid "creating %s"
|
msgid "creating %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:524 ../IkiWiki/CGI.pm:552 ../IkiWiki/CGI.pm:562
|
#: ../IkiWiki/CGI.pm:523 ../IkiWiki/CGI.pm:551 ../IkiWiki/CGI.pm:561
|
||||||
#: ../IkiWiki/CGI.pm:597 ../IkiWiki/CGI.pm:642
|
#: ../IkiWiki/CGI.pm:596 ../IkiWiki/CGI.pm:641
|
||||||
#, perl-format
|
#, perl-format
|
||||||
msgid "editing %s"
|
msgid "editing %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:667
|
#: ../IkiWiki/CGI.pm:666
|
||||||
msgid "You are banned."
|
msgid "You are banned."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/CGI.pm:784 ../IkiWiki/CGI.pm:785 ../IkiWiki.pm:1096
|
#: ../IkiWiki/CGI.pm:783 ../IkiWiki/CGI.pm:784 ../IkiWiki.pm:1096
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -707,6 +707,22 @@ msgstr ""
|
||||||
msgid "failed to generate image from code"
|
msgid "failed to generate image from code"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../IkiWiki/Plugin/websetup.pm:120
|
||||||
|
msgid "you are not logged in as an admin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../IkiWiki/Plugin/websetup.pm:149
|
||||||
|
msgid "main"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../IkiWiki/Plugin/websetup.pm:158
|
||||||
|
msgid "plugin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../IkiWiki/Plugin/websetup.pm:168
|
||||||
|
msgid "Setup saved."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/Render.pm:276 ../IkiWiki/Render.pm:297
|
#: ../IkiWiki/Render.pm:276 ../IkiWiki/Render.pm:297
|
||||||
#, perl-format
|
#, perl-format
|
||||||
msgid "skipping bad filename %s"
|
msgid "skipping bad filename %s"
|
||||||
|
|
Loading…
Reference in New Issue