macros.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {% from 'simple/icons.html' import icon_small %}
  2. <!-- Draw favicon -->
  3. {% macro draw_favicon(favicon) -%}
  4. <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='themes/simple/img/icons/' + favicon + '.png') }}" alt="{{ favicon }}">
  5. {%- endmacro %}
  6. {% macro result_open_link(url, classes='') -%}
  7. <a href="{{ url }}" {% if classes %}class="{{ classes }}" {% endif %}{% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>
  8. {%- endmacro %}
  9. {%- macro result_close_link() -%}
  10. </a>
  11. {%- endmacro %}
  12. {%- macro result_link(url, title, classes='') -%}
  13. {{ result_open_link(url, classes) }}{{ title }}{{ result_close_link() }}
  14. {%- endmacro -%}
  15. <!-- Draw result header -->
  16. {% macro result_header(result, favicons, image_proxify) -%}
  17. <article class="result {% if result['template'] %}result-{{ result.template|replace('.html', '') }}{% else %}result-default{% endif %} {% if result['category'] %}category-{{ result['category'] }}{% endif %}">
  18. {{- result_open_link(result.url, "url_header") -}}
  19. {%- if favicon_resolver != "" %}
  20. <div class="favicon"><img loading="lazy" src="{{ favicon_url(result.parsed_url.netloc) }}"></div>
  21. {%- endif -%}
  22. <div class="url_wrapper">
  23. {%- for part in get_pretty_url(result.parsed_url) -%}
  24. <span class="url_o{{loop.index}}"><span class="url_i{{loop.index}}">{{- part -}}</span></span>
  25. {%- endfor %}
  26. </div>
  27. {{- result_close_link() -}}
  28. {%- if result.thumbnail %}{{ result_open_link(result.url) }}<img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" loading="lazy">{{ result_close_link() }}{% endif -%}
  29. <h3>{{ result_link(result.url, result.title|safe) }}</h3>
  30. {%- endmacro -%}
  31. <!-- Draw result sub header -->
  32. {%- macro result_sub_header(result) -%}
  33. {%- if result.publishedDate %}<time class="published_date" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif -%}
  34. {%- if result.length %}<div class="result_length">{{ _('Length') }}: {{ result.length }}</div>{% endif -%}
  35. {%- if result.views %}<div class="result_views">{{ _('Views') }}: {{ result.views }}</div>{% endif -%}
  36. {%- if result.author %}<div class="result_author">{{ _('Author') }}: {{ result.author }}</div>{% endif -%}
  37. {%- if result.metadata %}<div class="highlight">{{ result.metadata|safe }}</div>{% endif -%}
  38. {%- endmacro -%}
  39. <!-- Draw result sub footer -->
  40. {%- macro result_sub_footer(result, proxify) -%}
  41. <div class="engines">
  42. {% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}
  43. {{ icon_small('ellipsis-vertical-outline') + result_link(cache_url + result.url, _('cached'), "cache_link") }}&lrm; {% if proxify and proxify_results %} {{ result_link(proxify(result.url), _('proxied'), "proxyfied_link") }} {% endif %}
  44. </div>{{- '' -}}
  45. <div class="break"></div>{{- '' -}}
  46. {%- endmacro -%}
  47. <!-- Draw result footer -->
  48. {%- macro result_footer(result) -%}
  49. </article>
  50. {%- endmacro -%}
  51. <!-- input checkbox, on/off slider user can tap-->
  52. {%- macro checkbox_onoff(name, checked) -%}
  53. <input type="checkbox" {{- ' ' -}}
  54. name="{{ name }}" {{- ' ' -}}
  55. id="{{ name }}" {{- ' ' -}}
  56. aria-labelledby="pref_{{ name }}"{{- ' ' -}}
  57. class="checkbox-onoff"{{- ' ' -}}
  58. {%- if checked -%} checked{%- endif -%}/>
  59. {%- endmacro -%}