X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/54f600af14bf6dc067ffc30ec6f22d517001fe99..9ef5139918dbe3f4cf0b3310c76dd31090925406:/IkiWiki/Plugin/websetup.pm diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index d444c0a3d..0a3d90aec 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -102,7 +102,7 @@ sub showfields ($$$@) { } my $section=defined $plugin - ? sprintf(gettext("%s plugin:"), $plugininfo{section}).$plugin + ? sprintf(gettext("%s plugin:"), $plugininfo{section})." ".$plugin : "main"; my %enabledfields; my $shownfields=0; @@ -219,7 +219,8 @@ sub showfields ($$$@) { options => [ [ 1 => $description ] ], fieldset => $section, ); - if (! $form->submitted) { + if (! $form->submitted || + ($info{advanced} && $form->submitted eq 'Advanced Mode')) { $form->field(name => $name, value => $value); } } @@ -253,18 +254,16 @@ sub enable_plugin ($) { sub disable_plugin ($) { my $plugin=shift; - if (grep { $_ eq $plugin } @{$config{add_plugins}}) { - $config{add_plugins}=[grep { $_ ne $plugin } @{$config{add_plugins}}]; - } - else { - push @{$config{disable_plugins}}, $plugin; - } + $config{add_plugins}=[grep { $_ ne $plugin } @{$config{add_plugins}}]; + push @{$config{disable_plugins}}, $plugin; } sub showform ($$) { my $cgi=shift; my $session=shift; + IkiWiki::needsignin($cgi, $session); + if (! defined $session->param("name") || ! IkiWiki::is_admin($session->param("name"))) { error(gettext("you are not logged in as an admin")); @@ -289,14 +288,15 @@ sub showform ($$) { fieldsets => [ [main => gettext("main")], ], - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), template => {type => 'div'}, - stylesheet => IkiWiki::baseurl()."style.css", + stylesheet => 1, ); $form->field(name => "do", type => "hidden", value => "setup", force => 1); $form->field(name => "rebuild_asked", type => "hidden"); + $form->field(name => "showadvanced", type => "hidden"); if ($form->submitted eq 'Basic Mode') { $form->field(name => "showadvanced", type => "hidden", @@ -344,7 +344,7 @@ sub showform ($$) { IkiWiki::decode_form_utf8($form); if ($form->submitted eq "Cancel") { - IkiWiki::redirect($cgi, $config{url}); + IkiWiki::redirect($cgi, IkiWiki::baseurl(undef)); return; } elsif (($form->submitted eq 'Save Setup' || $form->submitted eq 'Rebuild Wiki') && $form->validate) { @@ -447,10 +447,10 @@ sub showform ($$) { IkiWiki::saveindex(); IkiWiki::unlockwiki(); - # Print the top part of a standard misctemplate, - # then show the rebuild or refresh. - my $divider="xxx"; - my $html=IkiWiki::misctemplate("setup", $divider); + # Print the top part of a standard cgitemplate, + # then show the rebuild or refresh, live. + my $divider="\0"; + my $html=IkiWiki::cgitemplate($cgi, "setup", $divider); IkiWiki::printheader($session); my ($head, $tail)=split($divider, $html, 2); print $head."
\n";
@@ -475,7 +475,7 @@ sub showform ($$) {
 						join(" ", @command), $ret).
 					'

'; open(OUT, ">", $config{setupfile}) || error("$config{setupfile}: $!"); - print OUT $oldsetup; + print OUT Encode::encode_utf8($oldsetup); close OUT; } @@ -501,9 +501,10 @@ sub formbuilder_setup (@) { my %params=@_; my $form=$params{form}; - if ($form->title eq "preferences") { - push @{$params{buttons}}, "Wiki Setup"; - if ($form->submitted && $form->submitted eq "Wiki Setup") { + if ($form->title eq "preferences" && + IkiWiki::is_admin($params{session}->param("name"))) { + push @{$params{buttons}}, "Setup"; + if ($form->submitted && $form->submitted eq "Setup") { showform($params{cgi}, $params{session}); exit; }