macros.html 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!-- Draw favicon -->
  2. {% macro draw_favicon(favicon) -%}
  3. <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='themes/simple/img/icons/' + favicon + '.png') }}" alt="{{ favicon }}" />
  4. {%- endmacro %}
  5. {% macro result_open_link(url, classes='') -%}
  6. <a href="{{ url }}" {% if classes %}class="{{ classes }}" {% endif %}{% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>
  7. {%- endmacro %}
  8. {%- macro result_close_link() -%}
  9. </a>
  10. {%- endmacro %}
  11. {%- macro result_link(url, title, classes='') -%}
  12. {{ result_open_link(url, classes) }}{{ title }}{{ result_close_link() }}
  13. {%- endmacro -%}
  14. <!-- Draw result header -->
  15. {% macro result_header(result, favicons, image_proxify) -%}
  16. <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 %}">
  17. {{- result_open_link(result.url, "url_wrapper") -}}
  18. {%- for part in get_pretty_url(result.parsed_url) -%}
  19. <span class="url_o{{loop.index}}"><span class="url_i{{loop.index}}">{{- part -}}</span></span>
  20. {%- endfor %}
  21. {{- result_close_link() -}}
  22. {%- if result.img_src %}{{ result_open_link(result.url) }}<img class="image" src="{{ image_proxify(result.img_src) }}" alt="{{ result.title|striptags }}" title="{{ result.title|striptags }}" class="image" />{{ result_close_link() }}{% endif -%}
  23. {%- if result.thumbnail %}{{ result_open_link(result.url) }}<img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/>{{ result_close_link() }}{% endif -%}
  24. <h3>{{ result_link(result.url, result.title|safe) }}</h3>
  25. {%- endmacro -%}
  26. <!-- Draw result sub header -->
  27. {%- macro result_sub_header(result) -%}
  28. {% if result.publishedDate %}<time class="published_date" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
  29. {%- if result.metadata %} <div class="highlight">{{ result.metadata|safe }}</div>{% endif -%}
  30. {%- endmacro -%}
  31. <!-- Draw result sub footer -->
  32. {%- macro result_sub_footer(result, proxify) -%}
  33. <div class="engines">
  34. {% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}
  35. {{ result_link("https://web.archive.org/web/" + 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 %}
  36. </div>{{- '' -}}
  37. <div class="break"></div>{{- '' -}}
  38. {%- endmacro -%}
  39. <!-- Draw result footer -->
  40. {%- macro result_footer(result) -%}
  41. </article>
  42. {%- endmacro -%}
  43. <!-- -->
  44. {%- macro tabs_open() -%}
  45. <div class="tabs" role="tablist">
  46. {%- endmacro -%}
  47. {%- macro tab_header(name, id, label) -%}
  48. <input type="radio" name="{{ name }}" id="tab_{{ id }}"/>
  49. <label for="tab_{{ id }}" role="tab"
  50. aria-controls="panel{{ id }}">{{ label }}</label>
  51. <section id="tab-content{{ id }}" role="tabpanel"
  52. aria-labelledby="{{ label }}" aria-hidden="false">
  53. {%- endmacro -%}
  54. {%- macro tab_footer() -%}
  55. </section>
  56. {%- endmacro -%}
  57. {%- macro tabs_close() -%}
  58. </div>
  59. {%- endmacro -%}
  60. {%- macro checkbox_onoff(name, checked) -%}
  61. <div class="checkbox-onoff">{{- '' -}}
  62. <input type="checkbox" value="None" id="{{ name }}" name="{{ name }}" {% if checked %}checked{% endif %}/>{{- '' -}}
  63. <label for="{{ name }}"></label>{{- '' -}}
  64. </div>
  65. {%- endmacro -%}
  66. {%- macro checkbox(name, checked, readonly, disabled) -%}
  67. <div class="checkbox">{{- '' -}}
  68. {%- if checked == '?' -%}
  69. {{ icon_small('warning') }}
  70. {%- else -%}
  71. <input type="checkbox" value="None" id="{{ name }}" name="{{ name }}" {% if checked %}checked{% endif %}{% if readonly %} readonly="readonly" {% endif %}{% if disabled %} disabled="disabled" {% endif %}/>{{- '' -}}
  72. <label for="{{ name }}"></label>{{- '' -}}
  73. {%- endif -%}
  74. </div>
  75. {%- endmacro -%}