зеркало из https://github.com/mozilla/kitsune.git
[bug 617096] Better public emails.
This commit is contained in:
Родитель
d3bcc52ef6
Коммит
5f41630cb0
|
@ -36,4 +36,9 @@ def display_name(user):
|
|||
@register.filter
|
||||
def public_email(email):
|
||||
"""Email address -> publicly displayable email."""
|
||||
return jinja2.Markup(email.replace(u'@', u' [at] '))
|
||||
return jinja2.Markup(unicode_to_html(email))
|
||||
|
||||
|
||||
def unicode_to_html(text):
|
||||
"""Turns all unicode into html entities, e.g. E -> E."""
|
||||
return ''.join([u'&#%s;' % ord(i) for i in text])
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{# vim: set ts=2 et sts=2 sw=2: #}
|
||||
{% extends "wiki/base.html" %}
|
||||
{% set styles = ('wiki', 'users') %}
|
||||
{% set scripts = ('users',) %}
|
||||
|
||||
{# NOTE/TODO: We are using wiki base.html and CSS for now (Until the refactoring moves what we need into main.css, etc.) #}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
{% if profile.public_email and profile.website or profile.twitter or profile.facebook or profile.irc_handle %}
|
||||
<ul>
|
||||
{% if profile.public_email %}
|
||||
<li>{{ profile.user.email|public_email }}</li>
|
||||
<li class="email">{{ profile.user.email|public_email }}</li>
|
||||
{% endif %}
|
||||
{% if profile.website %}
|
||||
<li><a rel="nofollow" href="{{ profile.website }}">{{ _('Website') }}</a></li>
|
||||
|
|
|
@ -28,8 +28,10 @@ class HelperTestCase(TestCase):
|
|||
eq_('%simages/foo.png' % settings.MEDIA_URL, profile_avatar(self.u))
|
||||
|
||||
def test_public_email(self):
|
||||
eq_('me [at] domain.com', public_email('me@domain.com'))
|
||||
eq_('not.an.email', public_email('not.an.email'))
|
||||
eq_(u'me@domain.c'
|
||||
'om', public_email('me@domain.com'))
|
||||
eq_(u'not.an.emai'
|
||||
'l', public_email('not.an.email'))
|
||||
|
||||
def test_display_name(self):
|
||||
eq_(u'testuser', display_name(self.u))
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* users.js
|
||||
* Make public emails clickable.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
function makeEmailsClickable() {
|
||||
// bail if no emails on page
|
||||
var $emails = $('.email');
|
||||
if ($emails.length === 0) {
|
||||
return false;
|
||||
}
|
||||
$emails.each(function () {
|
||||
var email_val = $(this).text();
|
||||
$a = $('<a/>').attr('href', 'mailto:' + email_val)
|
||||
.html($(this).html());
|
||||
$(this).html($a);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
makeEmailsClickable();
|
||||
});
|
||||
|
||||
}());
|
|
@ -395,6 +395,9 @@ MINIFY_BUNDLES = {
|
|||
'chat': (
|
||||
'js/chat.js',
|
||||
),
|
||||
'users': (
|
||||
'js/users.js',
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче