macros.html 4.6 KB

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