From: Joey Hess Date: Sun, 3 Aug 2008 02:46:16 +0000 (-0400) Subject: show unsafe options (RO) by default X-Git-Tag: 2.60~117 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/c762b65ce42c18f026a16ee702cec5dc168a39be show unsafe options (RO) by default Small data leak, but only to admins, and I think it's worth it to see the stuff that cannot be configured. --- diff --git a/.IkiWiki.pm.swp b/.IkiWiki.pm.swp new file mode 100644 index 000000000..adf830d94 Binary files /dev/null and b/.IkiWiki.pm.swp differ diff --git a/IkiWiki.pm b/IkiWiki.pm index 241a7c036..a2b4d8d80 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -92,7 +92,7 @@ sub getsetup () { #{{{ type => "string", default => '', example => "/var/www/wiki/ikiwiki.cgi", - description => "cgi executable to generate", + description => "cgi wrapper to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 99025a973..0b5059292 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -36,7 +36,7 @@ sub getsetup () { #{{{ bzr_wrapper => { type => "string", #example => "", # FIXME add example - description => "bzr post-commit executable to generate", + description => "bzr post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index d1c1165e0..b6ad43167 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -45,7 +45,7 @@ sub getsetup () { #{{{ git_wrapper => { type => "string", example => "/git/wiki.git/hooks/post-update", - description => "git post-update executable to generate", + description => "git post-update hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index d2c34fa6a..23bebaaad 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -36,7 +36,7 @@ sub getsetup () { #{{{ mercurial_wrapper => { type => "string", #example => # FIXME add example - description => "mercurial post-commit executable to generate", + description => "mercurial post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 4b9be316a..bdc6ee786 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -68,7 +68,7 @@ sub getsetup () { #{{{ mtn_wrapper => { type => "string", example => "/srv/mtn/wiki/_MTN/ikiwiki-netsync-hook", - description => "monotone netsync hook executable to generate", + description => "monotone netsync hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index 51683704c..c51b0f181 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -58,7 +58,7 @@ sub getsetup () { #{{{ svn_wrapper => { type => "string", example => "/svn/wikirepo/hooks/post-commit", - description => "svn post-commit executable to generate", + description => "svn post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index 6faaecccc..1c2763359 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -34,7 +34,7 @@ sub getsetup () { #{{{ tla_wrapper => { type => "string", #example => "", # TODO example - description => "tla post-commit executable to generate", + description => "tla post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 6aab04e32..150c792a5 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -13,6 +13,7 @@ my @default_force_plugins=(qw{amazon_s3 external}); sub import { #{{{ hook(type => "getsetup", id => "websetup", call => \&getsetup); + hook(type => "checkconfig", id => "websetup", call => \&checkconfig); hook(type => "sessioncgi", id => "websetup", call => \&sessioncgi); hook(type => "formbuilder_setup", id => "websetup", call => \&formbuilder_setup); @@ -27,12 +28,29 @@ sub getsetup () { #{{{ safe => 0, rebuild => 0, }, + websetup_show_unsafe => { + type => "boolean", + example => 1, + description => "show unsafe settings, read-only, in web interface?", + safe => 0, + rebuild => 0, + }, +} #}}} + +sub checkconfig () { #{{{ + if (! exists $config{websetup_show_unsafe}) { + $config{websetup_show_unsafe}=1; + } } #}}} -sub formatexample ($) { #{{{ +sub formatexample ($$) { #{{{ my $example=shift; + my $value=shift; - if (defined $example && ! ref $example && length $example) { + if (defined $value && length $value) { + return ""; + } + elsif (defined $example && ! ref $example && length $example) { return "
Example: $example"; } else { @@ -50,8 +68,10 @@ sub showfields ($$$@) { #{{{ my $key=shift; my %info=%{shift()}; - # skip complex, unsafe, or internal settings - next if ref $config{$key} || ! $info{safe} || $info{type} eq "internal"; + # skip complex or internal settings + next if ref $config{$key} || ref $info{example} || $info{type} eq "internal"; + # maybe skip unsafe settings + next if ! $info{safe} && ! $config{websetup_show_unsafe}; # these are handled specially, so don't show next if $key eq 'add_plugins' || $key eq 'disable_plugins'; @@ -83,7 +103,7 @@ sub showfields ($$$@) { #{{{ $form->field( name => $name, label => $description, - comment => defined $value && length $value ? "" : formatexample($info{example}), + comment => formatexample($info{example}, $value), type => "text", value => $value, size => 60, @@ -94,7 +114,7 @@ sub showfields ($$$@) { #{{{ $form->field( name => $name, label => $description, - comment => formatexample($info{example}), + comment => formatexample($info{example}, $value), type => "text", value => $value, size => 60, @@ -106,6 +126,7 @@ sub showfields ($$$@) { #{{{ $form->field( name => $name, label => $description, + comment => formatexample($info{example}, $value), type => "text", value => $value, size => 5, @@ -123,6 +144,11 @@ sub showfields ($$$@) { #{{{ fieldset => $section, ); } + + if (! $info{safe}) { + $form->field(name => $name, disabled => 1); + $form->text(gettext("Note: Disabled options cannot be configured here, but only by editing the setup file.")); + } } return 1; diff --git a/websetup.pm b/websetup.pm new file mode 120000 index 000000000..8ca7a8a64 --- /dev/null +++ b/websetup.pm @@ -0,0 +1 @@ +/home/joey/src/ikiwiki/IkiWiki/Plugin/websetup.pm \ No newline at end of file