macros.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!-- Draw glyphicon icon from bootstrap-theme -->
  2. {% macro icon(action) -%}
  3. <span class="ion-icon-big ion-{{ action }}"></span>
  4. {%- endmacro %}
  5. {% macro icon_small(action) -%}
  6. <span class="ion-icon ion-{{ action }}"></span>
  7. {%- endmacro %}
  8. <!-- Draw favicon -->
  9. <!-- TODO: using url_for methode -->
  10. {% macro draw_favicon(favicon) -%}
  11. <img width="14" height="14" class="favicon" src="static/themes/simple/img/icons/{{ favicon }}.png" alt="{{ favicon }}" />
  12. {%- endmacro %}
  13. {% macro result_open_link(url, classes='') -%}
  14. <a href="{{ url }}" {% if classes %}class="{{ classes }}" {% endif %}{% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>
  15. {%- endmacro %}
  16. {%- macro result_close_link() -%}
  17. </a>
  18. {%- endmacro %}
  19. {%- macro result_link(url, title, classes='') -%}
  20. {{ result_open_link(url, classes) }}{{ title }}{{ result_close_link() }}
  21. {%- endmacro -%}
  22. <!-- Draw result header -->
  23. {% macro result_header(result, favicons, image_proxify) -%}
  24. <article class="result {% if result['template'] %}result-{{ result.template|replace('.html', '') }}{% else %}result-default{% endif %} {% if result['category'] %}category-{{ result['category'] }}{% endif %}">
  25. {%- 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 -%}
  26. {%- 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 -%}
  27. <h3>{{ result_link(result.url, result.title|safe) }}</h3>
  28. {%- endmacro -%}
  29. <!-- Draw result sub header -->
  30. {%- macro result_sub_header(result) -%}
  31. {% if result.publishedDate %}<time class="published_date" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
  32. {%- endmacro -%}
  33. <!-- Draw result sub footer -->
  34. {%- macro result_sub_footer(result, proxify) -%}
  35. <div class="engines">{% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}</div>{{- '' -}}
  36. <p class="url"><span class="url">{{ result.pretty_url }}</span>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "cache_link") }}&lrm; {% if proxify %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}</p>{{- '' -}}
  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. <input type="checkbox" value="None" id="{{ name }}" name="{{ name }}" {% if checked %}checked{% endif %}{% if readonly %} readonly="readonly" {% endif %}{% if disabled %} disabled="disabled" {% endif %}/>{{- '' -}}
  69. <label for="{{ name }}"></label>{{- '' -}}
  70. </div>
  71. {%- endmacro -%}