macros.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. {%- for part in get_pretty_url(result.parsed_url) -%}
  20. <span class="url_o{{loop.index}}"><span class="url_i{{loop.index}}">{{- part -}}</span></span>
  21. {%- endfor %}
  22. {{- result_close_link() -}}
  23. {%- if result.img_src %}{{ result_open_link(result.url) }}<img class="image" src="{{ image_proxify(result.img_src) }}" title="{{ result.title|striptags }}" loading="lazy" width="200" height="200">{{ result_close_link() }}{% endif -%}
  24. {%- if result.thumbnail %}{{ result_open_link(result.url) }}<img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" loading="lazy" width="200" height="200">{{ result_close_link() }}{% endif -%}
  25. <h3>{{ result_link(result.url, result.title|safe) }}</h3>
  26. {%- endmacro -%}
  27. <!-- Draw result sub header -->
  28. {%- macro result_sub_header(result) -%}
  29. {%- if result.publishedDate %}<time class="published_date" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif -%}
  30. {%- if result.length %}<div class="result_length">{{ _('Length') }}: {{ result.length }}</div>{% endif -%}
  31. {%- if result.author %}<div class="result_author">{{ _('Author') }}: {{ result.author }}</div>{% endif -%}
  32. {%- if result.metadata %}<div class="highlight">{{ result.metadata|safe }}</div>{% endif -%}
  33. {%- endmacro -%}
  34. <!-- Draw result sub footer -->
  35. {%- macro result_sub_footer(result, proxify) -%}
  36. <div class="engines">
  37. {% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}
  38. {{ result_link(cache_url + result.url, icon_small('ellipsis-vertical-outline') + _('cached'), "cache_link") }}&lrm; {% if proxify and proxify_results %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}
  39. </div>{{- '' -}}
  40. <div class="break"></div>{{- '' -}}
  41. {%- endmacro -%}
  42. <!-- Draw result footer -->
  43. {%- macro result_footer(result) -%}
  44. </article>
  45. {%- endmacro -%}
  46. <!-- input checkbox, on/off slider user can tap-->
  47. {%- macro checkbox_onoff(name, checked) -%}
  48. <input type="checkbox" {{- ' ' -}}
  49. name="{{ name }}" {{- ' ' -}}
  50. id="{{ name }}" {{- ' ' -}}
  51. aria-labelledby="pref_{{ name }}"{{- ' ' -}}
  52. class="checkbox-onoff"{{- ' ' -}}
  53. {%- if checked -%} checked{%- endif -%}/>
  54. {%- endmacro -%}