Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Initial packaging of easyopenid app
- Loading branch information
0 parents
commit 1354ab0
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Nicola Paolucci <durden@gmail.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
QUICK SETUP INSTRUCTIONS | ||
- copy easyopenid into your apps folder | ||
- move folder easyopenid/templates/easyopenid to your templates folder. | ||
- add 'easyopenid' to INSTALLED_APPS in settings.py | ||
- run ./manage.py syncdb | ||
- in your login/setup page put a include of the form {% include "easyopenid/providers.html" %} where you want the easyopenid form to appear. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2008 Nicola Paolucci | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[{"pk": 1, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.blogger.com/favicon.ico", "name": "Blogger", "pattern": "http://<TEXTFIELD>.blogspot.com"}}, | ||
{"pk": 2, "model": "easyopenid.openidprovider", "fields": {"icon": "/site_media/openid_providers/aol.png", "name": "AOL", "pattern": "http://openid.aol.com/<TEXTFIELD>"}}, | ||
{"pk": 3, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.flickr.com/favicon.ico", "name": "Flickr", "pattern": "http://www.flickr.com/photos/<TEXTFIELD>"}}, | ||
{"pk": 4, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.livedoor.com/favicon.ico", "name": "LiveDoor", "pattern": "http://profile.livedoor.com/<TEXTFIELD>"}}, | ||
{"pk": 5, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.livejournal.com/favicon.ico", "name": "LiveJournal", "pattern": "http://<TEXTFIELD>.livejournal.com"}}, | ||
{"pk": 7, "model": "easyopenid.openidprovider", "fields": {"icon": "/site_media/openid_providers/smugmug.png", "name": "SmugMug", "pattern": "http://<TEXTFIELD>.smugmug.com"}}, | ||
{"pk": 8, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.technorati.com/favicon.ico", "name": "Technorati", "pattern": "http://technorati.com/people/technorati/<TEXTFIELD>"}}, | ||
{"pk": 9, "model": "easyopenid.openidprovider", "fields": {"icon": "/site_media/openid_providers/vox.png", "name": "Vox", "pattern": "http://<TEXTFIELD>.vox.com"}}, | ||
{"pk": 10, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.yahoo.com/favicon.ico", "name": "Yahoo", "pattern": "http://yahoo.com"}}, | ||
{"pk": 11, "model": "easyopenid.openidprovider", "fields": {"icon": "http://www.wordpress.com/favicon.ico", "name": "Wordpress", "pattern": "http://<TEXTFIELD>.wordpress.com"}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
class OpenidProvider(models.Model): | ||
icon = models.CharField(_('icon'), max_length=255, unique=False) | ||
name = models.CharField(_('name'), max_length=80, unique=True) | ||
pattern = models.CharField(_('pattern'), max_length=200, unique=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{% load i18n %} | ||
<fieldset> | ||
<legend>{% trans "Login/Signup with OpenID:" %}</legend> | ||
<div id="openid-providers"> | ||
<table width="100%" id="providers_table"> | ||
{% for provider in providers %} | ||
{% if forloop.counter0|divisibleby:"3" %}<tr>{% endif %} | ||
<td> | ||
<a href="#" id="provider-entry-{{provider.name}}" style="text-decoration: none"><img src="{{provider.icon}}" class="favicon" />{{ provider.name }}</a> | ||
</td> | ||
{% if forloop.counter0|add:"1"|divisibleby:"3" %}</tr>{% endif %} | ||
{% endfor %} | ||
{% if providers|length|divisibleby:"3" %}{% else %}</tr>{% endif %} | ||
</table> | ||
<p></p> | ||
<a href="#" id="other-openid-provider"><img src="/site_media/openid-icon.png" />{% trans "Or click here to sign in with another OpenID provider" %}</a> | ||
</div> | ||
<form id="openid-login" class="login" action="{% url django_openidconsumer.views.begin %}" method="POST" style="display: none;"> | ||
<table> | ||
<tr><td width="150px"> | ||
<span id="openid-provider-icon"><img src="/site_media/openid-icon.png" /></span> | ||
<span id="openid-provider-label">{% trans "OpenID Identifier" %}</span>:</td> | ||
</tr> | ||
<tr> | ||
<td colspan="3"> | ||
<span id="openid-provider-pattern" class="alignCenter"></span> | ||
</td> | ||
</tr> | ||
<tr><td></td><td><input type="submit" value="{% trans "Log in »" %}" class="button" /></td></tr> | ||
</table> | ||
</form> | ||
<a href="#" id="pick-another-openid-provider" style="display: none;">{% trans "Go back and pick another from the list." %}</a> | ||
<p>What is OpenID? <a href="http://openid.net/what/" target="_blank">Learn it now.</a></p> | ||
</fieldset> | ||
|
||
{% block extra_body %} | ||
<script type="text/javascript"> | ||
|
||
function pattern_input_text(pattern) { | ||
pre_index = pattern.indexOf('<'); | ||
if (pre_index >= 0) { | ||
post_index = pattern.indexOf('>'); | ||
pre = pattern.substring(0,pre_index); | ||
post = pattern.substring(post_index+4,pattern.length); | ||
result = pre + '<input class="openid" type="text" id="openid_url" name="openid_url" value="your id" />' + post + '<input type="hidden" id="hidden-pattern" value="'+pattern+'" />'; | ||
return result; | ||
} else { | ||
result = '<input class="openid" type="hidden" id="openid_url" name="openid_url" value="" />' + pattern + '<input type="hidden" id="hidden-pattern" value="'+pattern+'" />'; | ||
return result; | ||
} | ||
} | ||
|
||
function compute_open_id(login,pattern) { | ||
pre_index = pattern.indexOf('<'); | ||
if (pre_index >= 0) { | ||
post_index = pattern.indexOf('>') + 1; | ||
pre = pattern.substring(0,pre_index); | ||
post = pattern.substring(post_index,pattern.length); | ||
result = pre + login + post; | ||
return result; | ||
} else { | ||
return pattern; | ||
} | ||
} | ||
|
||
$(document).ready(function() { | ||
$("#openid-login").hide(); | ||
$("#pick-another-openid-provider").hide(); | ||
{% for provider in providers %} | ||
$("#provider-entry-{{provider.name}}").click(function() { | ||
$("#openid-provider-icon").html('<img src="{{ provider.icon }}" />'); | ||
$("#openid-provider-label").html("{{provider.name}} id"); | ||
$("#openid-provider-pattern").html(pattern_input_text('{{provider.pattern}}')); | ||
$("#openid-login").show(); | ||
$("#openid-providers").hide(); | ||
$("#pick-another-openid-provider").show(); | ||
}); | ||
{% endfor %} | ||
|
||
$("#other-openid-provider").click(function() { | ||
$("#openid-provider-icon").html('<img src="/site_media/openid-icon.png" />'); | ||
$("#openid-provider-label").html("OpenID Identifier"); | ||
$("#openid-provider-pattern").html('<input class="openid" type="text" id="openid_url" name="openid_url" value="">'); | ||
$("#openid-login").show(); | ||
$("#openid-providers").hide(); | ||
$("#pick-another-openid-provider").show(); | ||
}); | ||
|
||
$("#pick-another-openid-provider").click(function() { | ||
$("#openid-providers").show(); | ||
$("#pick-another-openid-provider").hide(); | ||
$("#openid-login").hide(); | ||
}); | ||
|
||
$("#openid-login").submit(function() { | ||
//alert('openid=' + compute_open_id($('#openid_url').val(),$('#hidden-pattern').val())); | ||
computed = compute_open_id($('#openid_url').val(),$('#hidden-pattern').val()); | ||
$("#openid-provider-pattern").html('<input class="openid" type="text" id="openid_url" name="openid_url" value="'+ computed +'">'); | ||
return true; | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} |