macros.html 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 %}{% for e in result.engines %} {{ e }}{% endfor %}">
  18. {{- result_open_link(result.url, "url_wrapper") -}}
  19. {% if not rtl %}
  20. {%- if favicon_resolver != "" %}
  21. <div class="favicon"><img loading="lazy" src="{{ favicon_url(result.parsed_url.netloc) }}"></div>
  22. {%- endif -%}
  23. {%- endif -%}
  24. {%- for part in get_pretty_url(result.parsed_url) -%}
  25. <span class="url_o{{loop.index}}"><span class="url_i{{loop.index}}">{{- part -}}</span></span>
  26. {%- endfor %}
  27. {% if rtl %}
  28. {%- if favicon_resolver != "" %}
  29. <div class="favicon"><img loading="lazy" src="{{ favicon_url(result.parsed_url.netloc) }}"></div>
  30. {%- endif -%}
  31. {%- endif -%}
  32. {{- result_close_link() -}}
  33. {%- 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 -%}
  34. <h3>{{ result_link(result.url, result.title|safe) }}</h3>
  35. {%- endmacro -%}
  36. <!-- Draw result sub header -->
  37. {%- macro result_sub_header(result) -%}
  38. {%- if result.publishedDate %}<time class="published_date" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif -%}
  39. {%- if result.length %}<div class="result_length">{{ _('Length') }}: {{ result.length }}</div>{% endif -%}
  40. {%- if result.views %}<div class="result_views">{{ _('Views') }}: {{ result.views }}</div>{% endif -%}
  41. {%- if result.author %}<div class="result_author">{{ _('Author') }}: {{ result.author }}</div>{% endif -%}
  42. {%- if result.metadata %}<div class="highlight">{{ result.metadata|safe }}</div>{% endif -%}
  43. {%- endmacro -%}
  44. <!-- Draw result sub footer -->
  45. {%- macro result_sub_footer(result, proxify) -%}
  46. <div class="engines">
  47. {% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}
  48. {{ 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 %}
  49. </div>{{- '' -}}
  50. <div class="break"></div>{{- '' -}}
  51. {%- endmacro -%}
  52. <!-- Draw result footer -->
  53. {%- macro result_footer(result) -%}
  54. </article>
  55. {%- endmacro -%}
  56. <!-- input checkbox, on/off slider user can tap-->
  57. {%- macro checkbox_onoff(name, checked) -%}
  58. <input type="checkbox" {{- ' ' -}}
  59. name="{{ name }}" {{- ' ' -}}
  60. id="{{ name }}" {{- ' ' -}}
  61. aria-labelledby="pref_{{ name }}"{{- ' ' -}}
  62. class="checkbox-onoff"{{- ' ' -}}
  63. {%- if checked -%} checked{%- endif -%}/>
  64. {%- endmacro -%}