]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
show unsafe options (RO) by default
authorJoey Hess <joey@kodama.kitenet.net>
Sun, 3 Aug 2008 02:46:16 +0000 (22:46 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Sun, 3 Aug 2008 02:50:09 +0000 (22:50 -0400)
Small data leak, but only to admins, and I think it's worth it to see the
stuff that cannot be configured.

.IkiWiki.pm.swp [new file with mode: 0644]
IkiWiki.pm
IkiWiki/Plugin/bzr.pm
IkiWiki/Plugin/git.pm
IkiWiki/Plugin/mercurial.pm
IkiWiki/Plugin/monotone.pm
IkiWiki/Plugin/svn.pm
IkiWiki/Plugin/tla.pm
IkiWiki/Plugin/websetup.pm
websetup.pm [new symlink]

diff --git a/.IkiWiki.pm.swp b/.IkiWiki.pm.swp
new file mode 100644 (file)
index 0000000..adf830d
Binary files /dev/null and b/.IkiWiki.pm.swp differ
index 241a7c036f41f73ebd5e7374f2b00afd9344464e..a2b4d8d80db321374ed4bd92085263d8ef954554 100644 (file)
@@ -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,
        },
index 99025a973db235605cf64448e9ccdd04e1fc687b..0b50592924915b0040fa530095fd575985da08ea 100644 (file)
@@ -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,
                },
index d1c1165e03c25528d1cb10d4f03e54ed890c547b..b6ad43167eff6d77c3d06f5c8c0e5c548005b7b0 100644 (file)
@@ -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,
                },
index d2c34fa6a5810c43ac999fb23184a08dab1abc76..23bebaaadfd5e09798718523f24d61b6fa1f79f6 100644 (file)
@@ -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,
                },
index 4b9be316a4e602f5aaa075c8c62f2e8ade8e3ed2..bdc6ee786e18bad7e4d9b2662df5938ebe2b7131 100644 (file)
@@ -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,
                },
index 51683704c5928d6e5577a3e1f92b62adbb41849f..c51b0f1811a0e528ae962686cb68daff2e92922f 100644 (file)
@@ -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,
                },
index 6faaecccc5d7a48a1f44e3fd40aa6376c8d8cf48..1c2763359c35766b8cd42dfb323fbb13ee6e0e11 100644 (file)
@@ -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,
                },
index 6aab04e320fe21d02a36a9334ab0f3ab068bd191..150c792a52d7dfcc2097f5467451d6af1800a660 100644 (file)
@@ -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 "<br/ ><small>Example: <tt>$example</tt></small>";
        }
        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 (symlink)
index 0000000..8ca7a8a
--- /dev/null
@@ -0,0 +1 @@
+/home/joey/src/ikiwiki/IkiWiki/Plugin/websetup.pm
\ No newline at end of file