]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
websetup: Add websetup_unsafe to allow marking other settings as unsafe.
authorJoey Hess <joey@gnu.kitenet.net>
Sat, 13 Mar 2010 20:08:00 +0000 (15:08 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Sat, 13 Mar 2010 20:08:00 +0000 (15:08 -0500)
IkiWiki/Plugin/websetup.pm
debian/changelog
doc/plugins/websetup.mdwn

index 5c19c9b63dad88e54cd2deca80ee3e3d08a73f3c..d444c0a3d2b67e228737d592d66a04b082876960 100644 (file)
@@ -27,6 +27,13 @@ sub getsetup () {
                        safe => 0,
                        rebuild => 0,
                },
+               websetup_unsafe => {
+                       type => "string",
+                       example => [],
+                       description => "list of additional setup field keys to treat as unsafe",
+                       safe => 0,
+                       rebuild => 0,
+               },
                websetup_show_unsafe => {
                        type => "boolean",
                        example => 1,
@@ -57,6 +64,12 @@ sub formatexample ($$) {
        }
 }
 
+sub issafe ($) {
+       my $key=shift;
+
+       return ! grep { $_ eq $key } @{$config{websetup_unsafe}};
+}
+
 sub showfields ($$$@) {
        my $form=shift;
        my $plugin=shift;
@@ -78,7 +91,8 @@ sub showfields ($$$@) {
                # XXX hashes not handled yet
                next if ref $config{$key} && ref $config{$key} eq 'HASH' || ref $info{example} eq 'HASH';
                # maybe skip unsafe settings
-               next if ! $info{safe} && ! ($config{websetup_show_unsafe} && $config{websetup_advanced});
+               next if ! ($config{websetup_show_unsafe} && $config{websetup_advanced}) &&
+                       (! $info{safe} || ! issafe($key));
                # maybe skip advanced settings
                next if $info{advanced} && ! $config{websetup_advanced};
                # these are handled specially, so don't show
@@ -156,7 +170,7 @@ sub showfields ($$$@) {
 
                if (ref $value eq 'ARRAY' || ref $info{example} eq 'ARRAY') {
                        $value=[(ref $value eq 'ARRAY' ? map { Encode::encode_utf8($_) }  @{$value} : "")];
-                       push @$value, "", "" if $info{safe}; # blank items for expansion
+                       push @$value, "", "" if $info{safe} && issafe($key); # blank items for expansion
                }
                else {
                        $value=Encode::encode_utf8($value);
@@ -210,7 +224,7 @@ sub showfields ($$$@) {
                        }
                }
                
-               if (! $info{safe}) {
+               if (! $info{safe} || ! issafe($key)) {
                        $form->field(name => $name, disabled => 1);
                }
                else {
@@ -346,7 +360,7 @@ sub showform ($$) {
                                @value=0;
                        }
                
-                       if (! $info{safe}) {
+                       if (! $info{safe} || ! issafe($key)) {
                                error("unsafe field $key"); # should never happen
                        }
                
index 7fdbbcb63695ccf844091e27aa2a084454804f22..9e779bb18efae066258821e280ca944ed7f3afba 100644 (file)
@@ -1,3 +1,10 @@
+ikiwiki (3.20100313) UNRELEASED; urgency=low
+
+  * websetup: Add websetup_unsafe to allow marking other settings
+    as unsafe.
+
+ -- Joey Hess <joeyh@debian.org>  Sat, 13 Mar 2010 14:48:10 -0500
+
 ikiwiki (3.20100312) unstable; urgency=HIGH
 
   * Fix utf8 issues in calls to md5_hex.
index f1756ba8ff9675d27a394688a09728e432cc4996..b4d23ba9cfbf85d08dce8a3556ffc45730a29263 100644 (file)
@@ -16,7 +16,8 @@ enabled and disabled using it too. Some settings are not considered safe
 enough to be manipulated over the web; these are still shown, by default,
 but cannot be modified. To hide them, set `websetup_show_unsafe` to false
 in the setup file. A few settings have too complex a data type to be
-configured via the web.
+configured via the web. To mark additional settings as unsafe, you can
+list them in `websetup_unsafe`.
 
 Plugins that should not be enabled/disabled via the web interface can be
 listed in `websetup_force_plugins` in the setup file.