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

Add other websites

parent bc773059
......@@ -4,17 +4,23 @@ from django.utils.safestring import mark_safe
import re
register = template.Library()
link = '<a class="{network}-link" href="{url}" target="_blank">{user}</a>'
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,
user=re.sub(r'.*/@?([^/]+)', '@\\1', url)))
label=re.sub(r'.*/@?([^/]+)', '@\\1', url)))
@register.filter
def facebook_link(url):
return mark_safe(link.format(network='facebook', url=url,
user=re.sub(r'.*/([^/]+)', '\\1', url)))
label=re.sub(r'.*/([^/]+)', '\\1', url)))
@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))
......@@ -51,3 +51,9 @@
- elif site.kind == 'facebook'
= site.url|facebook_link
- if representative.other_websites|length > 0
%tr
%th Websites
%td
- for site in representative.other_websites
= site.url|website_link
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