macros.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!-- Draw glyphicon icon from bootstrap-theme -->
  2. {% macro icon(action) -%}
  3. <span 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 -->
  45. {% macro result_footer_rtl(result, id) -%}
  46. <div class="clearfix"></div>{{- "" -}}
  47. {% for engine in result.engines -%}
  48. <span class="label label-default">{{ engine }}</span>
  49. {%- endfor %}
  50. {%- if result.url -%}
  51. {% if result.cached_url %}
  52. <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
  53. {% elif not result.is_onion %}
  54. <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
  55. {% endif %}
  56. {%- endif -%}
  57. {% if proxify -%}
  58. <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
  59. {%- endif %}
  60. {%- if result.pretty_url -%}
  61. <div class="external-link">{{ result.pretty_url }}</div>
  62. {%- endif %}
  63. {%- endmacro %}
  64. {% macro preferences_item_header(info, label, rtl, id) -%}
  65. {% if rtl %}
  66. <div class="row form-group">
  67. <label class="col-sm-3 col-md-2 pull-right"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>
  68. <span class="col-sm-5 col-md-6 help-block pull-left">{{ info }}</span>
  69. <div class="col-sm-4 col-md-4">
  70. {% else %}
  71. <div class="row form-group">
  72. <label class="col-sm-3 col-md-2"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>
  73. <div class="col-sm-4 col-md-4">
  74. {% endif %}
  75. {%- endmacro %}
  76. {% macro preferences_item_footer(info, label, rtl) -%}
  77. {% if rtl %}
  78. </div>
  79. </div>
  80. {% else %}
  81. </div>
  82. <span class="col-sm-5 col-md-6 help-block">{{ info }}</span>
  83. </div>
  84. {% endif %}
  85. {%- endmacro %}
  86. {% macro custom_select_class(rtl) -%}
  87. custom-select{% if rtl %}-rtl{% endif %}
  88. {%- endmacro %}
  89. {% macro checkbox_toggle(id, blocked) -%}
  90. <div class="onoffswitch">
  91. <input type="checkbox" id="{{ id }}" name="{{ id }}"{% if blocked %} checked="checked"{% endif %} class="onoffswitch-checkbox">
  92. <label class="onoffswitch-label" for="{{ id }}">
  93. <span class="onoffswitch-inner"></span>
  94. <span class="onoffswitch-switch"></span>
  95. </label>
  96. <label class="visually-hidden" for="{{ id }}">{{ _('Allow') }}</label>
  97. </div>
  98. {%- endmacro %}
  99. {% macro support_toggle(supports) -%}
  100. {% if supports %}
  101. <span class="label label-success">
  102. {{ _("supported") }}
  103. </span>
  104. {% else %}
  105. <span class="label label-danger">
  106. {{ _("not supported") }}
  107. </span>
  108. {% endif %}
  109. {%- endmacro %}