]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Disable the Preferences link if no plugin with an auth hook is enabled.
authorJoey Hess <joey@gnu.kitenet.net>
Tue, 9 Jun 2009 19:39:00 +0000 (15:39 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 9 Jun 2009 19:39:00 +0000 (15:39 -0400)
IkiWiki/Plugin/passwordauth.pm
IkiWiki/Render.pm
debian/changelog
doc/todo/Allow_disabling_edit_and_preferences_links.mdwn

index 90e2ca56493767f655984973dddb80af58fd1285..8cf5af51ed03d47ff90963dd1aece3c9ea773cbb 100644 (file)
@@ -8,9 +8,10 @@ use IkiWiki 3.00;
 
 sub import {
        hook(type => "getsetup", id => "passwordauth", "call" => \&getsetup);
-        hook(type => "formbuilder_setup", id => "passwordauth", call => \&formbuilder_setup);
-        hook(type => "formbuilder", id => "passwordauth", call => \&formbuilder);
+       hook(type => "formbuilder_setup", id => "passwordauth", call => \&formbuilder_setup);
+       hook(type => "formbuilder", id => "passwordauth", call => \&formbuilder);
        hook(type => "sessioncgi", id => "passwordauth", call => \&sessioncgi);
+       hook(type => "auth", id => "passwordauth", call => \&auth);
 }
 
 sub getsetup () {
@@ -337,4 +338,10 @@ sub sessioncgi ($$) {
        }
 }
 
+sub auth ($$) {
+       # While this hook is not currently used, it needs to exist
+       # so ikiwiki knows that the wiki supports logins, and will
+       # enable the Preferences page.
+}
+
 1
index f4de19378e86223bf7c2d518a5c618f7a47d120d..2da18738d9e4f2740dadb22f647383846f4c3742 100644 (file)
@@ -65,7 +65,8 @@ sub genpage ($$) {
        if (length $config{cgiurl}) {
                $template->param(editurl => cgiurl(do => "edit", page => $page))
                        if IkiWiki->can("cgi_editpage");
-               $template->param(prefsurl => cgiurl(do => "prefs"));
+               $template->param(prefsurl => cgiurl(do => "prefs"))
+                       if exists $hooks{auth};
                $actions++;
        }
                
index dd24e0bba78bc71b6c1f8d4e9e760cfd8dbbeec7..06bed479bd05f29b56598a8abdbb5ba9b51db779 100644 (file)
@@ -22,6 +22,7 @@ ikiwiki (3.141) UNRELEASED; urgency=low
     is not available. Closes: #532285
   * meta: Add openid delegate parameter to allow delegating only
     openid or openid2.
+  * Disable the Preferences link if no plugin with an auth hook is enabled.
 
  -- Joey Hess <joeyh@debian.org>  Tue, 02 Jun 2009 17:03:41 -0400
 
index 5b9cc87421fe0f383be643a4445f89b07961e24d..4277ae899d5a6f4f923eb5d40e4337c57086e7e4 100644 (file)
@@ -67,3 +67,13 @@ Patch:
 >>> Adding a new `canlogin` hook looks like overkill to me.  [[Joey]], how
 >>> about making registration of the `auth` hook mandatory for all plugins
 >>> making sense of the "Preferences" link? --[[Lunar]]
+
+>>>> Hmm, using the `auth` hook existance does seem like a nice solution.
+>>>> While splitting the preferences code out into its own plugin is
+>>>> easily enough done, it has the minor problem of being yet another
+>>>> file nearly all ikiwikis will have to load, and also, prefs would
+>>>> have to be disabled manually. So I like that using the hook would
+>>>> cause it to auto-disable if nothing uses it. It's a bit ugly that
+>>>> passwordauth doesn't need an auth hook (it could be reorged to
+>>>> use it instead of formbuilder, maybe) and would probably just have an
+>>>> empty one. Thanks for the idea. --[[Joey]]  [[done]]