macros.html 3.6 KB

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