Linkify location in item view
This commit is contained in:
@@ -84,6 +84,16 @@ def render_qr_code(slug):
|
|||||||
qr = segno.make(str("http://k6.ee/" + slug), micro=False, mode='byte', mask=3, error='L', boost_error=False)
|
qr = segno.make(str("http://k6.ee/" + slug), micro=False, mode='byte', mask=3, error='L', boost_error=False)
|
||||||
return Markup(qr.svg_inline(light='black', dark='yellow', scale=3, border=1))
|
return Markup(qr.svg_inline(light='black', dark='yellow', scale=3, border=1))
|
||||||
|
|
||||||
|
def render_location_link(location: str):
|
||||||
|
if location == "":
|
||||||
|
return
|
||||||
|
|
||||||
|
linkstart = location.find("k6.ee/")
|
||||||
|
if linkstart == -1:
|
||||||
|
return
|
||||||
|
|
||||||
|
return location[linkstart:].split(" ", 1)[0]
|
||||||
|
|
||||||
jinja2.filters.FILTERS['format_name'] = format_name
|
jinja2.filters.FILTERS['format_name'] = format_name
|
||||||
jinja2.filters.FILTERS['markdown'] = render_markdown
|
jinja2.filters.FILTERS['markdown'] = render_markdown
|
||||||
jinja2.filters.FILTERS['timeago'] = render_timeago
|
jinja2.filters.FILTERS['timeago'] = render_timeago
|
||||||
@@ -95,6 +105,7 @@ jinja2.filters.FILTERS['quote_plus'] = lambda u: urllib.parse.quote_plus(u)
|
|||||||
jinja2.filters.FILTERS['check_foreign_key_format'] = check_foreign_key_format
|
jinja2.filters.FILTERS['check_foreign_key_format'] = check_foreign_key_format
|
||||||
jinja2.filters.FILTERS['display_name'] = render_user_display_name
|
jinja2.filters.FILTERS['display_name'] = render_user_display_name
|
||||||
jinja2.filters.FILTERS['qr_code'] = render_qr_code
|
jinja2.filters.FILTERS['qr_code'] = render_qr_code
|
||||||
|
jinja2.filters.FILTERS['location_link'] = render_location_link
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'))
|
env = Environment(loader=FileSystemLoader('templates/'))
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Location</td>
|
<td>Location</td>
|
||||||
<td>{{ item.location }}</td>
|
<td>{% if item.location and (item.location | location_link) %}<a href="https://{{ item.location | location_link }}">🡼</a>{% else %}🮰{% endif %} {{ item.location }}</td>
|
||||||
|
|
||||||
<td>Last audited</td>
|
<td>Last audited</td>
|
||||||
<td><div>
|
<td><div>
|
||||||
|
Reference in New Issue
Block a user