Commits

Robert Kern committed dbf36da

ENH: partial OpenID selector.
(transplanted from 847b79728d2d584eaaa3ba8084f82241e764f6d6)

  • Participants
  • Parent commits c3e7eb0

Comments (0)

Files changed (24)

File solace/_openid_auth.py

 
     def complete_login(self, request):
         consumer = Consumer(request.session, SolaceOpenIDStore())
+        print ' request.args.to_dict() = %r' % (request.args.to_dict(),)
         openid_response = consumer.complete(request.args.to_dict(),
                                             url_for('core.login', _external=True))
+        print ' openid_response.openid_identifier = %r' % (openid_response.openid_identifier,)
         if openid_response.status == SUCCESS:
-            return self.create_or_login(request, openid_response.identity_url)
+            return self.create_or_login(request, openid_response.openid_identifier)
         elif openid_response.status == CANCEL:
             raise LoginUnsucessful(_(u'The request was cancelled'))
         else:

File solace/static/images/aolW.png

Added
New image

File solace/static/images/blogger.png

Added
New image

File solace/static/images/claimid.png

Added
New image

File solace/static/images/facebookW.png

Added
New image

File solace/static/images/fadegrey.png

Added
New image

File solace/static/images/flickr.png

Added
New image

File solace/static/images/flickrW.png

Added
New image

File solace/static/images/googleW.png

Added
New image

File solace/static/images/livejournal.png

Added
New image

File solace/static/images/myopenid.png

Added
New image

File solace/static/images/myopenidW.png

Added
New image

File solace/static/images/myspaceW.png

Added
New image

File solace/static/images/openidW.png

Added
New image

File solace/static/images/openidico.png

Added
New image

File solace/static/images/technorati.png

Added
New image

File solace/static/images/verisign.png

Added
New image

File solace/static/images/vidoop.png

Added
New image

File solace/static/images/wordpress.png

Added
New image

File solace/static/images/yahooW.png

Added
New image

File solace/static/jquery.openid.js

+//jQuery OpenID Plugin 1.1 Copyright 2009 Jarrett Vance http://jvance.com/pages/jQueryOpenIdPlugin.xhtml
+$.fn.openid = function() {
+  var $this = $(this);
+  var $usr = $this.find('input[name=openid_username]');
+  var $id = $this.find('input[name=openid_identifier]');
+  var $front = $this.find('div:has(input[name=openid_username])>span:eq(0)');
+  var $end = $this.find('div:has(input[name=openid_username])>span:eq(1)');
+  var $usrfs = $this.find('fieldset:has(input[name=openid_username])');
+  var $idfs = $this.find('fieldset:has(input[name=openid_identifier])');
+
+  var submitusr = function() {
+    if ($usr.val().length < 1) {
+      $usr.focus();
+      return false;
+    }
+    $id.val($front.text() + $usr.val() + $end.text());
+    return true;
+  };
+
+  var submitid = function() {
+    if ($id.val().length < 1) {
+      $id.focus();
+      return false;
+    }
+    return true;
+
+  };
+  var direct = function() {
+    var $li = $(this);
+    $li.parent().find('li').removeClass('highlight');
+    $li.addClass('highlight');
+    $usrfs.fadeOut();
+    $idfs.fadeOut();
+
+    $this.unbind('submit').submit(function() {
+        console.log($this.find("li.highlight span").text());
+      $id.val($this.find("li.highlight span").text());
+    });
+    console.log($this);
+    $this.submit();
+    return false;
+  };
+
+  var openid = function() {
+    var $li = $(this);
+    $li.parent().find('li').removeClass('highlight');
+    $li.addClass('highlight');
+    $usrfs.hide();
+    $idfs.show();
+    $id.focus();
+    $this.unbind('submit').submit(submitid);
+    return false;
+  };
+
+  var username = function() {
+    var $li = $(this);
+    $li.parent().find('li').removeClass('highlight');
+    $li.addClass('highlight');
+    $idfs.hide();
+    $usrfs.show();
+    $this.find('label[for=openid_username] span').text($li.attr("title"));
+    $front.text($li.find("span").text().split("username")[0]);
+    $end.text("").text($li.find("span").text().split("username")[1]);
+    $id.focus();
+    $this.unbind('submit').submit(submitusr);
+    return false;
+  };
+
+  $this.find('li.direct').click(direct);
+  $this.find('li.openid').click(openid);
+  $this.find('li.username').click(username);
+  $id.keypress(function(e) {
+    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
+      return submitid();
+    }
+  });
+  $usr.keypress(function(e) {
+    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
+      return submitusr();
+    }
+  });
+  $this.find('li span').hide();
+  $this.find('li').css('line-height', 0).css('cursor', 'pointer');
+  $this.find('li:eq(0)').click();
+  return this;
+};

File solace/static/openid.css

+fieldset {border-style:none;}
+img {border-style:none;}
+
+form.openid ul { text-align:center; list-style-type:none; display:inline;}
+form.openid ul li {float:left; padding:4px}
+form.openid ul li span {padding:0 1em 0 3px}
+form.openid fieldset {clear:both; padding:1em 0}
+form.openid div+fieldset {display:none}
+form.openid label {display:block; font-weight:bold; font-size:larger; margin-bottom:.5em}
+input[name=openid_username] {width:8em}
+input[name=openid_identifier] {width:18em}
+form.openid ul li.highlight { -moz-border-radius:4px; -webkit-border-radius:4px; background-color: #FD6}
+form.openid fieldset div {font-family:arial;-moz-border-radius:4px; -webkit-border-radius:4px; 
+                          background: #DCDCDC url(images/fadegrey.png); padding:10px;display:inline-block}
+form.openid input[type='submit'] {margin-left:1em;}
+
+.openid_logo{color:#F7931E;padding:6px 0px 8px 28px; background: url(images/openidico.png) no-repeat}
+
+#openid_login{float:left; font-size:larger; width:30%; margin:2em 1em; text-align:center}
+#openid_login div{margin-top:0.5em}
+#openid_login div+span{font-size:smaller}

File solace/templates/core/login_openid.html

 {% extends 'layout.html' %}
 {% set page_title = _('Login with OpenID') %}
+{% block extra_header %}
+<script type="text/javascript" src="{{ url_for('static', file='jquery.openid.js') }}"></script>
+<script type="text/javascript">  $(function() { $("form.openid:eq(0)").openid(); });</script>
+<link rel="stylesheet" type="text/css" media="screen" href="{{ url_for('static', file='openid.css') }}" />
+{% endblock %}
 {% block body %}
   <h1>{{ _('Login with OpenID') }}</h1>
   <p>{% trans -%}
     Enter your OpenID URL to login.
   {%- endtrans %}
-  {% call form() %}
-    <dl>
-      {{ form.identity_url.as_dd(class='openid') }}
-    </dl>
-    <script type="text/javascript">
-      $('input[name=identity_url]').focus();
-    </script>
-    <div class="buttons">
-      <input type="submit" value="{{ _('Login') }}">
-    </div>
+  {% call form(class="openid") %}
+  <div><ul class="providers"> 
+          <li class="openid" title="OpenID"><img src="{{ url_for('static', file='images/openidW.png') }}" alt="icon" /> 
+  <span><strong>http://{your-openid-url}</strong></span></li> 
+  <li class="direct" title="Google"> 
+		<img src="{{ url_for('static', file='images/googleW.png') }}" alt="icon" /><span>https://www.google.com/accounts/o8/id</span></li> 
+  <li class="direct" title="Yahoo"> 
+		<img src="{{ url_for('static', file='images/yahooW.png') }}" alt="icon" /><span>http://yahoo.com/</span></li> 
+  <li class="username" title="AOL screen name"> 
+		<img src="{{ url_for('static', file='images/aolW.png') }}" alt="icon" /><span>http://openid.aol.com/<strong>username</strong></span></li> 
+  <li class="username" title="MyOpenID user name"> 
+		<img src="{{ url_for('static', file='images/myopenid.png') }}" alt="icon" /><span>http://<strong>username</strong>.myopenid.com/</span></li> 
+  <li class="username" title="Flickr user name"> 
+		<img src="{{ url_for('static', file='images/flickr.png') }}" alt="icon" /><span>http://flickr.com/<strong>username</strong>/</span></li> 
+  <li class="username" title="Technorati user name"> 
+		<img src="{{ url_for('static', file='images/technorati.png') }}" alt="icon" /><span>http://technorati.com/people/technorati/<strong>username</strong>/</span></li> 
+  <li class="username" title="Wordpress blog name"> 
+		<img src="{{ url_for('static', file='images/wordpress.png') }}" alt="icon" /><span>http://<strong>username</strong>.wordpress.com</span></li> 
+  <li class="username" title="Blogger blog name"> 
+		<img src="{{ url_for('static', file='images/blogger.png') }}" alt="icon" /><span>http://<strong>username</strong>.blogspot.com/</span></li> 
+  <li class="username" title="LiveJournal blog name"> 
+		<img src="{{ url_for('static', file='images/livejournal.png') }}" alt="icon" /><span>http://<strong>username</strong>.livejournal.com</span></li> 
+  <li class="username" title="ClaimID user name"> 
+		<img src="{{ url_for('static', file='images/claimid.png') }}" alt="icon" /><span>http://claimid.com/<strong>username</strong></span></li> 
+  <li class="username" title="Vidoop user name"> 
+		<img src="{{ url_for('static', file='images/vidoop.png') }}" alt="icon" /><span>http://<strong>username</strong>.myvidoop.com/</span></li> 
+  <li class="username" title="Verisign user name"> 
+		<img src="{{ url_for('static', file='images/verisign.png') }}" alt="icon" /><span>http://<strong>username</strong>.pip.verisignlabs.com/</span></li> 
+  </ul></div> 
+
+  <fieldset> 
+  <label for="openid_username">Enter your <span>Provider user name</span></label> 
+  <div><span></span><input type="text" name="openid_username" /><span></span> 
+      <div class="buttons">
+        <input type="submit" value="{{ _('Login') }}" />
+      </div>
+  </div>
+  </fieldset> 
+
+  <fieldset> 
+  <label for="openid_identifier">Enter your <a class="openid_logo" href="http://openid.net">OpenID</a></label> 
+  <div><input type="text" name="openid_identifier" /> 
+      <div class="buttons">
+        <input type="submit" value="{{ _('Login') }}" />
+      </div>
+  </div>
+  </fieldset> 
+  
   {% endcall %}
 {% endblock %}

File solace/templates/layout.html

 <title>{% block html_head_title %}{% if page_title %}{{ page_title|e
   }} | {% endif %}{{ settings.WEBSITE_TITLE|e }}{% endblock %}</title>
 {{ packs.default }}
+{% block extra_header %}{% endblock %}
 <script type="text/javascript" src="{{ url_for('core.get_translations', lang=request.locale) }}"></script>
 <!--[if IE]><link rel="stylesheet" type="text/css" href="{{ url_for('static', file='ie.css') }}"><![endif]-->
 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="{{ url_for('static', file='ie6.css') }}"><![endif]-->