[ckan-changes] commit/ckan: zephod: [merge, from-branch]: Pulling in Gravatars feature.
Bitbucket
commits-noreply at bitbucket.org
Fri Oct 21 16:32:00 UTC 2011
1 new changeset in ckan:
http://bitbucket.org/okfn/ckan/changeset/2e662f324bd1/
changeset: 2e662f324bd1
branch: release-v1.5
user: zephod
date: 2011-10-21 18:25:08
summary: [merge,from-branch]: Pulling in Gravatars feature.
affected #: 11 files (-1 bytes)
--- a/ckan/lib/dictization/model_dictize.py Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/lib/dictization/model_dictize.py Fri Oct 21 17:25:08 2011 +0100
@@ -186,6 +186,7 @@
del result_dict['password']
result_dict['display_name'] = user.display_name
+ result_dict['email_hash'] = user.email_hash
result_dict['number_of_edits'] = user.number_of_edits()
result_dict['number_administered_packages'] = user.number_administered_packages()
--- a/ckan/lib/helpers.py Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/lib/helpers.py Fri Oct 21 17:25:08 2011 +0100
@@ -215,6 +215,12 @@
def icon(name, alt=None):
return literal('<img src="%s" height="16px" width="16px" alt="%s" /> ' % (icon_url(name), alt))
+def gravatar(email_hash, size=100):
+ return literal('''<a href="http://gravatar.com" target="_blank">
+ <img src="http://gravatar.com/avatar/%s?s=%d&d=mm" />
+ </a>''' % (email_hash, size))
+
+
class Page(paginate.Page):
# Curry the pager method of the webhelpers.paginate.Page class, so we have
--- a/ckan/model/user.py Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/model/user.py Fri Oct 21 17:25:08 2011 +0100
@@ -49,6 +49,14 @@
if self.fullname is not None and len(self.fullname.strip()) > 0:
return self.fullname
return self.name
+
+ @property
+ def email_hash(self):
+ import hashlib
+ e = ''
+ if self.email:
+ e = self.email.strip().lower()
+ return hashlib.md5(e).hexdigest()
def get_reference_preferred_for_uri(self):
'''Returns a reference (e.g. name, id, openid) for this user
--- a/ckan/public/css/style.css Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/public/css/style.css Fri Oct 21 17:25:08 2011 +0100
@@ -554,6 +554,14 @@
border-right: 1px solid #ccc;
}
+.gravatar {
+ border: 1px solid #777;
+ padding: 1px;
+ width: 120px;
+ height: 120px;
+ margin: 0 auto 10px auto;
+}
+
/* ===================== */
/* = Stateful stuff = */
/* ===================== */
--- a/ckan/templates/user/layout.html Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/templates/user/layout.html Fri Oct 21 17:25:08 2011 +0100
@@ -6,11 +6,26 @@
><py:match path="minornavigation">
- <ul class="tabbed" py:if="c.is_myself">
- <li py:attrs="{'class':'current-tab'} if c.action=='read' else {}"><a href="${h.url_for(controller='user', action='read')}">My Profile</a></li>
- <li py:attrs="{'class':'current-tab'} if c.action=='edit' else {}"><a href="${h.url_for(controller='user', action='edit')}">Edit Profile</a></li>
- <li><a href="${h.url_for('/user/logout')}">Log out</a></li>
- </ul>
+ <py:if test="c.is_myself">
+ <ul class="tabbed">
+ <li py:attrs="{'class':'current-tab'} if c.action=='read' else {}"><a href="${h.url_for(controller='user', action='read')}">My Profile</a></li>
+ <li py:attrs="{'class':'current-tab'} if c.action=='edit' else {}"><a href="${h.url_for(controller='user', action='edit')}">Edit Profile</a></li>
+ <li><a href="${h.url_for('/user/logout')}">Log out</a></li>
+ </ul>
+ </py:if>
+ <py:if test="not c.is_myself">
+ <py:if test="c.id">
+ <ul class="tabbed">
+ <li py:attrs="{'class':'current-tab'} if c.action=='read' else {}"><a href="${h.url_for(controller='user', action='read')}">View Profile</a></li>
+ </ul>
+ </py:if>
+ <py:if test="not c.id">
+ <ul class="tabbed">
+ <li py:attrs="{'class':'current-tab'} if c.action=='login' else {}"><a href="${h.url_for(controller='user', action='login')}">Login</a></li>
+ <li py:attrs="{'class':'current-tab'} if c.action=='register' else {}"><a href="${h.url_for('register')}">Register Account</a></li>
+ </ul>
+ </py:if>
+ </py:if></py:match>
--- a/ckan/templates/user/login.html Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/templates/user/login.html Fri Oct 21 17:25:08 2011 +0100
@@ -34,10 +34,9 @@
<input type="hidden" name="remember" value="1576800000" /><br/></fieldset>
- ${h.submit('s', _('Login'))} —
+ <input name="s" id="s" type="submit" class="pretty-button primary" value="Sign In"/>
+ —
<a href="${h.url_for('reset')}">Forgot your password?</a>
- —
- ${h.link_to(_('Not yet registered?'), h.url_for(action='register'))}
</form><br/><!-- Simple OpenID Selector -->
@@ -66,7 +65,7 @@
</p></div></fieldset>
- <input id="openid_submit" type="submit" value="Sign in"/>
+ <input id="openid_submit" type="submit" class="pretty-button primary" value="Sign in with OpenID"/></form></div><xi:include href="layout.html" />
--- a/ckan/templates/user/logout.html Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/templates/user/logout.html Fri Oct 21 17:25:08 2011 +0100
@@ -4,8 +4,10 @@
<py:def function="page_title">Logout - User</py:def>
+ <py:def function="page_title">Logout</py:def>
+ <py:def function="page_heading">Logout from ${g.site_title}</py:def>
+
<div py:match="content">
- <h2>Logout</h2><p>You have logged out successfully.</p></div>
--- a/ckan/templates/user/new_user_form.html Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/templates/user/new_user_form.html Fri Oct 21 17:25:08 2011 +0100
@@ -45,5 +45,5 @@
</dd></dl>
- <input id="save" name="save" type="submit" value="Register now »" />
+ <input id="save" name="save" type="submit" class="pretty-button primary" value="Register now »" /></form>
--- a/ckan/templates/user/read.html Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/templates/user/read.html Fri Oct 21 17:25:08 2011 +0100
@@ -7,6 +7,9 @@
<py:def function="body_class">user-view</py:def><py:match path="primarysidebar">
+ <div class="gravatar">
+ ${h.gravatar(c.user_dict['email_hash'],120)}
+ </div><li class="widget-container widget_text" py:if="not c.hide_welcome_message"><h3>Activity</h3><ul>
--- a/ckan/templates/user/request_reset.html Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/templates/user/request_reset.html Fri Oct 21 17:25:08 2011 +0100
@@ -14,7 +14,7 @@
<input name="user" value="" /><br/></fieldset><div>
- ${h.submit('reset', _('Reset password'))}
+ <input type="submit" id="reset" name="reset" class="pretty-button primary" value="Reset Password" /></div></form></div>
--- a/ckan/tests/lib/test_helpers.py Fri Oct 21 17:23:36 2011 +0100
+++ b/ckan/tests/lib/test_helpers.py Fri Oct 21 17:25:08 2011 +0100
@@ -50,3 +50,15 @@
two_months_ago_str = h.datetime_to_date_str(two_months_ago)
res = h.time_ago_in_words_from_str(two_months_ago_str)
assert_equal(res, '2 months')
+
+ def test_gravatar(self):
+ email = 'zephod at gmail.com'
+ expected =['<a href="http://gravatar.com" target="_blank">', '<img src="http://gravatar.com/avatar/7856421db6a63efa5b248909c472fbd2?s=200&d=mm" />', '</a>']
+ # Hash the email address
+ import hashlib
+ email_hash = hashlib.md5(email).hexdigest()
+ res = h.gravatar(email_hash, 200)
+ for e in expected:
+ assert e in res, e
+
+
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list