Commits

Daniel Holth committed 56833f6

switch to openid-realselector

Comments (0)

Files changed (10)

+0.1
+---
+-  Switch to openid-realselector
+
 0.0
 ---
 

ponzi_openid/static/css/openid.css

+body {
+  font: 14px sans-serif;
+}
+
+#openid {
+  background: url(../img/indicator.gif) center center no-repeat;
+  margin: 0 auto;
+  width: 440px;
+  height: 162px;
+}
+
+#openid_inputarea {
+  clear: both;
+  display: none;
+  background: url(../img/balloon.png) no-repeat;
+  width: 410px;
+  height: 48px;
+  color: white;
+  text-align: center;
+  margin-top: 35px;
+  padding-top: 17px;
+}
+
+#openid_inputarea #openid_username {
+  margin: 0 4px 0 8px;
+  width: 120px;
+}
+
+#openid_btns, #openid_btns br {
+  clear: both;
+}
+
+#openid_highlight {
+  -moz-border-radius: 10px;
+  -webkit-border-radius: 10px;
+  padding: 2px;
+  background-color: #FFFCC9;
+  float: left;
+}
+
+.openid_large_btn, .openid_small_btn {
+  background: url(../img/openid-icons.png) no-repeat;
+  margin: 3px;
+  float: left;
+}
+
+.openid_large_btn {
+  width: 91px;
+  height: 51px;
+}
+
+.openid_small_btn {
+  width: 16px;
+  height: 16px;
+}  
+
+.Google { background-position: 0 0; }
+.Yahoo { background-position: 0 -51px; }
+.AOL { background-position: 0 -102px; }
+.OpenID { background-position: 0 -153px; }
+.MyOpenID { background-position: 0 -204px; }
+.Flickr { background-position: 0 -220px; }
+.Technorati { background-position: -17px -220px; }
+.Wordpress { background-position: -17px -204px; }
+.Blogger { background-position: -34px -204px; }
+.Verisign { background-position: -51px -220px; }
+.Vidoop { background-position: -34px -220px; }
+.ClaimID { background-position: -68px -204px; }
+.LiveJournal { background-position: -51px -204px; }
+.MySpace { background-position: -68px -220px; }
+
+a.openid_large_btn:focus {
+  outline: none;
+  -moz-outline-style: none;
+}

ponzi_openid/static/img/balloon.png

Added
New image

ponzi_openid/static/img/indicator.gif

Added
New image

ponzi_openid/static/img/openid-icons.png

Added
New image

ponzi_openid/static/js/jquery.openid.js

+/*
+OpenID Plugin
+http://code.google.com/p/openid-realselector/
+
+Martin Conte Mac Donell <Reflejo@gmail.com>
+*/
+
+(function($) {
+  $.fn.openid = function(opt) {
+    var gprovider;
+    var INPUTID = 'openid_username';
+    var inputarea = $('#openid_inputarea').length ? $('#openid_inputarea'): $('<div id="openid_inputarea" />');
+  
+    var defaults = {
+      txt: {
+        label: 'Enter your {provider} {username}',
+        username: 'username',
+        title: 'Select your openID provider',
+        sign: 'Sign-In'
+      },
+      /*
+       Default providers with url. "big" variable means that icon
+       will be big.
+      */
+      providers: [
+        {
+          name: 'Google',
+          url: 'https://www.google.com/accounts/o8/id',
+          label: null,
+          big: true
+        },
+        {
+          name: 'Yahoo',
+          url: 'http://yahoo.com/',
+          label: null,
+          big: true
+        },    
+        {
+          name: 'AOL',
+          username_txt: 'screenname',
+          url: 'http://openid.aol.com/{username}',
+          big: true
+        },
+        {
+          name: 'OpenID',
+          username_txt: 'url',
+          big: true
+        },
+        {
+          name: 'MyOpenID',
+          url: 'http://{username}.myopenid.com/'
+        },
+        {
+          name: 'Flickr',
+          url: 'http://flickr.com/{username}/'
+        },
+        {
+          name: 'Technorati',
+          url: 'http://technorati.com/people/technorati/{username}/'
+        },
+        {
+          name: 'Wordpress',
+          url: 'http://{username}.wordpress.com/'
+        },
+        {
+          name: 'Blogger',
+          url: 'http://{username}.blogspot.com/'
+        },
+        {
+          name: 'Verisign',
+          url: 'http://{username}.pip.verisignlabs.com/'
+        },
+        {
+          name: 'Vidoop',
+          url: 'http://{username}.myvidoop.com/'
+        },
+        {
+          name: 'ClaimID',
+          url: 'http://claimid.com/{username}'
+        },
+        {
+          name: 'LiveJournal',
+          url: 'http://{username}.livejournal.com'
+        },
+        {
+          name: 'MySpace',
+          url: 'http://www.myspace.com/{username}'
+        }
+      ],
+      cookie_expires: 6 * 30, // in days.
+      cookie_path: '/',
+      img_path: '/img/'
+    };
+  
+    var getBox = function(provider, idx, box_size) {
+      var a = $('<a title="' + provider + '" href="#" id="btn_' + idx + 
+                '" class="openid_' + box_size + '_btn ' + provider + '" />');
+      return a.click(signIn);
+    };
+  
+    var setCookie = function(value) {
+      var date = new Date();
+      date.setTime(date.getTime() + (settings.cookie_expires * 24 * 60 * 60 * 1000));
+      document.cookie = "openid_prov=" + value + "; expires=" + date.toGMTString() + 
+                        "; path=" + settings.cookie_path;
+    };
+  
+    var readCookie = function(){
+      var c = document.cookie.split(';');
+      for(i in c){
+        if ((pos = c[i].indexOf("openid_prov=")) != -1) 
+          return $.trim(c[i].slice(pos + 12));
+      }
+    };
+  
+    var signIn = function(obj, tidx) {
+      var idx = $(tidx || this).attr('id').replace('btn_', '');
+      if (!(gprovider = settings.providers[idx]))
+        return;
+    
+      // Hightlight
+      if (highlight = $('#openid_highlight'))
+        highlight.replaceWith($('#openid_highlight a')[0]);
+   
+      $('#btn_' + idx).wrap('<div id="openid_highlight" />');
+      setCookie(idx);
+  
+      // prompt user for input?
+      showInputBox();
+      if (gprovider.label === null) {
+        inputarea.text(settings.txt.title);
+        if (!tidx) {
+          inputarea.fadeOut();
+          form.submit();
+        }
+      }
+      return false;
+    };
+  
+    var showInputBox = function() {
+      var lbl = (gprovider.label || settings.txt.label).replace(
+        '{username}', (gprovider.username_txt !== undefined) ? gprovider.username_txt: settings.txt.username
+      ).replace('{provider}', gprovider.name);
+  
+      inputarea.empty().show().append('<span class="oidlabel">' + lbl + '</span><input id="' + INPUTID + '" type="text" ' +
+        ' name="username_txt" class="Verisign"/><input type="submit" value="' + settings.txt.sign + '"/>');
+  
+      $('#' + INPUTID).focus();
+    };
+  
+    var submit = function(){
+      var prov = (gprovider.url) ? gprovider.url.replace('{username}', $('#' + INPUTID).val()): $('#' + INPUTID).val();
+      form.append($('<input type="hidden" name="url" value="' + prov + '" />'));
+    };
+  
+    var settings = $.extend(defaults, opt || {});
+    var btns = $('<div id="openid_btns" />');
+  
+    // Add box for each provider
+    var addbr = true;
+    $.each(settings.providers, function(i, val) {
+      if (!val.big && addbr) {
+        btns.append('<br />');
+        addbr = false;
+      }
+      btns.append(getBox(val.name, i, (val.big) ? 'large': 'small'));
+    });
+  
+    var form = this;
+    form.css({'background-image': 'none'});
+    form.append(btns).submit(submit);
+    btns.append(inputarea);
+  
+    if (idx = readCookie())
+      signIn(null, '#btn_' + idx);
+    else
+  	inputarea.text(settings.txt.title).show();
+  
+    return this;
+  };
+})(jQuery);

ponzi_openid/static/js/jquery.openid.min.js

+/*
+OpenID Plugin
+http://code.google.com/p/openid-realselector/
+
+Martin Conte Mac Donell <Reflejo@gmail.com>
+*/
+(function($){$.fn.openid=function(e){var f;var g='openid_username';var h=$('#openid_inputarea').length?$('#openid_inputarea'):$('<div id="openid_inputarea" />');var j={txt:{label:'Enter your {provider} {username}',username:'username',title:'Select your openID provider',sign:'Sign-In'},providers:[{name:'Google',url:'https://www.google.com/accounts/o8/id',label:null,big:true},{name:'Yahoo',url:'http://yahoo.com/',label:null,big:true},{name:'AOL',username_txt:'screenname',url:'http://openid.aol.com/{username}',big:true},{name:'OpenID',username_txt:'url',big:true},{name:'MyOpenID',url:'http://{username}.myopenid.com/'},{name:'Flickr',url:'http://flickr.com/{username}/'},{name:'Technorati',url:'http://technorati.com/people/technorati/{username}/'},{name:'Wordpress',url:'http://{username}.wordpress.com/'},{name:'Blogger',url:'http://{username}.blogspot.com/'},{name:'Verisign',url:'http://{username}.pip.verisignlabs.com/'},{name:'Vidoop',url:'http://{username}.myvidoop.com/'},{name:'ClaimID',url:'http://claimid.com/{username}'},{name:'LiveJournal',url:'http://{username}.livejournal.com'},{name:'MySpace',url:'http://www.myspace.com/{username}'}],cookie_expires:6*30,cookie_path:'/',img_path:'/img/'};var k=function(b,c,d){var a=$('<a title="'+b+'" href="#" id="btn_'+c+'" class="openid_'+d+'_btn '+b+'" />');return a.click(n)};var l=function(a){var b=new Date();b.setTime(b.getTime()+(q.cookie_expires*24*60*60*1000));document.cookie="openid_prov="+a+"; expires="+b.toGMTString()+"; path="+q.cookie_path};var m=function(){var c=document.cookie.split(';');for(i in c){if((pos=c[i].indexOf("openid_prov="))!=-1)return $.trim(c[i].slice(pos+12))}};var n=function(a,b){var c=$(b||this).attr('id').replace('btn_','');if(!(f=q.providers[c]))return;if(highlight=$('#openid_highlight'))highlight.replaceWith($('#openid_highlight a')[0]);$('#btn_'+c).wrap('<div id="openid_highlight" />');l(c);o();if(f.label===null){h.text(q.txt.title);if(!b){h.fadeOut();t.submit()}}return false};var o=function(){var a=(f.label||q.txt.label).replace('{username}',(f.username_txt!==undefined)?f.username_txt:q.txt.username).replace('{provider}',f.name);h.empty().show().append('<span class="oidlabel">'+a+'</span><input id="'+g+'" type="text" '+' name="username_txt" class="Verisign"/><input type="submit" value="'+q.txt.sign+'"/>');$('#'+g).focus()};var p=function(){var a=(f.url)?f.url.replace('{username}',$('#'+g).val()):$('#'+g).val();t.append($('<input type="hidden" name="url" value="'+a+'" />'))};var q=$.extend(j,e||{});var r=$('<div id="openid_btns" />');var s=true;$.each(q.providers,function(i,a){if(!a.big&&s){r.append('<br />');s=false}r.append(k(a.name,i,(a.big)?'large':'small'))});var t=this;t.css({'background-image':'none'});t.append(r).submit(p);r.append(h);if(idx=m())n(null,'#btn_'+idx);else h.text(q.txt.title).show();return this}})(jQuery);

ponzi_openid/templates/openid.jinja2

 {% extends 'base.jinja2' %}
-{% block title %}jQuery OpenID Plugin{% endblock %}
+{% block title %}Login with your third-party account.{% endblock %}
 {% block css %}
 {{ super() }}
 <link rel="stylesheet" type="text/css" media="screen" href="{{ request.script_name }}/static/css/openid.css" />
-<!-- jQuery OpenID Plugin 1.1 Copyright 2009 Jarrett Vance http://jvance.com/pages/jQueryOpenIdPlugin.xhtml -->
 {% endblock %}
 {% block body %}
-	<h1>jQuery OpenID Plugin</h1>
-<address>By <a href="http://jvance.com">Jarrett Vance</a></address><br />
-
-<h2>Login (with javascript)</h2>
-<form class="openid" id="openid" method="post" action="{{ request.url }}"> 
-  <div><ul class="providers"> 
-  <li class="direct" title="Google"> 
-		<img src="{{ request.script_name }}/static/images/googleW.png" alt="icon" /><span>https://www.google.com/accounts/o8/id</span></li> 
-  <li class="direct" title="Yahoo"> 
-		<img src="{{ request.script_name }}/static/images/yahooW.png" alt="icon" /><span>http://yahoo.com/</span></li> 
-  <li class="username" title="AOL screen name"> 
-		<img src="{{ request.script_name }}/static/images/aolW.png" alt="icon" /><span>http://openid.aol.com/<strong>username</strong></span></li> 
-  <li class="username" title="MyOpenID user name"> 
-		<img src="{{ request.script_name }}/static/images/myopenid.png" alt="icon" /><span>http://<strong>username</strong>.myopenid.com/</span></li> 
-  <li class="username" title="Flickr user name"> 
-		<img src="{{ request.script_name }}/static/images/flickr.png" alt="icon" /><span>http://flickr.com/<strong>username</strong>/</span></li> 
-  <li class="username" title="Technorati user name"> 
-		<img src="{{ request.script_name }}/static/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="{{ request.script_name }}/static/images/wordpress.png" alt="icon" /><span>http://<strong>username</strong>.wordpress.com</span></li> 
-  <li class="username" title="Blogger blog name"> 
-		<img src="{{ request.script_name }}/static/images/blogger.png" alt="icon" /><span>http://<strong>username</strong>.blogspot.com/</span></li> 
-  <li class="username" title="LiveJournal blog name"> 
-		<img src="{{ request.script_name }}/static/images/livejournal.png" alt="icon" /><span>http://<strong>username</strong>.livejournal.com</span></li> 
-  <li class="username" title="ClaimID user name"> 
-		<img src="{{ request.script_name }}/static/images/claimid.png" alt="icon" /><span>http://claimid.com/<strong>username</strong></span></li> 
-  <li class="username" title="Vidoop user name"> 
-		<img src="{{ request.script_name }}/static/images/vidoop.png" alt="icon" /><span>http://<strong>username</strong>.myvidoop.com/</span></li> 
-  <li class="username" title="Verisign user name"> 
-		<img src="{{ request.script_name }}/static/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> 
-  <input type="submit" value="Login" /></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" /> 
-  <input type="submit" value="Login" /></div> 
-  </fieldset> 
-</form>
-
-<p>Visit <a href="http://jvance.com/pages/jQueryOpenIdPlugin.xhtml">jQuery OpenID Plugin Homepage</a> for updates.</p>
-
-<p><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike 3.0 Unported License</a>.</p>
+<form method="post" action="{{ request.url }}" id="openid"></form>
 {% endblock %}
 {% block js %}
 {{ super() }}
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
-<script type="text/javascript" src="{{ request.script_name }}/static/js/jquery.openid.js"></script>
-<script type="text/javascript">  $(function() { $("form.openid:eq(0)").openid(); });</script>
+<script type="text/javascript" src="{{ request.script_name }}/static/js/jquery.openid.min.js"></script>
+<script type="text/javascript">
+  $(function() {
+    $('#openid').openid({
+      img_path: '{{ request.script_name }}/static/img',
+      txt: {
+        label: 'Ingresá tu {username} de <b>{provider}</b>',
+        username: 'usuario',
+        title: 'Seleccioná la página donde tengas una cuenta.',
+        sign: 'Ir'
+      }
+    });
+  });
+</script>
 {% endblock %}

ponzi_openid/views.py

 log = logging.getLogger(__name__)
 
 class OpenID(object):
+    """Handle the OpenID authentication flow."""
 
     def __init__(self, context, request):
         self.context=context
     def redirect(self):
         """Redirect to OpenID provider or POST+JavaScript pseudo-redirect."""
         c = self.get_consumer(self.request)
-        auth_request = c.begin(user_url=self.request.POST['openid_identifier'])
+        auth_request = c.begin(user_url=self.request.POST['url'])
         return_to = self.base_url.rstrip('/')+'/success'
         # is this the place to set ax/sreg extensions?
         if auth_request.shouldSendRedirect():
 ]
 
 setup(name='ponzi_openid',
-      version='0.0',
+      version='0.1',
       description='ponzi_openid',
       long_description=README + '\n\n' +  CHANGES,
       classifiers=[