[ckan-changes] commit/ckan: 4 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Oct 28 11:15:16 UTC 2011
4 new commits in ckan:
https://bitbucket.org/okfn/ckan/changeset/cb7950146d91/
changeset: cb7950146d91
branch: feature-1410-gravatars
user: zephod
date: 2011-10-27 20:02:43
summary: [gravatars][s]: Gravatars appear on tiny user portraits.
affected #: 3 files
diff -r 64acb729fdf471d674d102f24badf9a223fe2b5c -r cb7950146d9102665096e17737a19f812119fb3a ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -15,6 +15,7 @@
from webhelpers import paginate
from webhelpers.text import truncate
import webhelpers.date as date
+from pylons import g
from pylons.decorators.cache import beaker_cache
from routes import url_for, redirect_to
from alphabet_paginate import AlphaPage
@@ -188,7 +189,9 @@
return user_name
if user:
_name = user.name if model.User.VALID_NAME.match(user.name) else user.id
- _icon = icon("user") + " "
+ # Absolute URL of default user icon
+ _icon_url_default = g.site_url + icon_url("user")
+ _icon = gravatar(user.email_hash, 16, _icon_url_default)
displayname = user.display_name
if maxlength and len(user.display_name) > maxlength:
displayname = displayname[:maxlength] + '...'
@@ -212,13 +215,17 @@
def icon_url(name):
return '/images/icons/%s.png' % name
+def icon_html(url, alt=None):
+ return literal('<img src="%s" height="16px" width="16px" alt="%s" /> ' % (url, alt))
+
def icon(name, alt=None):
- return literal('<img src="%s" height="16px" width="16px" alt="%s" /> ' % (icon_url(name), alt))
+ return icon_html(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))
+def linked_gravatar(email_hash, size=100, default="mm"):
+ return literal('<a href="http://gravatar.com" target="_blank">%s</a>' % gravatar(email_hash,size,default))
+
+def gravatar(email_hash, size=100, default="mm"):
+ return literal('<img src="http://gravatar.com/avatar/%s?s=%d&d=%s" />' % (email_hash, size, default))
class Page(paginate.Page):
diff -r 64acb729fdf471d674d102f24badf9a223fe2b5c -r cb7950146d9102665096e17737a19f812119fb3a ckan/templates/user/read.html
--- a/ckan/templates/user/read.html
+++ b/ckan/templates/user/read.html
@@ -8,7 +8,7 @@
<py:match path="primarysidebar"><div class="gravatar">
- ${h.gravatar(c.user_dict['email_hash'],120)}
+ ${h.linked_gravatar(c.user_dict['email_hash'],120)}
</div><li class="widget-container widget_text" py:if="not c.hide_welcome_message"><h3>Activity</h3>
diff -r 64acb729fdf471d674d102f24badf9a223fe2b5c -r cb7950146d9102665096e17737a19f812119fb3a ckan/tests/lib/test_helpers.py
--- a/ckan/tests/lib/test_helpers.py
+++ b/ckan/tests/lib/test_helpers.py
@@ -57,7 +57,7 @@
# Hash the email address
import hashlib
email_hash = hashlib.md5(email).hexdigest()
- res = h.gravatar(email_hash, 200)
+ res = h.linked_gravatar(email_hash, 200)
for e in expected:
assert e in res, e
https://bitbucket.org/okfn/ckan/changeset/db211d47516c/
changeset: db211d47516c
branch: feature-1410-gravatars
user: zephod
date: 2011-10-27 20:02:54
summary: [close-branch]:
affected #: 0 files
https://bitbucket.org/okfn/ckan/changeset/1bdaf1b5022e/
changeset: 1bdaf1b5022e
user: zephod
date: 2011-10-28 13:12:19
summary: [gravatars][m]: Re-adding Gravatars feature to default
affected #: 12 files
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/lib/dictization/model_dictize.py
--- a/ckan/lib/dictization/model_dictize.py
+++ b/ckan/lib/dictization/model_dictize.py
@@ -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()
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -222,6 +222,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
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/model/user.py
--- a/ckan/model/user.py
+++ b/ckan/model/user.py
@@ -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
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/public/css/style.css
--- a/ckan/public/css/style.css
+++ b/ckan/public/css/style.css
@@ -811,6 +811,14 @@
+.gravatar {
+ border: 1px solid #777;
+ padding: 1px;
+ width: 120px;
+ height: 120px;
+ margin: 0 auto 10px auto;
+}
+
/* ===================== */
/* = Edit Dataset Page = */
/* ===================== */
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/package/read.html
--- a/ckan/templates/package/read.html
+++ b/ckan/templates/package/read.html
@@ -18,13 +18,6 @@
<py:match path="primarysidebar">
- <li class="widget-container boxed widget_text" py:if="not c.hide_welcome_message">
- <h3>First time at ${g.site_title}?</h3>
- <p>
- ${g.site_title} is a catalogue for data. ${h.subnav_link(c, _('Click here to find out more ...'), controller='home', action='about', id=None)}
- </p>
- </li>
-
<li class="widget-container widget_text"><ul class="property-list"><li py:if="c.pkg.url">
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/user/layout.html
--- a/ckan/templates/user/layout.html
+++ b/ckan/templates/user/layout.html
@@ -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>
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/user/login.html
--- a/ckan/templates/user/login.html
+++ b/ckan/templates/user/login.html
@@ -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" />
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/user/logout.html
--- a/ckan/templates/user/logout.html
+++ b/ckan/templates/user/logout.html
@@ -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>
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/user/new_user_form.html
--- a/ckan/templates/user/new_user_form.html
+++ b/ckan/templates/user/new_user_form.html
@@ -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>
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/user/read.html
--- a/ckan/templates/user/read.html
+++ b/ckan/templates/user/read.html
@@ -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>
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/templates/user/request_reset.html
--- a/ckan/templates/user/request_reset.html
+++ b/ckan/templates/user/request_reset.html
@@ -14,7 +14,7 @@
<input type="text" 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>
diff -r a7ecdbed3bbe45e40d4c8d65a3a96d9524da948c -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 ckan/tests/lib/test_helpers.py
--- a/ckan/tests/lib/test_helpers.py
+++ b/ckan/tests/lib/test_helpers.py
@@ -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
+
+
https://bitbucket.org/okfn/ckan/changeset/e25d1d7573a3/
changeset: e25d1d7573a3
user: zephod
date: 2011-10-28 13:15:08
summary: [gravatars][s]: Gravatars appear in linked_user()
affected #: 2 files
diff -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 -r e25d1d7573a3414ea57d201f0b6fb57fd5894b22 ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -15,6 +15,7 @@
from webhelpers import paginate
from webhelpers.text import truncate
import webhelpers.date as date
+from pylons import g
from pylons.decorators.cache import beaker_cache
from routes import url_for, redirect_to
from alphabet_paginate import AlphaPage
@@ -195,7 +196,9 @@
return user_name
if user:
_name = user.name if model.User.VALID_NAME.match(user.name) else user.id
- _icon = icon("user") + " "
+ # Absolute URL of default user icon
+ _icon_url_default = g.site_url + icon_url("user")
+ _icon = gravatar(user.email_hash, 16, _icon_url_default)
displayname = user.display_name
if maxlength and len(user.display_name) > maxlength:
displayname = displayname[:maxlength] + '...'
@@ -219,13 +222,17 @@
def icon_url(name):
return '/images/icons/%s.png' % name
+def icon_html(url, alt=None):
+ return literal('<img src="%s" height="16px" width="16px" alt="%s" /> ' % (url, alt))
+
def icon(name, alt=None):
- return literal('<img src="%s" height="16px" width="16px" alt="%s" /> ' % (icon_url(name), alt))
+ return icon_html(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))
+def linked_gravatar(email_hash, size=100, default="mm"):
+ return literal('<a href="http://gravatar.com" target="_blank">%s</a>' % gravatar(email_hash,size,default))
+
+def gravatar(email_hash, size=100, default="mm"):
+ return literal('<img src="http://gravatar.com/avatar/%s?s=%d&d=%s" />' % (email_hash, size, default))
class Page(paginate.Page):
diff -r 1bdaf1b5022e0b8f9d9ddccfcde17e1736bfebb5 -r e25d1d7573a3414ea57d201f0b6fb57fd5894b22 ckan/tests/lib/test_helpers.py
--- a/ckan/tests/lib/test_helpers.py
+++ b/ckan/tests/lib/test_helpers.py
@@ -57,8 +57,6 @@
# Hash the email address
import hashlib
email_hash = hashlib.md5(email).hexdigest()
- res = h.gravatar(email_hash, 200)
+ res = h.linked_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