54 lines
1.2 KiB
Cheetah
54 lines
1.2 KiB
Cheetah
<%doc>
|
|
Return URL from email and some social networks.
|
|
|
|
Template engine: Mako
|
|
|
|
Usage:
|
|
|
|
{{% url <site> [suffix=<suffix>] [delprt=<delprt>] %}}
|
|
|
|
where <site> is one of 'email', 'xmpp', 'mastodon' or 'peertube', corresponding to GLOBAL_CONTEXT variable of EMAIL_URL, XMPP_URL, MASTODON_URL, PEERTUBE_URL and GIT_URL respectively, and sufix variable allow to add a suffix <suffix> to the URL, and if delprt variable is True then remove protocol from URL
|
|
|
|
Example: {{% url 'mastodon' %}} will show the content of MASTODON_URL defined in GLOBAL_CONTEXT of config.py
|
|
</%doc>
|
|
|
|
<%!
|
|
def del_prt(url):
|
|
i = url.find('//') + 1
|
|
if i == 0:
|
|
i = url.find(':')
|
|
return url[i+1:]
|
|
%>
|
|
|
|
% if suffix is UNDEFINED:
|
|
<% s = '' %>
|
|
% else:
|
|
<% s = suffix %>
|
|
% endif
|
|
|
|
% if delprt is UNDEFINED:
|
|
<% d = False %>
|
|
% else:
|
|
<% d = delprt %>
|
|
% endif
|
|
|
|
% if _args[0] == 'email':
|
|
<% url = EMAIL_URL + s %>
|
|
% elif _args[0] == 'xmpp':
|
|
<% url = XMPP_URL + s %>
|
|
% elif _args[0] == 'mastodon':
|
|
<% url = MASTODON_URL + s %>
|
|
% elif _args[0] == 'peertube':
|
|
<% url = PEERTUBE_URL + s %>
|
|
% elif _args[0] == 'git':
|
|
<% url = GIT_URL + s %>
|
|
% else:
|
|
Unknown
|
|
% endif
|
|
|
|
% if d:
|
|
${url | del_prt}
|
|
% else:
|
|
${url}
|
|
% endif
|