From 94c59d3254dd97be541cd8ff03ccf3c29b5a55b8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 2 Aug 2008 23:06:25 -0400 Subject: [PATCH] collect a hash of shown fields Need to do this to know what fields to take from CGI. (Can't trust that only safe ones are sent..) --- .IkiWiki.pm.swp | Bin 16384 -> 0 bytes IkiWiki/Plugin/websetup.pm | 39 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) delete mode 100644 .IkiWiki.pm.swp diff --git a/.IkiWiki.pm.swp b/.IkiWiki.pm.swp deleted file mode 100644 index adf830d94a5f4ed131610662776020c1c906d086..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3Ym6jS6~~L0ILaz&h>s6=x2K2cafj(y*ae+&mLV{(1N&n3!Rj#EsqVTnQ%rYN zPgOO&W7|ti)K3U*;wHpMSh8Ua0Y3mH#wZ_%A;t%oXpF(cO%x+hK1d<~7XMw05}m#%xO>eQ+KJ@?*oZ_gC_4~*_q*Y|C<_*`yT8$NSv`>WQK)|Q(r>uz7q zN%dNv8Q-xh_F7k2))6t74}((PopI}sADwaU}zrFW+aqza@8qza@8qza@8qza@8qzb(66o{&qS?}WYh45{-AmLp;-{tsd zQhp~XZ{h;E=55L+`F<`b|0gNWU`WotMfnlFKXy@Eev|UUl%GnOW_wE zv8?-`1`*r^8{nA@meqh6*bEoLPcCC^4_jdiWZ{!=5&ZSTmi24+75oq$g`@CQxD#%J z0k{r&;0m|^{`?`Xg`@B_Xo3&pa4Yn{+Z~qmcX$zg56{7qa2x{AupjP#Vd#ZV!RZgO z*8tDLlkfvL0S~|tH~?3Jg3IADc=uAvdIkOnC!qlz9D*;ycGv=)aGHIL=i$fj7(5CO zKm#<$zQ+}C30wegurKlw{1zUEZ$J%ZVH`%F15UA@@(kPu_ks^I@Ff_5E$|wfDKEnx z;CJv0JO&TKEI66UdU590DkyH<|OrCHYtBfDJYsrhi)4)pxrr?hU2?`h+3>w;MXf3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i`&Oi*e^*^`oI&p*W2oi}Xy(F&_=I#Ocz zj7FtLwd+a7r>5Gb+MaB^eN*~WhuF}EU6xksxZ3KFC1=aPkm;GICY2&Xt72J4WpNQ} z@_*cDMa_~%FTC6NX|?uN*J!pcuA?FTN6nV_ze>9$b4xrV%hD{DEsSrT=v936^EF(c zOD)8L?2wza@R`lc&kW0_s-#CaKKpah-;6C5;#oN`?Ik_d^jeW8c5ABa7jxMvKFL+R zvf2#nifkaX>D;S#L%G@fGGuytwi;V!b=P`2=2|o5f(zOCeE>bXFa@_Naf?2KXVtUz zCV6!pE-_Ws-V}4#{8LT;maw)<)5`Qwl^brDd&0Q$OJ&O)b{giTZ`I|plYw7J#1k*q zN+*&wO2$>ATBe76TYm0ie2G=O>MAwwMKXBACx#XUzNu-%1DWhpNVA&zhcd>eeEjN) z_inwmxGK#WUv?zyJakuIzO&O*$+;n_@;8hh%1>;{nrhPzaQkNloOVkEx;#iO3F+ZsOO&}y`P@ocIaWLT7NTU0lo*rto`PGWIr IxG-q_7i_y9oB#j- diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 150c792a5..64c4d0991 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -78,15 +78,19 @@ sub showfields ($$$@) { #{{{ push @show, $key, \%info; } - return 0 unless @show; + return unless @show; my $section=defined $plugin ? $plugin." ".gettext("plugin") : gettext("main"); + my %shownfields; if (defined $plugin) { - if (! showplugintoggle($form, $plugin, $enabled, $section) && ! $enabled) { + if (showplugintoggle($form, $plugin, $enabled, $section)) { + $shownfields{"enable.$plugin"}=$plugin; + } + elsif (! $enabled) { # plugin not enabled and cannot be, so skip showing # its configuration - return 0; + return; } } @@ -149,9 +153,12 @@ sub showfields ($$$@) { #{{{ $form->field(name => $name, disabled => 1); $form->text(gettext("Note: Disabled options cannot be configured here, but only by editing the setup file.")); } + else { + $shownfields{$name}=$key; + } } - return 1; + return %shownfields; } #}}} sub showplugintoggle ($$$$) { #{{{ @@ -170,7 +177,7 @@ sub showplugintoggle ($$$$) { #{{{ } $form->field( - name => "enable.$plugin", + ame => "enable.$plugin", label => "", type => "checkbox", options => [ [ 1 => sprintf(gettext("enable %s?"), $plugin) ] ], @@ -217,7 +224,7 @@ sub showform ($$) { #{{{ $form->field(name => "do", type => "hidden", value => "setup", force => 1); - showfields($form, undef, undef, IkiWiki::getsetup()); + my %fields=showfields($form, undef, undef, IkiWiki::getsetup()); # record all currently enabled plugins before all are loaded my %enabled_plugins=%IkiWiki::loaded_plugins; @@ -232,19 +239,31 @@ sub showform ($$) { #{{{ # 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}); + my %shown=showfields($form, $plugin, $enabled_plugins{$plugin}, @{$setup}); + if (%shown) { + delete $plugins{$plugin}; + $fields{$_}=$shown{$_} foreach keys %shown; + } } # list all remaining plugins (with no setup options) at the end - showplugintoggle($form, $_, $enabled_plugins{$_}, gettext("other plugins")) - foreach sort keys %plugins; + foreach (sort keys %plugins) { + if (showplugintoggle($form, $_, $enabled_plugins{$_}, gettext("other plugins"))) { + $fields{"enable.$_"}=$_; + } + } if ($form->submitted eq "Cancel") { IkiWiki::redirect($cgi, $config{url}); return; } elsif ($form->submitted eq 'Save Setup' && $form->validate) { - # TODO + foreach my $field (keys %fields) { + # TODO plugin enable/disable + next if $field=~/^enable\./; # plugin + $config{$fields{$field}}=$form->field($field); + } + # TODO save to real path IkiWiki::Setup::dump("/tmp/s"); $form->text(gettext("Setup saved.")); } -- 2.26.2