summaryrefslogtreecommitdiff
path: root/searx/templates/oscar/macros.html
blob: 2b27cfd283ef30db042a4d312bd01736ea265e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!-- Draw glyphicon icon from bootstrap-theme -->
{% macro icon(action, alt) -%}
    <span title="{{ alt }}" class="glyphicon glyphicon-{{ action }}"></span>
{%- endmacro %}

<!-- Draw favicon -->
{% macro draw_favicon(favicon) -%}
    <img width="32" height="32" class="favicon" src="{{ url_for('static', filename='themes/oscar/img/icons/' + favicon + '.png') }}" alt="{{ favicon }}" />
{%- endmacro %}

{%- macro result_link(url, title, classes='', id='') -%}
<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>
{%- endmacro -%}

<!-- Draw result header -->
{% macro result_header(result, favicons, id) -%}
<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>
{%- endmacro %}

<!-- Draw result sub header -->
{% macro result_sub_header(result, id) -%}
    {%- if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif -%}
    {%- if result.magnetlink %}<small> &bull; {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink", id) }}</small>{% endif -%}
    {%- if result.torrentfile %}<small> &bull; {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile", id) }}</small>{% endif -%}
    {%- if result.metadata %} <div class="highlight">{{ result.metadata|safe }}</div>{% endif -%}
{%- endmacro %}

<!-- Draw result footer -->
{% macro result_footer(result, id) -%}
    <div class="clearfix"></div>{{- "" -}}
    <div class="pull-right">
        {%- for engine in result.engines -%}
            <span class="label label-default">{{ engine }}</span>
        {%- endfor -%}
        {%- if result.url -%}
            {%- if result.cached_url -%}
            <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
            {%- elif not result.is_onion -%}
            <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
            {%- endif -%}
        {%- endif -%}
        {%- if proxify and proxify_results -%}
        <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
        {%- endif -%}
    </div>
    {%- if result.pretty_url -%}
    <div class="external-link">{{ result.pretty_url }}</div>
    {%- endif -%}
{%- endmacro %}

<!-- Draw result footer without cache link -->
{% macro result_footer_nocache(result) -%}
    <div class="clearfix"></div>{{- ""  -}}
    <div class="pull-right">
    {%- for engine in result.engines -%}
        <span class="label label-default">{{ engine }}</span>
    {%- endfor -%}
    {%- if proxify and proxify_results -%}
    <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
    {%- endif -%}
</div>{{- "" -}}
<div class="external-link">{{ result.pretty_url }}</div>
{%- endmacro %}

<!-- Draw result footer -->
{% macro result_footer_rtl(result, id) -%}
    <div class="clearfix"></div>
    {%- for engine in result.engines -%}
        <span class="label label-default">{{ engine }}</span>
    {%- endfor -%}
    {%- if result.url -%}
        {%- if result.cached_url -%}
        <small>{{ result_link(result.cached_url, icon('link') + _('cached'), "text-info", id) }}</small>
        {%- elif not result.is_onion -%}
        <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
        {%- endif -%}
    {%- endif -%}
    {%- if proxify and proxify_results -%}
    <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
    {%- endif -%}
    {%- if result.pretty_url -%}
    <div class="external-link">{{ result.pretty_url }}</div>
    {%- endif -%}
{%- endmacro %}

<!-- Draw result footer without cache link -->
{% macro result_footer_nocache_rtl(result) -%}
    <div class="clearfix"></div>
    {%- for engine in result.engines -%}
        <span class="label label-default">{{ engine }}</span>
    {%- endfor -%}
    {%- if proxify and proxify_results -%}
    <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
    {%- endif -%}
    <div class="external-link">{{ result.pretty_url }}</div>
{%- endmacro %}

{% macro preferences_item_header(info, label, rtl, id) -%}
    {%- if rtl -%}
    <div class="row form-group">{{- "" -}}
        <label class="col-sm-3 col-md-2 pull-right"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>{{- "" -}}
        <span class="col-sm-5 col-md-6 help-block pull-left">{{ info }}</span>{{- "" -}}
        <div class="col-sm-4 col-md-4">
    {%- else -%}
    <div class="row form-group">{{- "" -}}
        <label class="col-sm-3 col-md-2"{% if id %} for="{{id}}"{% endif %}>{{ label }}</label>{{- "" -}}
        <div class="col-sm-4 col-md-4">
    {%- endif -%}
{%- endmacro %}

{% macro preferences_item_footer(info, label, rtl) -%}
    {%- if rtl -%}
        </div>{{- "" -}}
    </div>
    {%- else -%}
        </div>
        <span class="col-sm-5 col-md-6 help-block">{{ info }}</span>{{- "" -}}
    </div>
    {%- endif -%}
{%- endmacro %}

{% macro custom_select_class(rtl) -%}
custom-select{% if rtl %}-rtl{% endif %}
{%- endmacro %}

{% macro checkbox_toggle(id, blocked) -%}
    <div class="onoffswitch">{{- "" -}}
        <input type="checkbox" id="{{ id }}" name="{{ id }}"{% if blocked %} checked="checked"{% endif %} class="onoffswitch-checkbox">{{- "" -}}
        <label class="onoffswitch-label" for="{{ id }}">{{- "" -}}
            <span class="onoffswitch-inner"></span>{{- "" -}}
            <span class="onoffswitch-switch"></span>{{- "" -}}
        </label>{{- "" -}}
        <label class="visually-hidden" for="{{ id }}">{{ _('Allow') }}</label>{{- "" -}}
    </div>{{- "" -}}
{%- endmacro %}

{% macro support_toggle(supports) -%}
    {%- if supports == '?' -%}
    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" title="{{- _('broken') -}}"></span>{{- "" -}}
    {%- elif supports -%}
    <span class="glyphicon glyphicon-ok" aria-hidden="true" title="{{- _('supported') -}}"></span>{{- "" -}}
    {%- else -%}
    <span aria-hidden="true" title="{{- _('not supported') -}}"></span>{{- "" -}}
    {%- endif -%}
{%- endmacro %}