summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
370261e)
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.
# a reference to the normal signin form.
require IkiWiki::CGI;
my $real_cgi_signin;
# 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}} > 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 ($$) {
}
}
inject(name => "IkiWiki::cgi_signin", call => sub ($$) {
- openid_selector($real_cgi_signin, $nonopenidform_label, @_);
+ openid_selector($real_cgi_signin, $otherform_label, @_);
sub openid_selector {
my $real_cgi_signin=shift;
sub openid_selector {
my $real_cgi_signin=shift;
- my $nonopenidform_label=shift;
+ my $otherform_label=shift;
my $q=shift;
my $session=shift;
my $q=shift;
my $session=shift;
+ my $template=IkiWiki::template("openid-selector.tmpl");
my $openid_url=$q->param('openid_identifier');
my $openid_url=$q->param('openid_identifier');
if (! load_openid_module()) {
if ($real_cgi_signin) {
if (! load_openid_module()) {
if ($real_cgi_signin) {
}
error(sprintf(gettext("failed to load openid module: "), @_));
}
}
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 {
validate($q, $session, $openid_url, sub {
+ $template->param(login_error => shift())
- my $template=IkiWiki::template("openid-selector.tmpl");
$template->param(
cgiurl => IkiWiki::cgiurl(),
$template->param(
cgiurl => IkiWiki::cgiurl(),
- (defined $openid_error ? (openid_error => $openid_error) : ()),
(defined $openid_url ? (openid_url => $openid_url) : ()),
(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);
);
IkiWiki::printheader($session);
-/* openid selector */
-#openid_choice {
+/* login selector */
+#login_choice {
clear: both;
padding: 10px;
}
clear: both;
padding: 10px;
}
-#openid_btns, #openid_btns br {
+#login_btns, #login_btns br {
background-color: black;
float: left;
}
background-color: black;
float: left;
}
padding: 1em 1.5em;
border: 1px solid #DDD;
margin: 3px;
float: left;
}
padding: 1em 1.5em;
border: 1px solid #DDD;
margin: 3px;
float: left;
}
padding: 4px 4px;
border: 1px solid #DDD;
margin: 3px;
float: left;
}
padding: 4px 4px;
border: 1px solid #DDD;
margin: 3px;
float: left;
}
-a.openid_large_btn:focus {
+a.login_large_btn:focus {
-a.openid_large_btn:focus {
+a.login_large_btn:focus {
border: 4px solid #DDD;
}
border: 4px solid #DDD;
}
<script type="text/javascript" src="ikiwiki/openid/openid-jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
<script type="text/javascript" src="ikiwiki/openid/openid-jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
- openid.init('openid_identifier','<TMPL_IF NONOPENIDFORM>nonopenidform</TMPL_IF>', '<TMPL_VAR NONOPENIDFORM_LABEL>');
+ selector.init('openid_identifier','<TMPL_IF OTHERFORM>otherform</TMPL_IF>', '<TMPL_VAR OTHERFORM_LABEL>');
-<form action="<TMPL_VAR CGIURL>" method="get" id="openid_form">
- <fieldset>
+<form action="<TMPL_VAR CGIURL>" method="get" id="login_selector_form">
+ <div>
<script>
$('fieldset').append("<legend>Select login method</legend>");
</script>
<input type="hidden" name="do" value="signin" />
<input type="hidden" name="action" value="verify" />
<script>
$('fieldset').append("<legend>Select login method</legend>");
</script>
<input type="hidden" name="do" value="signin" />
<input type="hidden" name="action" value="verify" />
- <div id="openid_choice">
- <div id="openid_btns"></div>
+ <div id="login_choice">
+ <div id="login_btns"></div>
- <div id="openid_input_area">
+ <div id="login_input_area">
<label for="openid_identifier" class="block">Enter your OpenID:</label>
<input id="openid_identifier" name="openid_identifier" type="text" value="<TMPL_VAR ESCAPE=HTML OPENID_URL>"/>
<input id="openid_submit" type="submit" value="Login"/>
</div>
<label for="openid_identifier" class="block">Enter your OpenID:</label>
<input id="openid_identifier" name="openid_identifier" type="text" value="<TMPL_VAR ESCAPE=HTML OPENID_URL>"/>
<input id="openid_submit" type="submit" value="Login"/>
</div>
- <TMPL_IF OPENID_ERROR>
- <div class="error"><TMPL_VAR OPENID_ERROR></div>
+ <TMPL_IF LOGIN_ERROR>
+ <div class="error"><TMPL_VAR LOGIN_ERROR></div>
-<div id="nonopenidform">
-<TMPL_IF NONOPENIDFORM>
+<div id="otherform">
+<TMPL_IF OTHERFORM>
-<h2><TMPL_VAR NONOPENIDFORM_LABEL>:</h2>
+<h2><TMPL_VAR OTHERFORM_LABEL>:</h2>
-<TMPL_VAR NONOPENIDFORM>
+Based on the Simple OpenID Plugin
http://code.google.com/p/openid-selector/
This code is licenced under the New BSD License.
*/
http://code.google.com/p/openid-selector/
This code is licenced under the New BSD License.
*/
+var selections_large = {
+ email: {
+ name: 'Email',
+ icon: 'wikiicons/email.png',
+ label: 'Enter your email address:',
+ url: null
+ },
+ openid: {
+ name: 'OpenID',
+ icon: 'wikiicons/openidlogin-bg.gif',
+ label: 'Enter your OpenID:',
+ url: null
+ },
+};
+var selections_small = {
verisign: {
name: 'Verisign',
icon: 'ikiwiki/openid/verisign.png',
verisign: {
name: 'Verisign',
icon: 'ikiwiki/openid/verisign.png',
url: 'http://{username}.pip.verisignlabs.com/'
},
yahoo: {
url: 'http://{username}.pip.verisignlabs.com/'
},
yahoo: {
icon: 'ikiwiki/openid/goa-account-yahoo.png',
url: 'http://me.yahoo.com/'
icon: 'ikiwiki/openid/goa-account-yahoo.png',
url: 'http://me.yahoo.com/'
- },
- openid: {
- name: 'OpenID',
- icon: 'wikiicons/openidlogin-bg.gif',
- label: 'Enter your OpenID:',
- url: null
+ },
+ flickr: {
+ name: 'Flickr',
+ icon: 'ikiwiki/openid/goa-account-flickr.png',
+ label: 'Enter your Flickr username:',
+ url: 'http://flickr.com/photos/{username}/'
+ },
+ wordpress: {
+ name: 'Wordpress',
+ icon: 'ikiwiki/openid/wordpress.png',
+ label: 'Enter your Wordpress.com username:',
+ url: 'http://{username}.wordpress.com/'
+ },
+ aol: {
+ name: 'AOL',
+ icon: 'ikiwiki/openid/aol.png',
+ label: 'Enter your AOL username:',
+ url: 'http://openid.aol.com/{username}'
-var providers_small = {
-};
-var providers = $.extend({}, providers_large, providers_small);
+var selections = $.extend({}, selections_large, selections_small);
ajaxHandler: null,
cookie_expires: 6*30, // 6 months.
ajaxHandler: null,
cookie_expires: 6*30, // 6 months.
- cookie_name: 'openid_provider',
+ cookie_name: 'openid_selection', // historical name
cookie_path: '/',
img_path: 'images/',
input_id: null,
cookie_path: '/',
img_path: 'images/',
input_id: null,
- provider_url: null,
- provider_id: null,
- localsignin_id: null,
+ selection_url: null,
+ selection_id: null,
+ othersignin_id: null,
- init: function(input_id, localsignin_id, localsignin_label) {
+ init: function(input_id, othersignin_id, othersignin_label) {
- var openid_btns = $('#openid_btns');
+ var selector_btns = $('#login_btns');
this.input_id = input_id;
this.input_id = input_id;
- $('#openid_choice').show();
- $('#openid_input_area').empty();
+ $('#login_choice').show();
+ $('#login_input_area').empty();
- // add box for each provider
- for (id in providers_large) {
- openid_btns.append(this.getBoxHTML(providers_large[id], 'large'));
+ // add box for each selection
+ for (id in selections_large) {
+ selector_btns.append(this.getBoxHTML(selections_large[id], 'large'));
- if (localsignin_label != "") {
- this.localsignin_label=localsignin_label;
+ if (othersignin_label != "") {
+ this.othersignin_label=othersignin_label;
- this.localsignin_label="other";
+ this.othersignin_label="other";
- if (localsignin_id != "") {
- this.localsignin_id=localsignin_id;
- openid_btns.append(
- '<a href="javascript: openid.signin(\'localsignin\');"' +
+ if (othersignin_id != "") {
+ this.othersignin_id=othersignin_id;
+ selector_btns.prepend(
+ '<a href="javascript: selector.signin(\'othersignin\');"' +
' style="background: #FFF" ' +
' style="background: #FFF" ' +
- 'class="localsignin openid_large_btn">' +
+ 'class="othersignin login_large_btn">' +
'<img alt="" width="16" height="16" src="favicon.ico" />' +
'<img alt="" width="16" height="16" src="favicon.ico" />' +
- ' ' + this.localsignin_label +
+ ' ' + this.othersignin_label +
- $('#'+this.localsignin_id).hide();
+ $('#'+this.othersignin_id).hide();
- if (providers_small) {
- openid_btns.append('<br/>');
+ if (selections_small) {
+ selector_btns.append('<br/>');
- 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);
}
},
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') {
var label="";
var title=""
if (box_size == 'large') {
- label=' ' + provider["name"];
+ label=' ' + selection["name"];
- title=' title="'+provider["name"]+'"';
+ title=' title="'+selection["name"]+'"';
- var box_id = provider["name"].toLowerCase();
- return '<a' + title +' href="javascript: openid.signin(\''+ box_id +'\');"' +
+ var box_id = selection["name"].toLowerCase();
+ return '<a' + title +' href="javascript: selector.signin(\''+ box_id +'\');"' +
' style="background: #FFF" ' +
' style="background: #FFF" ' +
- 'class="' + box_id + ' openid_' + box_size + '_btn">' +
- '<img alt="" width="16" height="16" src="' + provider["icon"] + '" />' +
+ 'class="' + box_id + ' login_' + box_size + '_btn">' +
+ '<img alt="" width="16" height="16" src="' + selection["icon"] + '" />' +
- /* Provider image click */
+ /* selection image click */
signin: function(box_id, onload) {
signin: function(box_id, onload) {
- if (box_id == 'localsignin') {
+ if (box_id == 'othersignin') {
- $('#openid_input_area').empty();
- $('#'+this.localsignin_id).show();
+ $('#login_input_area').empty();
+ $('#'+this.othersignin_id).show();
this.setCookie(box_id);
return;
}
else {
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);
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?
// prompt user for input?
- if (provider['label']) {
+ if (selection['label']) {
- this.useInputBox(provider);
+ this.useInputBox(selection);
} else {
this.setCookie('');
} else {
this.setCookie('');
- $('#openid_input_area').empty();
+ $('#login_input_area').empty();
- $('#openid_form').submit();
+ $('#login_selector_form').submit();
}
}
},
/* Sign-in button click */
submit: function() {
}
}
},
/* Sign-in button click */
submit: function() {
-
- var url = openid.provider_url;
+ var url = selector.selection_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;
return false;
}
return true;
if (hidden.length > 0) {
hidden.value = url;
} else {
if (hidden.length > 0) {
hidden.value = url;
} else {
- $('#openid_form').append('<input style="display:none" id="' + this.input_id + '" name="' + this.input_id + '" value="'+url+'"/>');
+ $('#login_selector_form').append('<input style="display:none" id="' + this.input_id + '" name="' + this.input_id + '" value="'+url+'"/>');
}
},
highlight: function (box_id) {
// remove previous highlight.
}
},
highlight: function (box_id) {
// remove previous highlight.
- var highlight = $('#openid_highlight');
+ var highlight = $('#login_highlight');
- highlight.replaceWith($('#openid_highlight a')[0]);
+ highlight.replaceWith($('#login_highlight a')[0]);
- $('.'+box_id).wrap('<div id="openid_highlight"></div>');
+ $('.'+box_id).wrap('<div id="login_highlight"></div>');
},
setCookie: function (value) {
},
setCookie: function (value) {
- useInputBox: function (provider) {
+ useInputBox: function (selection) {
- var input_area = $('#openid_input_area');
+ var input_area = $('#login_input_area');
- var id = 'openid_username';
- var label = provider['label'];
+ var label = selection['label'];
- 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;';
id = this.input_id;
value = '';
style = 'background:#FFF url(wikiicons/openidlogin-bg.gif) no-repeat scroll 0 50%; padding-left:18px;';
if (label) {
html = '<label for="'+ id +'" class="block">' + label + '</label>';
}
if (label) {
html = '<label for="'+ id +'" class="block">' + label + '</label>';
}
+ html += '<input name="selection" type="hidden" value="' + selection['name'] + '" />'
html += '<input id="'+id+'" type="text" style="'+style+'" name="'+id+'" value="'+value+'" />' +
html += '<input id="'+id+'" type="text" style="'+style+'" name="'+id+'" value="'+value+'" />' +
- '<input id="openid_submit" type="submit" value="Login"/>';
+ '<input id="selector_submit" type="submit" value="Login"/>';
input_area.empty();
input_area.append(html);
$('#'+id).focus();
},
input_area.empty();
input_area.append(html);
$('#'+id).focus();
},
- setDemoMode: function (demoMode) {
- this.demo = demoMode;
- },
setAjaxHandler: function (ajaxFunction) {
this.ajaxHandler = ajaxFunction;
}
setAjaxHandler: function (ajaxFunction) {
this.ajaxHandler = ajaxFunction;
}