From 4405cebd0a275856acaa184d49751a5f6dcc7048 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 3 Aug 2008 14:57:24 -0400 Subject: [PATCH] add advanced and basic modes --- IkiWiki.pm | 9 +++++ IkiWiki/Plugin/prettydate.pm | 1 + IkiWiki/Plugin/typography.pm | 1 + IkiWiki/Plugin/websetup.pm | 25 +++++++++++-- doc/plugins/write.mdwn | 3 ++ po/ikiwiki.pot | 68 +++++++++++++++++++++++------------- 6 files changed, 81 insertions(+), 26 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 51e683bb4..2139aa7d1 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -137,6 +137,7 @@ sub getsetup () { #{{{ type => "string", default => "$installdir/share/ikiwiki/templates", description => "location of template files", + advanced => 1, safe => 0, # path rebuild => 1, }, @@ -144,6 +145,7 @@ sub getsetup () { #{{{ type => "string", default => "$installdir/share/ikiwiki/basewiki", description => "base wiki source location", + advanced => 1, safe => 0, # path rebuild => 0, }, @@ -214,6 +216,7 @@ sub getsetup () { #{{{ type => "string", default => '%c', description => "strftime format string to display date", + advanced => 1, safe => 1, rebuild => 1, }, @@ -222,6 +225,7 @@ sub getsetup () { #{{{ default => undef, example => "en_US.UTF-8", description => "UTF-8 locale to use", + advanced => 1, safe => 0, rebuild => 1, }, @@ -229,6 +233,7 @@ sub getsetup () { #{{{ type => "boolean", default => 0, description => "only send cookies over SSL connections?", + advanced => 1, safe => 1, rebuild => 0, }, @@ -251,6 +256,7 @@ sub getsetup () { #{{{ type => "boolean", default => 0, description => "attempt to hardlink source files? (optimisation for large files)", + advanced => 1, safe => 0, # paranoia rebuild => 0, }, @@ -259,6 +265,7 @@ sub getsetup () { #{{{ description => "", example => "022", description => "force ikiwiki to use a particular umask", + advanced => 1, safe => 0, # paranoia rebuild => 0, }, @@ -267,6 +274,7 @@ sub getsetup () { #{{{ default => "", example => "$ENV{HOME}/.ikiwiki/", description => "extra library and plugin directory", + advanced => 1, safe => 0, # directory rebuild => 0, }, @@ -282,6 +290,7 @@ sub getsetup () { #{{{ default => undef, example => '\.wav$', description => "regexp of source files to ignore", + advanced => 1, safe => 0, # regexp rebuild => 1, }, diff --git a/IkiWiki/Plugin/prettydate.pm b/IkiWiki/Plugin/prettydate.pm index db5a94f41..dd1e096b4 100644 --- a/IkiWiki/Plugin/prettydate.pm +++ b/IkiWiki/Plugin/prettydate.pm @@ -50,6 +50,7 @@ sub getsetup () { #{{{ type => "string", example => '%X, %B %o, %Y', description => "format to use to display date", + advanced => 1, safe => 1, rebuild => 1, }, diff --git a/IkiWiki/Plugin/typography.pm b/IkiWiki/Plugin/typography.pm index 6229e6c33..3964d266d 100644 --- a/IkiWiki/Plugin/typography.pm +++ b/IkiWiki/Plugin/typography.pm @@ -28,6 +28,7 @@ sub getsetup () { #{{{ type => "string", example => "3", description => "Text::Typography attributes value", + advanced => 1, safe => 1, rebuild => 1, }, diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index bfc238dc3..061ce0873 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -73,7 +73,9 @@ 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}; + next if ! $info{safe} && ! ($config{websetup_show_unsafe} && $config{websetup_advanced}); + # maybe skip advanced settings + next if $info{advanced} && ! $config{websetup_advanced}; # these are handled specially, so don't show next if $key eq 'add_plugins' || $key eq 'disable_plugins'; @@ -228,7 +230,26 @@ sub showform ($$) { #{{{ template => {type => 'div'}, stylesheet => IkiWiki::baseurl()."style.css", ); - my $buttons=["Save Setup", "Cancel"]; + + if ($form->submitted eq 'Basic') { + $form->field(name => "showadvanced", type => "hidden", + value => 0, force => 1); + } + elsif ($form->submitted eq 'Advanced') { + $form->field(name => "showadvanced", type => "hidden", + value => 1, force => 1); + } + my $advancedtoggle; + if ($form->field("showadvanced")) { + $config{websetup_advanced}=1; + $advancedtoggle="Basic"; + } + else { + $config{websetup_advanced}=0; + $advancedtoggle="Advanced"; + } + + my $buttons=["Save Setup", $advancedtoggle, "Cancel"]; IkiWiki::decode_form_utf8($form); IkiWiki::run_hooks(formbuilder_setup => sub { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 48a94ec8b..fc4b778db 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -385,6 +385,7 @@ describing the option. For example: option_foo => { type => "boolean", description => "enable foo", + advanced => 1, safe => 1, rebuild => 1, }, @@ -404,6 +405,8 @@ describing the option. For example: * `description` is a short description of the option. * `link` is a link to further information about the option. This can either be a wikilink, or an url. +* `advanced` can be set to true if the option is more suitable for advanced + users. * `safe` should be false if the option should not be displayed in unsafe configuration methods, such as the web interface. Anything that specifies a command to run, a path on disk, or a regexp should be marked as unsafe. diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 52a49ae9c..13db8f04f 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-08-02 15:27-0400\n" +"POT-Creation-Date: 2008-08-03 14:48-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -71,7 +71,7 @@ msgstr "" msgid "You are banned." msgstr "" -#: ../IkiWiki/CGI.pm:783 ../IkiWiki/CGI.pm:784 ../IkiWiki.pm:1096 +#: ../IkiWiki/CGI.pm:783 ../IkiWiki/CGI.pm:784 ../IkiWiki.pm:1108 msgid "Error" msgstr "" @@ -173,20 +173,20 @@ msgstr "" msgid "Failed to delete file from S3: " msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:46 +#: ../IkiWiki/Plugin/attachment.pm:42 #, perl-format msgid "there is already a page named %s" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:79 +#: ../IkiWiki/Plugin/attachment.pm:75 msgid "prohibited by allowed_attachments" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:187 +#: ../IkiWiki/Plugin/attachment.pm:183 msgid "bad attachment filename" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:229 +#: ../IkiWiki/Plugin/attachment.pm:225 msgid "attachment upload" msgstr "" @@ -311,7 +311,7 @@ msgstr "" msgid "failed to run dot" msgstr "" -#: ../IkiWiki/Plugin/lockedit.pm:43 ../IkiWiki/Plugin/lockedit.pm:57 +#: ../IkiWiki/Plugin/lockedit.pm:42 ../IkiWiki/Plugin/lockedit.pm:56 #, perl-format msgid "%s is locked and cannot be edited" msgstr "" @@ -495,15 +495,15 @@ msgstr "" msgid "%A night" msgstr "" -#: ../IkiWiki/Plugin/prettydate.pm:96 +#: ../IkiWiki/Plugin/prettydate.pm:97 msgid "at teatime on %A" msgstr "" -#: ../IkiWiki/Plugin/prettydate.pm:100 +#: ../IkiWiki/Plugin/prettydate.pm:101 msgid "at midnight" msgstr "" -#: ../IkiWiki/Plugin/prettydate.pm:103 +#: ../IkiWiki/Plugin/prettydate.pm:104 msgid "at noon on %A" msgstr "" @@ -707,19 +707,39 @@ msgstr "" msgid "failed to generate image from code" 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 +#: ../IkiWiki/Plugin/websetup.pm:85 msgid "plugin" msgstr "" -#: ../IkiWiki/Plugin/websetup.pm:168 +#: ../IkiWiki/Plugin/websetup.pm:85 +msgid "main" +msgstr "" + +#: ../IkiWiki/Plugin/websetup.pm:170 +msgid "" +"Note: Disabled options cannot be configured here, but only by editing the " +"setup file." +msgstr "" + +#: ../IkiWiki/Plugin/websetup.pm:198 +#, perl-format +msgid "enable %s?" +msgstr "" + +#: ../IkiWiki/Plugin/websetup.pm:212 +msgid "you are not logged in as an admin" +msgstr "" + +#: ../IkiWiki/Plugin/websetup.pm:266 +msgid "other plugins" +msgstr "" + +#: ../IkiWiki/Plugin/websetup.pm:317 +msgid "" +"The configuration changes shown below require a wiki rebuild to take effect." +msgstr "" + +#: ../IkiWiki/Plugin/websetup.pm:329 msgid "Setup saved." msgstr "" @@ -827,19 +847,19 @@ msgstr "" msgid "refreshing wiki.." msgstr "" -#: ../IkiWiki.pm:417 +#: ../IkiWiki.pm:427 msgid "Must specify url to wiki with --url when using --cgi" msgstr "" -#: ../IkiWiki.pm:461 +#: ../IkiWiki.pm:471 msgid "cannot use multiple rcs plugins" msgstr "" -#: ../IkiWiki.pm:1079 +#: ../IkiWiki.pm:1091 #, perl-format msgid "preprocessing loop detected on %s at depth %i" msgstr "" -#: ../IkiWiki.pm:1567 +#: ../IkiWiki.pm:1579 msgid "yes" msgstr ""