From ab4d9a54677c2c17b186048ba5d86986a161bcef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 13 May 2015 16:44:43 -0400 Subject: [PATCH] generalized the openid selector to a login selector This includes some CSS changes to names of elements. Also, added Email login button (doesn't work yet of course), and brought back the small openid login buttons. Demoted yahoo and verison to small buttons. This makes the big buttons be the main login types, and the small buttons be provider-specific helpers. --- IkiWiki/Plugin/openid.pm | 25 +-- doc/style.css | 20 +- doc/wikiicons/emaillogin.png | Bin 0 -> 685 bytes templates/openid-selector.tmpl | 28 +-- .../openid-selector/ikiwiki/openid/aol.png | Bin 0 -> 460 bytes .../ikiwiki/openid/goa-account-flickr.png | Bin 0 -> 592 bytes .../ikiwiki/openid/livejournal.png | Bin 0 -> 772 bytes .../ikiwiki/openid/openid-jquery.js | 188 ++++++++++-------- .../ikiwiki/openid/wordpress.png | Bin 0 -> 886 bytes 9 files changed, 140 insertions(+), 121 deletions(-) create mode 100644 doc/wikiicons/emaillogin.png create mode 100644 underlays/openid-selector/ikiwiki/openid/aol.png create mode 100644 underlays/openid-selector/ikiwiki/openid/goa-account-flickr.png create mode 100644 underlays/openid-selector/ikiwiki/openid/livejournal.png create mode 100644 underlays/openid-selector/ikiwiki/openid/wordpress.png diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index 00652ebb7..bfd130ace 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -25,15 +25,18 @@ sub checkconfig () { # a reference to the normal signin form. require IkiWiki::CGI; my $real_cgi_signin; - my $nonopenidform_label=gettext("Other"); + my $otherform_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"); + my %h=%{$IkiWiki::hooks{auth}}; + delete $h{openid}; + delete $h{emailauth}; + if (keys %h == 1 && exists $h{passwordauth}) { + $otherform_label=gettext("Password"); } } inject(name => "IkiWiki::cgi_signin", call => sub ($$) { - openid_selector($real_cgi_signin, $nonopenidform_label, @_); + openid_selector($real_cgi_signin, $otherform_label, @_); }); } } @@ -61,12 +64,12 @@ sub getsetup () { sub openid_selector { my $real_cgi_signin=shift; - my $nonopenidform_label=shift; + my $otherform_label=shift; my $q=shift; my $session=shift; + my $template=IkiWiki::template("openid-selector.tmpl"); my $openid_url=$q->param('openid_identifier'); - my $openid_error; if (! load_openid_module()) { if ($real_cgi_signin) { @@ -75,19 +78,17 @@ sub openid_selector { } error(sprintf(gettext("failed to load openid module: "), @_)); } - elsif (defined $q->param("action") && $q->param("action") eq "verify") { + elsif (defined $q->param("action") && $q->param("action") eq "verify" && defined $openid_url && length $openid_url) { validate($q, $session, $openid_url, sub { - $openid_error=shift; + $template->param(login_error => shift()) }); } - my $template=IkiWiki::template("openid-selector.tmpl"); $template->param( cgiurl => IkiWiki::cgiurl(), - (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, + ($real_cgi_signin ? (otherform => $real_cgi_signin->($q, $session, 1)) : ()), + otherform_label => $otherform_label, ); IkiWiki::printheader($session); diff --git a/doc/style.css b/doc/style.css index fe1eb903d..f0846c0d6 100644 --- a/doc/style.css +++ b/doc/style.css @@ -465,40 +465,40 @@ li.L8 { list-style: upper-alpha; } display: none; } -/* openid selector */ -#openid_choice { +/* login selector */ +#login_choice { display: none; } -#openid_input_area { +#login_input_area { clear: both; padding: 10px; } -#openid_btns, #openid_btns br { +#login_btns, #login_btns br { clear: both; } -#openid_highlight { +#login_highlight { background-color: black; float: left; } -.openid_large_btn { +.login_large_btn { padding: 1em 1.5em; border: 1px solid #DDD; margin: 3px; float: left; } -.openid_small_btn { +.login_small_btn { padding: 4px 4px; border: 1px solid #DDD; margin: 3px; float: left; } -a.openid_large_btn:focus { +a.login_large_btn:focus { outline: none; } -a.openid_large_btn:focus { +a.login_large_btn:focus { outline-style: none; } -.openid_selected { +.login_selected { border: 4px solid #DDD; } diff --git a/doc/wikiicons/emaillogin.png b/doc/wikiicons/emaillogin.png new file mode 100644 index 0000000000000000000000000000000000000000..1b16befd6177500558e6547a70f2e70871812d9a GIT binary patch literal 685 zcmV;e0#f~nP)0E$b?e4H!# zvcKa@>Q>K<>ZLKzMO;1S*eoFgF0e5E%$A+${kCOU_`biTaVI4b38Z_}mP#p%F$6(? z`8-eXbPV(B_qImS-HHA94vyoXl)~Bw&~M)DXa+D}76@lPVT`E)wAKKGVF-80m zcjGt`l#U>4plJVW2Hmt5W6ahJRI^L@@_7)V{tN8h#p=yV1lwi+l+T_-Wm-tRevAF} z2i8i7pxH%t9j4URi`kQgTHtFdXy5mx<2Y0*6##wknGAel_!c^+D8Erk#h zlarJExm?b2UAMkzlRVF(P$+~#hzaR=-rcFGDGG%`pD{-M4?qZ^rIZs&seAtb_)IY8 TCBh9=00000NkvXXu0mjf@YE -
-
+ +
-
-
+
+
-
+
- -
+ +
-
+
-
- +
+
- +
diff --git a/underlays/openid-selector/ikiwiki/openid/aol.png b/underlays/openid-selector/ikiwiki/openid/aol.png new file mode 100644 index 0000000000000000000000000000000000000000..d47f5fa54e821eaaa4fa3a0f3c6d5567ae31c714 GIT binary patch literal 460 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR48EvOHy+x6-qKv6&(G26ms&@^Lq@MKu!<^sdX$Z$;dBa2+qvS&r|SC z4$CYl$xL0_Wby*2KnSG3xhOTUBoinZl9`*zU}Ruu;>dsC4N&%;r;B5VMep0o>%ERR ziX8oTKCnBe9YHAi~&YAR))ralBi2Q*(p@VNC(w??= zrA~fupwXKBS@rWfi9ue5r?bwM{K{vVv_>uRpNW^|D~0tRJI-DC?KvaC=I(Z_QtsCp zH?m8jy^1EKOi6jVox^>{k;=8IFCWTv&p7Tp>7cp8BtE{6J>hTEUnY0R^%**eTgNlL zt$M0ww)%S$vyEct`_TN}id>!tOzFLfb04wE-g&s{)wU|(p6tU+w<9tbe%)AGy4+22 k)%s@MHHmzO|NLi__i_%)TBh*85a?3|Pgg&ebxsLQ06xgBfB*mh literal 0 HcmV?d00001 diff --git a/underlays/openid-selector/ikiwiki/openid/goa-account-flickr.png b/underlays/openid-selector/ikiwiki/openid/goa-account-flickr.png new file mode 100644 index 0000000000000000000000000000000000000000..5321642f6e26fa61ce9f8e731631ba3a52e87f57 GIT binary patch literal 592 zcmV-W0T zlfi0JK@^6+nL9U)A*(C`T6+_uCPS&(M7-eT33Q9v~C~Lhd5q zLXbjs3AiuPXfk)^&T$dbTHRd5e>?MkXZ~}}sL^QDR7#!XdEONfLjftJd=y0k5qWPy z2q(>Ev)5=ewAQ+apAdqX&*#0_Y=*Jcc9SI0Aq4U~F9c9ZktB(pPN!XyWtmY*;hZaE z-l$Y6k!6`N&N)P+aP^Hu1m_$N0GA&vXCIaT9KC(S!Rsvm;>#&pXP*GDN3U=PFYW=} zdjP)Nc={K&Gy9%QfKCCYrt!VEmmQS{+8V&v@-DsBWZQ|bn^{Q~%i#Z>!BOSgm z)T@H4mbp27NA>(O0E@$yxO(|v4>nEg>_KPmei=8DS#)+-basA;ks~5_@A0f-L1P+nfHmzkGcoSayYs+V7sKKq@G6i|^KNKr^; zNlq$*qe4MyUUFuRLQ!gQYHm_aW?s5NNk*!IPi9$aR(@$wUSf_yPJVj+_6Q$8piWVc zPRG)cjQk>o;LP0oJO$t6u*{N@%+$3_CNF>rgg^?Mi&7IyGJ%pInYpP9Mh1o^j{FDS zFfcH31o(uw{{R19&%_LfLPJ9p92^V`475#6Ev?K9jLp5=ZB48!Osy@f+ynJ(y{tV$ zfMlSrlZ{uXjh&^wtv8SXBqIWyY`nwt?YyHyoNc|s9UN@+?R=6WUG1El@{>I)Gkt1v ze7nj5+lvDX14_b6CK?4*MODr;3T?2ov5c)-U=&bf6y6GC8+s%fdZiip<`@N4ID};Q z1^O7e#TtdyJ4fbw#Fqip7)N&bq}3-hFJIOfWgOEVkkb)bJSn+j-M-n0QPp$OdNvz{ zw{?|=PH&8g$f>=sJl)95d~!{gN$O&g)Fo!I6MVfK0;7^MC+^J7&n}vO{^C*N3x|fTw_Rm zG?h^+dCI14XR)Q0?wU7TH#`lL;+`@mRK#6y>Aq!OE*f?`TFDf%tNr;u*+=O$$_=k) z8cw@Xz' + + 'class="othersignin login_large_btn">' + '' + - ' ' + this.localsignin_label + + ' ' + this.othersignin_label + '' ); - $('#'+this.localsignin_id).hide(); + $('#'+this.othersignin_id).hide(); } - if (providers_small) { - openid_btns.append('
'); + if (selections_small) { + selector_btns.append('
'); - for (id in providers_small) { - - openid_btns.append(this.getBoxHTML(providers_small[id], 'small')); + for (id in selections_small) { + selector_btns.append(this.getBoxHTML(selections_small[id], 'small')); } } - $('#openid_form').submit(this.submit); + $('#login_selector_form').submit(this.submit); var box_id = this.readCookie(); if (box_id) { this.signin(box_id, true); } }, - getBoxHTML: function(provider, box_size) { + getBoxHTML: function(selection, box_size) { var label=""; var title="" if (box_size == 'large') { - label=' ' + provider["name"]; + label=' ' + selection["name"]; } else { - title=' title="'+provider["name"]+'"'; + title=' title="'+selection["name"]+'"'; } - var box_id = provider["name"].toLowerCase(); - return '' + - '' + + 'class="' + box_id + ' login_' + box_size + '_btn">' + + '' + label + ''; }, - /* Provider image click */ + /* selection image click */ signin: function(box_id, onload) { - if (box_id == 'localsignin') { + if (box_id == 'othersignin') { this.highlight(box_id); - $('#openid_input_area').empty(); - $('#'+this.localsignin_id).show(); + $('#login_input_area').empty(); + $('#'+this.othersignin_id).show(); this.setCookie(box_id); return; } else { - if (this.localsignin_id) { - $('#'+this.localsignin_id).hide(); + if (this.othersignin_id) { + $('#'+this.othersignin_id).hide(); } } - var provider = providers[box_id]; - if (! provider) { + var selection = selections[box_id]; + if (! selection) { return; } this.highlight(box_id); - this.provider_id = box_id; - this.provider_url = provider['url']; + this.selection_id = box_id; + this.selection_url = selection['url']; // prompt user for input? - if (provider['label']) { + if (selection['label']) { this.setCookie(box_id); - this.useInputBox(provider); + this.useInputBox(selection); } else { this.setCookie(''); - $('#openid_input_area').empty(); + $('#login_input_area').empty(); if (! onload) { - $('#openid_form').submit(); + $('#login_selector_form').submit(); } } }, /* Sign-in button click */ submit: function() { - - var url = openid.provider_url; + var url = selector.selection_url; if (url) { - url = url.replace('{username}', $('#openid_username').val()); - openid.setOpenIdUrl(url); + url = url.replace('{username}', $('#entry').val()); + selector.setOpenIdUrl(url); } - if(openid.ajaxHandler) { - openid.ajaxHandler(openid.provider_id, document.getElementById(openid.input_id).value); - return false; - } - if(openid.demo) { - alert("In client demo mode. Normally would have submitted OpenID:\r\n" + document.getElementById(openid.input_id).value); + else { + selector.setOpenIdUrl(""); + } + if(selector.ajaxHandler) { + selector.ajaxHandler(selector.selection_id, document.getElementById(selector.input_id).value); return false; } return true; @@ -171,18 +191,18 @@ var openid = { if (hidden.length > 0) { hidden.value = url; } else { - $('#openid_form').append(''); + $('#login_selector_form').append(''); } }, highlight: function (box_id) { // remove previous highlight. - var highlight = $('#openid_highlight'); + var highlight = $('#login_highlight'); if (highlight) { - highlight.replaceWith($('#openid_highlight a')[0]); + highlight.replaceWith($('#login_highlight a')[0]); } // add new highlight. - $('.'+box_id).wrap('
'); + $('.'+box_id).wrap('
'); }, setCookie: function (value) { @@ -202,17 +222,17 @@ var openid = { } return null; }, - useInputBox: function (provider) { + useInputBox: function (selection) { - var input_area = $('#openid_input_area'); + var input_area = $('#login_input_area'); var html = ''; - var id = 'openid_username'; + var id = 'entry'; var value = ''; - var label = provider['label']; + var label = selection['label']; var style = ''; - if (provider['name'] == 'OpenID') { + if (selection['name'] == 'OpenID') { id = this.input_id; value = ''; style = 'background:#FFF url(wikiicons/openidlogin-bg.gif) no-repeat scroll 0 50%; padding-left:18px;'; @@ -220,17 +240,15 @@ var openid = { if (label) { html = ''; } + html += '' html += '' + - ''; + ''; input_area.empty(); input_area.append(html); $('#'+id).focus(); }, - setDemoMode: function (demoMode) { - this.demo = demoMode; - }, setAjaxHandler: function (ajaxFunction) { this.ajaxHandler = ajaxFunction; } diff --git a/underlays/openid-selector/ikiwiki/openid/wordpress.png b/underlays/openid-selector/ikiwiki/openid/wordpress.png new file mode 100644 index 0000000000000000000000000000000000000000..96e08bd99fa8862226a7b2e05fc914a2f3a77371 GIT binary patch literal 886 zcmV-+1Bv{JP)B&LZmn9UiN7y`z`OEoi1 zT$XS(lSM*ET$DlF6m6W58BE8AY_I^6u~AlFe6@_VWvA!E3#ZOxKKJjN-!FL|i3e$F zvvxGRux}`_(jp6~+-8vr0J55%(hYO$xlQil_3gb;B4PFKi1a`>aN=O~Da|nV7uXbr z6G^TwuL1C6p`DQ5#cDQ(BuPKK|LwqAM8b)G3!2&jU%d8wx27AFr~9uHn_1#vJmV|i z8lXYO|g=SbZv^YLzYLhsbI=|3~dsFLf0G604a|TGdWB(^e;S z3{4#{P0oeCk$H~93zD5|D&bLB2&MGgiND=k71 zV%wJkQ^ewb{oPno0>DCgoePumSS>QIhqeH4GnuBfZ-TU{(L1$(MM&i$Uy)tEO)v7x z)NKsI|ytxxB{J`Bn0*GKaQr0^sRl7a#Qu z|pC0r>pl7_t!T+2Y~FppWjWGkkS<8h}IF z0~Fiy$WvsNGb&YqLJZR!laDojxVV^JZ%AfUqJPZs!QQ8^T4Vywd`|v4&YkrfRe_D{ zE%9NR&^a2%rpT0e9F!Lo92NELy-}+yfB)vr5;iCnTKgsldK?HzBAe66YC7MH!~u9` zcaZ3{IS%g%qR67BzP&dph=kR5yDl~6EAn9El`2N(Qvh_0#{XI6#TyIEu4ahEmpFc) z62&5h-s|pfBobC-0Q%0Zbvdigzf|TgFSgrCOWk&6?_{wEiJ-?$?Gs*}^|=_COL9*$ zdX99)8i<5%{ny6(I-hx?c3=OkrDjEla+@N%OcOFWJ*gSS_``Jm6Sa?4eNZB`B>(^b M07*qoM6N<$f}eP&KmY&$ literal 0 HcmV?d00001