Disable the Preferences link if no plugin with an auth hook is enabled.

master
Joey Hess 2009-06-09 15:39:00 -04:00
parent 1a880b7d7b
commit 48a5f9f2d8
4 changed files with 22 additions and 3 deletions

View 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

View 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++;
}

1
debian/changelog vendored
View 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

View 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]]