aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui/templates/index.html.jinja
blob: fe9c5d550e84683bcd533c27ba8f4dd6766d3801 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
{#
SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0

Proxy web UI home page.

This file is part of Hydrilla&Haketilo.

Copyright (C) 2022 Wojtek Kosior

Dual licensed under
* GNU General Public License v3.0 or later and
* Creative Commons Attribution Share Alike 4.0 International.

You can choose to use either of these licenses or both.


I, Wojtek Kosior, thereby promise not to sue for violation of this
file's licenses. Although I request that you do not make use of this
code in a proprietary work, I am not going to enforce this in court.
#}
{% extends "hkt_mitm_it_base.html.jinja" %}

{% block title %} {{ _('web_ui.home.title') }} {% endblock %}

{% block style %}
  {{ super() }}

  {% include 'include/checkbox_tricks_style.css.jinja' %}
{% endblock %}

{% import 'import/checkbox_tricks.html.jinja' as tricks %}

{% block main %}
  <h3>
    {{ _('web_ui.home.heading.welcome_to_haketilo') }}
  </h3>

  <p>
    {{ _('web_ui.home.this_is_haketilo_page') }}
  </p>

  <div class="horizontal-separator"></div>

  <h4>
    {{ _('web_ui.home.heading.about_haketilo') }}
  </h4>

  <p class="has-colored-links">
    {{ _('web_ui.home.html.haketilo_is_blah_blah')|safe }}
  </p>

  <p class="has-colored-links">
    {% set fmt = _('web_ui.home.html.see_haketilo_doc_{url}') %}
    {% set doc_url = url_for('home.home_doc', page='doc_index') %}
    {{ fmt.format(url=doc_url|e)|safe }}
  </p>

  <div class="horizontal-separator"></div>

  {% if request.url.startswith('http://') %}
    <h4>
      {{ _('web_ui.home.heading.configuring_browser_for_haketilo') }}
    </h4>

    <p class="has-colored-links">
      {{ _('web_ui.home.html.to_add_certs_do_xyz')|safe }}
    </p>

    <div class="horizontal-separator"></div>
  {% endif %}

  <h4>
    {{ _('web_ui.home.heading.options') }}
  </h4>

  {{ label(_('web_ui.home.choose_language_label')) }}

  {% call unordered_list() %}
    {%
      for lang_name, lang_code in [
          ('english', 'en_US'),
          ('polski', 'pl_PL')
      ]
    %}
      {% call list_entry() %}
        <form method="POST" class="inline">
          <input type="hidden" name="action" value="set_lang">
          <input type="hidden" name="locale" value="{{ lang_code }}">
          <button>{{ lang_name }}</button>
        </form>
      {% endcall %}
    {% endfor %}
  {% endcall %}

  {% call label(_('web_ui.home.mapping_usage_mode_label')) %}
    {{ hkt_doc_link('packages') }}
  {% endcall %}

  {% set use_enabled_but_classes  = ['green-button'] %}
  {% set use_auto_but_classes     = ['green-button'] %}
  {% set use_question_but_classes = ['green-button'] %}

  <p>
    {% if settings.mapping_use_mode == MappingUseMode.WHEN_ENABLED %}
      {% do use_enabled_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.packages_are_used_when_enabled') }}
    {% elif settings.mapping_use_mode == MappingUseMode.QUESTION %}
      {% do use_question_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.user_gets_asked_whether_to_enable_package') }}
    {% else %}
      {# settings.mapping_use_mode == MappingUseMode.AUTO #}
      {% do use_auto_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.packages_are_used_automatically') }}
    {% endif %}
  </p>

  {{
    button_row([
        (use_enabled_but_classes,
         _('web_ui.home.use_enabled_button'),
         {'action': 'use_enabled'}),
        (use_question_but_classes,
         _('web_ui.home.use_question_button'),
         {'action': 'use_question'}),
        (use_auto_but_classes,
         _('web_ui.home.use_auto_button'),
         {'action': 'use_auto'})
    ])
  }}

  <div class="horizontal-separator"></div>

  {% call label(_('web_ui.home.script_blocking_mode_label')) %}
    {{ hkt_doc_link('script_blocking') }}
  {% endcall %}

  {% set allow_but_classes = ['red-button'] %}
  {% set block_but_classes = ['blue-button'] %}

  <p>
    {% if settings.default_allow_scripts %}
      {% do allow_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.scripts_are_allowed_by_default') }}
    {% else %}
      {% do block_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.scripts_are_blocked_by_default') }}
    {% endif %}
  </p>

  {% set allow_but_text = _('web_ui.home.allow_scripts_button') %}
  {% set block_but_text = _('web_ui.home.block_scripts_button') %}

  {{
    button_row([
        (allow_but_classes, allow_but_text, {'action': 'allow_scripts'}),
        (block_but_classes, block_but_text, {'action': 'block_scripts'})
    ])
  }}

  <div class="horizontal-separator"></div>

  {% call label(_('web_ui.home.advanced_features_label')) %}
    {{ hkt_doc_link('advanced_ui_features') }}
  {% endcall %}

  {% set advanced_user_but_classes = ['red-button'] %}
  {% set simple_user_but_classes   = ['blue-button'] %}

  <p>
    {% if settings.advanced_user %}
      {% do advanced_user_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.user_is_advanced_user') }}
    {% else %}
      {% do simple_user_but_classes.append('disabled-button') %}
      {{ _('web_ui.home.user_is_simple_user') }}
    {% endif %}
  </p>

  {{
    button_row([
        (advanced_user_but_classes,
         _('web_ui.home.user_make_advanced_button'),
         {'action': 'user_make_advanced'}),
        (simple_user_but_classes,
         _('web_ui.home.user_make_simple_button'),
         {'action': 'user_make_simple'})
    ])
  }}

  {% if orphan_item_stats.mappings > 0 or orphan_item_stats.resources > 0 %}
    <div class="horizontal-separator"></div>

    {{ label(_('web_ui.home.orphans_label')) }}

    <p>
      {% if settings.advanced_user %}
        {% if orphan_item_stats.mappings > 0 %}
          {{
            _('web_ui.home.orphans_to_delete_{mappings}')
                .format(mappings = orphan_item_stats.mappings)
          }}
        {% else %}
          {{ _('web_ui.home.orphans_to_delete_exist') }}
        {% endif %}
      {% else %}
        {{
          _('web_ui.home.orphans_to_delete_{mappings}_{resources}')
              .format(
                  mappings  = orphan_item_stats.mappings,
                  resources = orphan_item_stats.resources
              )
        }}
      {% endif %}
    </p>

    {% set prune_but_text =  _('web_ui.home.prune_orphans_button') %}

    {{
      button_row([
          (['green-button'], prune_but_text, {'action': 'prune_orphans'})
      ])
    }}
  {% endif %}

  <div class="horizontal-separator"></div>

  {% call label(_('web_ui.home.popup_settings_label')) %}
    {{ hkt_doc_link('popup') }}
  {% endcall %}

  {%
    macro render_popup_settings(
        page_type,
        initial_show                  = false,
        popup_change_but_base_classes = ['red-button', 'blue-button']
    )
  %}
    {% set radio_id = 'popup_settings_radio_' ~ page_type %}
    {{ tricks.sibling_hider_radio('popup_settings', radio_id, initial_show) }}

    <div>
      <p>
        {{ _('web_ui.home.configure_popup_settings_on_pages_with') }}
      </p>

      <div class="flex-row">
        {%
          for but_page_type, but_text in [
              ('jsallowed', _('web_ui.home.popup_settings_jsallowed_button')),
              ('jsblocked', _('web_ui.home.popup_settings_jsblocked_button')),
              ('payloadon', _('web_ui.home.popup_settings_payloadon_button'))
          ]
        %}
          {% set attrs, classes = {}, ['green-button'] %}

          {% if but_page_type == page_type %}
            {% do classes.append('disabled-button') %}
          {% else %}
            {% set but_radio_id = 'popup_settings_radio_' ~ but_page_type %}
            {% do attrs.update({'for': but_radio_id}) %}
          {% endif %}

          {% if not loop.first %}
            {% do classes.append('button-bordering-left') %}
          {% endif %}
          {% if not loop.last %}
            {% do classes.append('button-bordering-right') %}
          {% endif %}

          {% do attrs.update({'class': classes|join(' ')}) %}

          <label {{ attrs|xmlattr }}>
            {{ but_text }}
          </label>

          {% if not loop.last %}
            <div class="button-row-separator"></div>
          {% endif %}
        {% endfor %}
      </div>

      {% set popup_no_but_classes =  [popup_change_but_base_classes[0]] %}
      {% set popup_yes_but_classes = [popup_change_but_base_classes[1]] %}

      {% set settings_prop = 'default_popup_' ~ page_type %}
      {% set is_on = (settings|attr(settings_prop)).keyboard_trigger %}

      {% if is_on %}
        {% do popup_yes_but_classes.append('disabled-button') %}
      {% else %}
        {% do popup_no_but_classes.append('disabled-button') %}
      {% endif %}

      <p>
        {{ caller(is_on) }}
      </p>

      {{
        button_row([
            (popup_no_but_classes,
             _('web_ui.home.popup_no_button'),
             {'action': 'popup_no_when_' ~ page_type}),
            (popup_yes_but_classes,
             _('web_ui.home.popup_yes_button'),
             {'action': 'popup_yes_when_' ~ page_type})
        ])
      }}
    </div>
  {% endmacro %}

  {% set but_classes = ['green-button', 'green-button'] %}
  {% call(popup_is_on) render_popup_settings('jsallowed', true, but_classes) %}
    {% if popup_is_on %}
      {{ _('web_ui.home.jsallowed_popup_yes') }}
    {% else %}
      {{ _('web_ui.home.jsallowed_popup_no') }}
    {% endif %}
  {% endcall %}

  {% call(popup_is_on) render_popup_settings('jsblocked') %}
    {% if popup_is_on %}
      {{ _('web_ui.home.jsblocked_popup_yes') }}
    {% else %}
      {{ _('web_ui.home.jsblocked_popup_no') }}
    {% endif %}
  {% endcall %}

  {% call(popup_is_on) render_popup_settings('payloadon') %}
    {% if popup_is_on %}
      {{ _('web_ui.home.payloadon_popup_yes') }}
    {% else %}
      {{ _('web_ui.home.payloadon_popup_no') }}
    {% endif %}
  {% endcall %}

  <p>
    {{ _('web_ui.home.popup_can_be_opened_by') }}
  </p>
{% endblock main %}