{% from 'simple/icons.html' import icon_small %} {% macro draw_favicon(favicon) -%} {{ favicon }} {%- endmacro %} {% macro result_open_link(url, classes='') -%} {%- endmacro %} {%- macro result_close_link() -%} {%- endmacro %} {%- macro result_link(url, title, classes='') -%} {{ result_open_link(url, classes) }}{{ title }}{{ result_close_link() }} {%- endmacro -%} {% macro result_badges(result) -%} {%- set _netloc = (result.parsed_url.netloc if result.parsed_url else '') | lower -%} {%- set _path = (result.parsed_url.path if result.parsed_url else '') | lower -%} {%- if 'github.com' in _netloc -%}GitHub{% endif -%} {%- if 'youtube.com' in _netloc or 'youtu.be' in _netloc or result.category == 'videos' -%}Video{% endif -%} {%- if result.category == 'news' -%}News{% endif -%} {%- if result.category == 'science' or 'arxiv.org' in _netloc or 'pubmed' in _netloc or 'acm.org' in _netloc -%}Research{% endif -%} {%- if result.url and result.url.lower().endswith('.pdf') -%}PDF{% endif -%} {%- if _netloc.startswith('blog.') or 'medium.com' in _netloc or 'substack.com' in _netloc or 'wordpress.com' in _netloc -%}Blog{% endif -%} {%- if _netloc.startswith('docs.') or _netloc.startswith('developer.') or 'readthedocs' in _netloc or '/docs' in _path or '/documentation' in _path -%}Documentation{% endif -%} {%- endmacro -%} {% macro result_source_line(result) -%}
{%- if favicon_resolver != "" and result.parsed_url and result.parsed_url.netloc %} {%- endif %} {{ result.parsed_url.netloc | replace('www.', '', 1) if result.parsed_url and result.parsed_url.netloc else '' }} {{- result_badges(result) -}} {%- if result.publishedDate and result.publishedDate.strftime %} {%- endif %} {%- if result.author %}By {{ result.author }}{% endif -%}
{%- endmacro -%} {% macro result_header(result, favicons, image_proxify) -%}
{{- result_source_line(result) -}} {%- if result.thumbnail %}{{ result_open_link(result.url, classes='thumbnail_link') }}{%- if result.length -%}{{ result.length }}{%- endif -%}{{ result_close_link() }}{% endif -%}

{{ result_link(result.url, result.title|safe) }}

{%- endmacro -%} {%- macro result_sub_header(result) -%} {%- if result.length and not result.thumbnail %}
{{ _('Length') }}: {{ result.length }}
{% endif -%} {%- if result.views %}
{{ _('Views') }}: {{ result.views }}
{% endif -%} {%- if result.metadata %}
{{ result.metadata }}
{% endif -%} {%- endmacro -%} {%- macro result_sub_footer(result) -%}
{%- if result.url %}{{ result.url }}{% endif -%} {%- if result.content %} {%- set _words = result.content | striptags | wordcount -%} {%- if _words >= 40 -%} {%- set _mins = ((_words / 238) | round(0, 'common') | int) -%} {%- if _mins < 1 -%}< 1 min read{%- else -%}{{ _mins }} min read{%- endif -%} {%- endif -%} {%- endif -%}
{% for engine in result.engines %}{{ engine }}{% endfor %} {{ icon_small('ellipsis-vertical') + result_link(cache_url + result.url, _('cached'), "cache_link") }}
{{- '' -}}
{{- '' -}} {%- endmacro -%} {%- macro result_footer(result) -%}
{%- endmacro -%} {%- macro checkbox_onoff(name, checked) -%} {%- endmacro -%} {%- macro iframe(iframe_src) -%} {%- endmacro -%}