use IkiWiki 3.00;
sub import {
+ add_underlay("openid-selector");
hook(type => "checkconfig", id => "openid", call => \&checkconfig);
hook(type => "getopt", id => "openid", call => \&getopt);
hook(type => "getsetup", id => "openid", call => \&getsetup);
if ($config{cgi}) {
# Intercept normal signin form, so the openid selector
# can be displayed.
- require IkiWiki::CGI;
- my $real_cgi_signin=\&IkiWiki::cgi_signin;
+ #
+ # When other auth hooks are registered, give the selector
+ # a reference to the normal signin form.
+ my $real_cgi_signin;
+ if (keys %{$IkiWiki::hooks{auth}} > 1) {
+ require IkiWiki::CGI;
+ $real_cgi_signin=\&IkiWiki::cgi_signin;
+ }
inject(name => "IkiWiki::cgi_signin", call => sub ($$) {
- openid_selector($real_cgi_signin, @_);
+ openid_selector($real_cgi_signin, @_);
});
}
}
my $q=shift;
my $session=shift;
- my $openid_url=$q->param('openid_url');
+ my $openid_url=$q->param('openid_identifier');
my $openid_error;
- if (defined $q->param("action") && $q->param("action") eq "verify") {
+ if (! load_openid_module()) {
+ if ($real_cgi_signin) {
+ $real_cgi_signin->($q, $session);
+ }
+ error(sprintf(gettext("failed to load openid module: "), @_));
+ }
+ elsif (defined $q->param("action") && $q->param("action") eq "verify") {
validate($q, $session, $openid_url, sub {
$openid_error=shift;
});
}
- elsif ($q->param("do") eq "signin" || ! load_openid_module()) {
+ elsif ($q->param("do") eq "signin" && $real_cgi_signin) {
$real_cgi_signin->($q, $session);
exit;
}
cgiurl => $config{cgiurl},
(defined $openid_error ? (openid_error => $openid_error) : ()),
(defined $openid_url ? (openid_url => $openid_url) : ()),
- # TODO only if other auth methods are available
- nonopenidurl => IkiWiki::cgiurl(do => "signin"),
+ ($real_cgi_signin ? (nonopenidurl => IkiWiki::cgiurl(do => "signin")) : ()),
loginlabel => loginlabel(),
);
my $session=$params{session};
my $cgi=$params{cgi};
- if ($form->title eq "signin") {
- return unless load_openid_module();
-
- # This avoids it displaying a redundant label for the
- # OpenID fieldset.
- $form->fieldsets("OpenID");
-
- $form->field(
- name => "openid_url",
- label => loginlabel(),
- fieldset => "OpenID",
- size => 30,
- comment => ($config{openidsignup} ? " | <a href=\"$config{openidsignup}\">".gettext("Get an OpenID")."</a>" : "")
- );
-
- # Handle submission of an OpenID as validation.
- if ($form->submitted && $form->submitted eq "Login" &&
- defined $form->field("openid_url") &&
- length $form->field("openid_url")) {
- $form->field(
- name => "openid_url",
- validate => sub {
- validate($cgi, $session, shift, sub {
- # Display error in the form.
- $form->field(name => "openid_url", comment => shift);
- });
- },
- );
- # Skip all other required fields in this case.
- foreach my $field ($form->field) {
- next if $field eq "openid_url";
- $form->field(name => $field, required => 0,
- validate => '/.*/');
- }
- }
- }
- elsif ($form->title eq "preferences" &&
+ if ($form->title eq "preferences" &&
IkiWiki::openiduser($session->param("name"))) {
- $form->field(name => "openid_url", disabled => 1,
+ $form->field(name => "openid_identifier", disabled => 1,
label => htmllink("", "", "ikiwiki/OpenID", noimageinline => 1),
value => $session->param("name"),
size => 50, force => 1,
float: left;
margin: 2px 0;
}
-#signin_openid_url_label {
- float: left;
- margin-right: 1ex;
-}
-#signin_openid {
- padding: 10px 10px;
- border: 1px solid #aaa;
- background: #eee;
- color: black !important;
-}
label.block {
display: block;
}
li.form {
padding-bottom: 1em;
}
-input#openid_url {
- background: url(wikiicons/openidlogin-bg.gif) no-repeat;
- background-color: #fff;
- background-position: 0 50%;
- color: #000;
- padding-left: 18px;
-}
input#searchbox {
background: url(wikiicons/search-bg.gif) no-repeat;
background-color: #fff;
color: white !important;
background: #ff9900;
}
+
+/* openid selector */
+#openid_choice {
+ display: none;
+}
+#openid_input_area {
+ clear: both;
+ padding: 10px;
+}
+#openid_btns, #openid_btns br {
+ clear: both;
+}
+#openid_highlight {
+ padding: 3px;
+ background-color: #FFFCC9;
+ float: left;
+}
+.openid_large_btn {
+ width: 100px;
+ height: 60px;
+ border: 1px solid #DDD;
+ margin: 3px;
+ float: left;
+}
+.openid_small_btn {
+ width: 24px;
+ height: 24px;
+ border: 1px solid #DDD;
+ margin: 3px;
+ float: left;
+}
+a.openid_large_btn:focus {
+ outline: none;
+}
+a.openid_large_btn:focus {
+ -moz-outline-style: none;
+}
+.openid_selected {
+ border: 4px solid #DDD;
+}
-<script type="text/javascript" src="ikiwiki/openid-selector/jquery.js"></script>
-<script type="text/javascript" src="ikiwiki/openid-selector/openid-jquery.js"></script>
+<script type="text/javascript" src="ikiwiki/openid/jquery.js"></script>
+<script type="text/javascript" src="ikiwiki/openid/openid-jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
- openid.init('openid_url');
+ openid.init('openid_identifier');
});
</script>
-<TMPL_IF OPENID_ERROR>
-<div class="error"><TMPL_VAR OPENID_ERROR></span>
-</TMPL_IF>
-</div>
-
<form action="<TMPL_VAR CGIURL>" method="get" id="openid_form">
<input type="hidden" name="do" value="signin" />
<input type="hidden" name="action" value="verify" />
- <div id="openid_choice">
- <p><TMPL_VAR LOGINLABEL>:</p>
- <div id="openid_btns">
+ <fieldset>
+ <legend><TMPL_VAR LOGINLABEL></legend>
+ <div id="openid_choice">
+ <div id="openid_btns">
+ </div>
+ <TMPL_IF NONOPENIDURL>
+ <a href="<TMPL_VAR NONOPENIDURL>">local account</a>
+ </TMPL_IF>
</div>
- <TMPL_IF NONOPENIDURL>
- <a href="<TMPL_VAR NONOPENIDURL>">local account</a>
+ <div id="openid_input_area">
+ <input id="openid_identifier" name="openid_identifier" type="text" value="<TMPL_VAR 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>
- </div>
-
- <span id="openid_input_area">
- <input id="openid_url" name="openid_url" type="text" value="<TMPL_VAR OPENID_URL>"/>
- <input id="openid_submit" type="submit" value="Login"/>
- </span>
+ </fieldset>
</form>