macros.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. {%- if result.metadata %} <div class="highlight">{{ result.metadata|safe }}</div>{% endif -%}
  22. {%- endmacro %}
  23. <!-- Draw result footer -->
  24. {% macro result_footer(result, id) -%}
  25. <div class="clearfix"></div>{{- "" -}}
  26. <div class="pull-right">
  27. {%- for engine in result.engines -%}
  28. <span class="label label-default">{{ engine }}</span>
  29. {%- endfor -%}
  30. {%- if result.url -%}
  31. {%- if result.cached_url -%}
  32. <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
  33. {%- elif not result.is_onion -%}
  34. <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
  35. {%- endif -%}
  36. {%- endif -%}
  37. {%- if proxify and proxify_results -%}
  38. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
  39. {%- endif -%}
  40. </div>
  41. {%- if result.pretty_url -%}
  42. <div class="external-link">{{ result.pretty_url }}</div>
  43. {%- endif -%}
  44. {%- endmacro %}
  45. <!-- Draw result footer without cache link -->
  46. {% macro result_footer_nocache(result) -%}
  47. <div class="clearfix"></div>{{- "" -}}
  48. <div class="pull-right">
  49. {%- for engine in result.engines -%}
  50. <span class="label label-default">{{ engine }}</span>
  51. {%- endfor -%}
  52. {%- if proxify and proxify_results -%}
  53. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
  54. {%- endif -%}
  55. </div>{{- "" -}}
  56. <div class="external-link">{{ result.pretty_url }}</div>
  57. {%- endmacro %}
  58. <!-- Draw result footer -->
  59. {% macro result_footer_rtl(result, id) -%}
  60. <div class="clearfix"></div>
  61. {%- for engine in result.engines -%}
  62. <span class="label label-default">{{ engine }}</span>
  63. {%- endfor -%}
  64. {%- if result.url -%}
  65. {%- if result.cached_url -%}
  66. <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
  67. {%- elif not result.is_onion -%}
  68. <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
  69. {%- endif -%}
  70. {%- endif -%}
  71. {%- if proxify and proxify_results -%}
  72. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
  73. {%- endif -%}
  74. {%- if result.pretty_url -%}
  75. <div class="external-link">{{ result.pretty_url }}</div>
  76. {%- endif -%}
  77. {%- endmacro %}
  78. <!-- Draw result footer without cache link -->
  79. {% macro result_footer_nocache_rtl(result) -%}
  80. <div class="clearfix"></div>
  81. {%- for engine in result.engines -%}
  82. <span class="label label-default">{{ engine }}</span>
  83. {%- endfor -%}
  84. {%- if proxify and proxify_results -%}
  85. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
  86. {%- endif -%}
  87. <div class="external-link">{{ result.pretty_url }}</div>
  88. {%- endmacro %}
  89. {% macro preferences_item_header(info, label, rtl, id) -%}
  90. {%- if rtl -%}
  91. <div class="row form-group">{{- "" -}}
  92. <label class="col-sm-3 col-md-2 pull-right"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>{{- "" -}}
  93. <span class="col-sm-5 col-md-6 help-block pull-left">{{ info }}</span>{{- "" -}}
  94. <div class="col-sm-4 col-md-4">
  95. {%- else -%}
  96. <div class="row form-group">{{- "" -}}
  97. <label class="col-sm-3 col-md-2"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>{{- "" -}}
  98. <div class="col-sm-4 col-md-4">
  99. {%- endif -%}
  100. {%- endmacro %}
  101. {% macro preferences_item_footer(info, label, rtl) -%}
  102. {%- if rtl -%}
  103. </div>{{- "" -}}
  104. </div>
  105. {%- else -%}
  106. </div>
  107. <span class="col-sm-5 col-md-6 help-block">{{ info }}</span>{{- "" -}}
  108. </div>
  109. {%- endif -%}
  110. {%- endmacro %}
  111. {% macro custom_select_class(rtl) -%}
  112. custom-select{% if rtl %}-rtl{% endif %}
  113. {%- endmacro %}
  114. {% macro checkbox_toggle(id, blocked) -%}
  115. <div class="onoffswitch">{{- "" -}}
  116. <input type="checkbox" id="{{ id }}" name="{{ id }}"{% if blocked %} checked="checked"{% endif %} class="onoffswitch-checkbox">{{- "" -}}
  117. <label class="onoffswitch-label" for="{{ id }}">{{- "" -}}
  118. <span class="onoffswitch-inner"></span>{{- "" -}}
  119. <span class="onoffswitch-switch"></span>{{- "" -}}
  120. </label>{{- "" -}}
  121. <label class="visually-hidden" for="{{ id }}">{{ _('Allow') }}</label>{{- "" -}}
  122. </div>{{- "" -}}
  123. {%- endmacro %}
  124. {% macro support_toggle(supports) -%}
  125. {%- if supports == '?' -%}
  126. <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" title="{{- _('broken') -}}"></span>{{- "" -}}
  127. {%- elif supports -%}
  128. <span class="glyphicon glyphicon-ok" aria-hidden="true" title="{{- _('supported') -}}"></span>{{- "" -}}
  129. {%- else -%}
  130. <span aria-hidden="true" title="{{- _('not supported') -}}"></span>{{- "" -}}
  131. {%- endif -%}
  132. {%- endmacro %}