From ec72b4c95bce640f8b02b7885dad84640b924ffe Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 13 May 2015 12:18:22 -0400 Subject: [PATCH] When openid and passwordauth are the only enabled auth plugins, make the openid selector display "Password" instead of "Other", so users are more likely to click on it when they don't have an openid. --- IkiWiki/Plugin/openid.pm | 8 +++++++- debian/changelog | 3 +++ templates/openid-selector.tmpl | 6 +++--- .../openid-selector/ikiwiki/openid/openid-jquery.js | 10 ++++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index 107c6adcb..00652ebb7 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -25,11 +25,15 @@ sub checkconfig () { # a reference to the normal signin form. require IkiWiki::CGI; my $real_cgi_signin; + my $nonopenidform_label=gettext("Other"); if (keys %{$IkiWiki::hooks{auth}} > 1) { $real_cgi_signin=\&IkiWiki::cgi_signin; + if (keys %{$IkiWiki::hooks{auth}} == 2 && exists $IkiWiki::hooks{auth}->{passwordauth}) { + $nonopenidform_label=gettext("Password"); + } } inject(name => "IkiWiki::cgi_signin", call => sub ($$) { - openid_selector($real_cgi_signin, @_); + openid_selector($real_cgi_signin, $nonopenidform_label, @_); }); } } @@ -57,6 +61,7 @@ sub getsetup () { sub openid_selector { my $real_cgi_signin=shift; + my $nonopenidform_label=shift; my $q=shift; my $session=shift; @@ -82,6 +87,7 @@ sub openid_selector { (defined $openid_error ? (openid_error => $openid_error) : ()), (defined $openid_url ? (openid_url => $openid_url) : ()), ($real_cgi_signin ? (nonopenidform => $real_cgi_signin->($q, $session, 1)) : ()), + nonopenidform_label => $nonopenidform_label, ); IkiWiki::printheader($session); diff --git a/debian/changelog b/debian/changelog index de07f747a..4d8b589cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ ikiwiki (3.20150330) UNRELEASED; urgency=medium * Re-remove google from openid selector; their openid provider is gone for good. + * When openid and passwordauth are the only enabled auth plugins, + make the openid selector display "Password" instead of "Other", + so users are more likely to click on it when they don't have an openid. -- Joey Hess Tue, 28 Apr 2015 12:24:08 -0400 diff --git a/templates/openid-selector.tmpl b/templates/openid-selector.tmpl index 0fd833042..95ba086fe 100644 --- a/templates/openid-selector.tmpl +++ b/templates/openid-selector.tmpl @@ -2,7 +2,7 @@ @@ -13,7 +13,7 @@ $(document).ready(function() {
@@ -36,7 +36,7 @@ $(document).ready(function() {
diff --git a/underlays/openid-selector/ikiwiki/openid/openid-jquery.js b/underlays/openid-selector/ikiwiki/openid/openid-jquery.js index 1df419fb8..448d20d74 100644 --- a/underlays/openid-selector/ikiwiki/openid/openid-jquery.js +++ b/underlays/openid-selector/ikiwiki/openid/openid-jquery.js @@ -67,7 +67,7 @@ var openid = { provider_id: null, localsignin_id: null, - init: function(input_id, localsignin_id) { + init: function(input_id, localsignin_id, localsignin_label) { var openid_btns = $('#openid_btns'); @@ -89,6 +89,12 @@ var openid = { openid_btns.append(this.getBoxHTML(providers_small[id], 'small')); } } + if (localsignin_label != "") { + this.localsignin_label=localsignin_label; + } + else { + this.localsignin_label="other"; + } if (localsignin_id != "") { this.localsignin_id=localsignin_id; openid_btns.append( @@ -96,7 +102,7 @@ var openid = { ' style="background: #FFF" ' + 'class="localsignin openid_small_btn">' + '' + - ' other' + + ' ' + this.localsignin_label + '' ); $('#'+this.localsignin_id).hide();