macros.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!-- Draw glyphicon icon from bootstrap-theme -->
  2. {% macro icon(action, alt) -%}
  3. <span title="{{ alt }}" class="glyphicon glyphicon-{{ action }}"></span>
  4. {%- endmacro %}
  5. <!-- Draw favicon -->
  6. {% macro draw_favicon(favicon) -%}
  7. <img width="32" height="32" class="favicon" src="{{ url_for('static', filename='themes/oscar/img/icons/' + favicon + '.png') }}" alt="{{ favicon }}" />
  8. {%- endmacro %}
  9. {%- macro result_link(url, title, classes='', id='') -%}
  10. <a href="{{ url }}" {% if classes %}class="{{ classes }}" {% endif %}{% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}{% if id %} aria-labelledby="result-{{id}}"{%endif%}>{{ title }}</a>
  11. {%- endmacro -%}
  12. <!-- Draw result header -->
  13. {% macro result_header(result, favicons, id) -%}
  14. <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }}{% endif %}{% if result.url %}{{ result_link(result.url, result.title|safe, id=id) }}{% else %}{{ result.title|safe}}{% endif %}</h4>
  15. {%- endmacro %}
  16. <!-- Draw result sub header -->
  17. {% macro result_sub_header(result, id) -%}
  18. {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
  19. {% if result.magnetlink %}<small> &bull; {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink", id) }}</small>{% endif %}
  20. {% if result.torrentfile %}<small> &bull; {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile", id) }}</small>{% endif %}
  21. {%- endmacro %}
  22. <!-- Draw result footer -->
  23. {% macro result_footer(result, id) -%}
  24. <div class="clearfix"></div>{{- "" -}}
  25. <div class="pull-right">
  26. {%- for engine in result.engines -%}
  27. <span class="label label-default">{{ engine }}</span>
  28. {%- endfor -%}
  29. {%- if result.url -%}
  30. {% if result.cached_url %}
  31. <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
  32. {% elif not result.is_onion %}
  33. <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
  34. {% endif %}
  35. {%- endif -%}
  36. {%- if proxify -%}
  37. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
  38. {%- endif -%}
  39. </div>
  40. {%- if result.pretty_url -%}
  41. <div class="external-link">{{ result.pretty_url }}</div>
  42. {%- endif -%}
  43. {%- endmacro %}
  44. <!-- Draw result footer without cache link -->
  45. {% macro result_footer_nocache(result) -%}
  46. <div class="clearfix"></div>
  47. <div class="pull-right">
  48. {% for engine in result.engines %}
  49. <span class="label label-default">{{ engine }}</span>
  50. {% endfor %}
  51. {% if proxify %}
  52. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
  53. {% endif %}
  54. </div>
  55. <div class="external-link">{{ result.pretty_url }}</div>
  56. {%- endmacro %}
  57. <!-- Draw result footer -->
  58. {% macro result_footer_rtl(result, id) -%}
  59. <div class="clearfix"></div>{{- "" -}}
  60. {% for engine in result.engines -%}
  61. <span class="label label-default">{{ engine }}</span>
  62. {%- endfor %}
  63. {%- if result.url -%}
  64. {% if result.cached_url %}
  65. <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
  66. {% elif not result.is_onion %}
  67. <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
  68. {% endif %}
  69. {%- endif -%}
  70. {% if proxify -%}
  71. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
  72. {%- endif %}
  73. {%- if result.pretty_url -%}
  74. <div class="external-link">{{ result.pretty_url }}</div>
  75. {%- endif %}
  76. {%- endmacro %}
  77. <!-- Draw result footer without cache link -->
  78. {% macro result_footer_nocache_rtl(result) -%}
  79. <div class="clearfix"></div>
  80. {% for engine in result.engines %}
  81. <span class="label label-default">{{ engine }}</span>
  82. {% endfor %}
  83. {% if proxify %}
  84. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
  85. {% endif %}
  86. <div class="external-link">{{ result.pretty_url }}</div>
  87. {%- endmacro %}
  88. {% macro preferences_item_header(info, label, rtl, id) -%}
  89. {% if rtl %}
  90. <div class="row form-group">
  91. <label class="col-sm-3 col-md-2 pull-right"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>
  92. <span class="col-sm-5 col-md-6 help-block pull-left">{{ info }}</span>
  93. <div class="col-sm-4 col-md-4">
  94. {% else %}
  95. <div class="row form-group">
  96. <label class="col-sm-3 col-md-2"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>
  97. <div class="col-sm-4 col-md-4">
  98. {% endif %}
  99. {%- endmacro %}
  100. {% macro preferences_item_footer(info, label, rtl) -%}
  101. {% if rtl %}
  102. </div>
  103. </div>
  104. {% else %}
  105. </div>
  106. <span class="col-sm-5 col-md-6 help-block">{{ info }}</span>
  107. </div>
  108. {% endif %}
  109. {%- endmacro %}
  110. {% macro custom_select_class(rtl) -%}
  111. custom-select{% if rtl %}-rtl{% endif %}
  112. {%- endmacro %}
  113. {% macro checkbox_toggle(id, blocked) -%}
  114. <div class="onoffswitch">
  115. <input type="checkbox" id="{{ id }}" name="{{ id }}"{% if blocked %} checked="checked"{% endif %} class="onoffswitch-checkbox">
  116. <label class="onoffswitch-label" for="{{ id }}">
  117. <span class="onoffswitch-inner"></span>
  118. <span class="onoffswitch-switch"></span>
  119. </label>
  120. <label class="visually-hidden" for="{{ id }}">{{ _('Allow') }}</label>
  121. </div>
  122. {%- endmacro %}
  123. {% macro support_toggle(supports) -%}
  124. {% if supports %}
  125. <span class="label label-success">
  126. {{ _("supported") }}
  127. </span>
  128. {% else %}
  129. <span class="label label-danger">
  130. {{ _("not supported") }}
  131. </span>
  132. {% endif %}
  133. {%- endmacro %}