macros.html 6.5 KB

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