Commit e871ddf5 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Fix social nickname extraction

parent 54b19a1f
......@@ -10,23 +10,23 @@ link = '<a class="{network}-link" href="{url}" target="_blank">{label}</a>'
@register.filter
def twitter_link(url):
return mark_safe(link.format(network='twitter', url=url,
label=re.sub(r'.*/@?([^/]+)', '@\\1', url)))
label=re.sub(r'.*/@?([^/]+)', '@\\1', re.sub(r'/$', '', url.strip()))))
@register.filter
def facebook_link(url):
return mark_safe(link.format(network='facebook', url=url,
label=re.sub(r'.*/([^/]+)', '\\1', url)))
label=re.sub(r'.*/([^/]+)', '\\1', re.sub(r'/$', '', url.strip()))))
@register.filter
def website_link(url):
short_url = re.sub(r'^https?://([^/]+).*', '\\1', url)
return mark_safe(link.format(network='website', url=url,
label=short_url))
label=short_url))
@register.filter
def email_link(address):
return mark_safe(link.format(network='email', url='mailto:%s' % address,
label=address))
label=address))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment