Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Anthony
memopol
Commits
a79996b7
Commit
a79996b7
authored
Jun 02, 2016
by
Nicolas Joyard
Browse files
Add other websites
parent
bc773059
Changes
2
Hide whitespace changes
Inline
Side-by-side
memopol/templatetags/memopol_tags.py
View file @
a79996b7
...
...
@@ -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
))
templates/representatives/_representative_block.haml
View file @
a79996b7
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment