-
-
Notifications
You must be signed in to change notification settings - Fork 603
/
base.html
499 lines (451 loc) · 26.2 KB
/
base.html
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
{% load static %}
{% load i18n %}
{% load theming_tags %}
{% load custom_tags %}
{% theme_values request as theme_values %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}
{% endblock %}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover">
<meta name="robots" content="noindex,nofollow"/>
<link rel="icon" href="{{ theme_values.logo_color_svg }}">
<link rel="icon" href="{{ theme_values.logo_color_32 }}" sizes="32x32">
<link rel="icon" href="{{ theme_values.logo_color_128 }}" sizes="128x128">
<link rel="icon" href="{{ theme_values.logo_color_192 }}" sizes="192x192">
<link rel="apple-touch-icon" href="{{ theme_values.logo_color_180 }}" sizes="180x180">
<link rel="manifest" crossorigin="use-credentials" href="{% url 'web_manifest' %}">
<meta name="msapplication-TileColor" content="{{ theme_values.nav_bg_color }}">
<meta name="msapplication-TileImage" content="{{ theme_values.logo_color_144 }}">
<meta name="theme-color" content="{{ theme_values.nav_bg_color }}">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- Bootstrap 4 -->
<link id="id_main_css" href="{{ theme_values.theme }}" rel="stylesheet">
{% if theme_values.custom_theme %}
<link id="id_custom_css" href="{{ theme_values.custom_theme }}" rel="stylesheet">
{% endif %}
<link href="{% static 'css/app.min.css' %}" rel="stylesheet">
<script src="{% static 'js/jquery-3.5.1.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<!-- Select2 for use with django autocomplete light -->
<link href="{% static 'css/select2.min.css' %}" rel="stylesheet"/>
<script src="{% static 'js/select2.min.js' %}"></script>
<!-- Bootstrap theme for select2 -->
<link rel="stylesheet" href="{% static 'css/select2-bootstrap.css' %}"/>
<link rel="stylesheet" href="{% static 'themes/select2-bootstrap-theme.css' %}"/>
<script type="text/javascript">
$.fn.select2.defaults.set("theme", "bootstrap");
{% if request.user.is_authenticated %}
window.ACTIVE_SPACE_ID = '{{request.space.id}}';
{% endif %}
</script>
<!-- Fontawesome icons -->
<link rel="stylesheet" href="{% static "fontawesome/fontawesome_all.min.css" %}">
{% block extra_head %} <!-- block for templates to put stuff into header -->
{% endblock %}
<style>
{% if request.user.userpreference.left_handed %}
@media screen and (max-width: 600px) {
#switcher .btn-circle {
left: 80px !important;
}
}
{% endif %}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg {{ theme_values.nav_text_class }}"
id="id_main_nav"
style="{{ theme_values.sticky_nav }}; background-color: {{ theme_values.nav_bg_color }}">
{% if not request.user.userpreference.left_handed %}
{% if not request.user.is_authenticated or request.user.userpreference.nav_show_logo %}
<a class="navbar-brand p-0 me-2 justify-content-center" href="{% base_path request 'base' %}"
aria-label="Tandoor">
<img class="brand-icon" src="{{ theme_values.nav_logo }}" alt="Logo">
</a>
{% endif %}
{% endif %}
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText"
aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
{% if request.user.userpreference.left_handed %}
{% if not request.user.is_authenticated or request.user.userpreference.nav_show_logo %}
<a class="navbar-brand p-0 me-2 justify-content-center" href="{% base_path request 'base' %}"
aria-label="Tandoor">
<img class="brand-icon" src="{{ theme_values.nav_logo }}" alt="Logo">
</a>
{% endif %}
{% endif %}
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item {% if request.resolver_match.url_name in 'view_search' %}active{% endif %}">
<a class="nav-link" href="{% url 'view_search' %}"><i
class="fas fa-fw fa-book"></i> {% trans 'Recipes' %}</a>
</li>
<li class="nav-item {% if request.resolver_match.url_name in 'view_plan' %}active{% endif %}">
<a class="nav-link" href="{% url 'view_plan' %}"><i
class="fas fa-fw fa-calendar"></i> {% trans 'Meal-Plan' %}</a>
</li>
<li class="nav-item {% if request.resolver_match.url_name in 'list_shopping_list,view_shopping' %}active{% endif %}">
<a class="nav-link" href="{% url 'view_shopping' %}"><i
class="fas fa-fw fa-shopping-cart"></i> {% trans 'Shopping' %}</a>
</li>
<li class="nav-item {% if request.resolver_match.url_name in 'view_books' %}active{% endif %}">
<a class="nav-link" href="{% url 'view_books' %}"><i
class="fas fa-fw fa-book-open"></i> {% trans 'Books' %}</a>
</li>
{% plugin_main_nav_templates as plugin_main_nav_templates %}
{% for pn in plugin_main_nav_templates %}
{% include pn %}
{% endfor %}
</ul>
<ul class="navbar-nav ml-auto">
{% if user.is_authenticated %}
{% page_help request.resolver_match.url_name as help_button %}
{% if help_button %}{{ help_button|safe }}{% endif %}
<li class="nav-item dropdown {% if request.resolver_match.url_name in 'list_keyword,list_food,list_unit,view_supermarket,data_batch_edit,view_history' %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fas fa-fw fa-toolbox fa-lg"></i>
</a>
<div class="dropdown-menu dropdown-menu-center dropdown-menu-center-large">
<div class="row m-0 mt-1 mt-md-0">
<div class="col-4">
<a href="{% url 'list_keyword' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-tags fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Keyword' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'list_food' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-leaf fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Foods' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'list_unit' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-balance-scale fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Units' %}
</div>
</div>
</a>
</div>
</div>
<div class="row m-0 mt-1 mt-md-0">
<div class="col-4">
<a href="{% url 'list_supermarket' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-store-alt fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Supermarket' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'list_supermarket_category' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-cubes fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Supermarket Category' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'list_automation' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-robot fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Automations' %}
</div>
</div>
</a>
</div>
</div>
<div class="row m-0 mt-1 mt-md-0">
<div class="col-4">
<a href="{% url 'list_user_file' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-file fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Files' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'data_batch_edit' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-edit fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Batch Edit' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'view_history' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-history fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'History' %}
</div>
</div>
</a>
</div>
</div>
<div class="row m-0 mt-1 mt-md-0">
<div class="col-4">
<a href="{% url 'view_ingredient_editor' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-th-list fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Ingredient Editor' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'view_export' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-file-export fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Export' %}
</div>
</div>
</a>
</div>
<div class="col-4">
<a href="{% url 'list_property_type' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-database fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Properties' %}
</div>
</div>
</a>
</div>
</div>
<div class="row m-0 mt-1 mt-md-0">
<div class="col-4">
<a href="{% url 'list_unit_conversion' %}" class="p-0 p-md-1">
<div class="card p-1 pt-2 no-gutters border-0">
<div class="card-body text-center p-0 no-gutters">
<i class="fas fa-exchange-alt fa-2x"></i>
</div>
<div class="card-body text-break text-center p-0 no-gutters text-muted menu-dropdown-text">
{% trans 'Unit Conversions' %}
</div>
</div>
</a>
</div>
</div>
</div>
</li>
<li class="nav-item dropdown {% if request.resolver_match.url_name in 'data_import_url,new_recipe' %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"><i
class="fas fa-fw fa-plus fa-lg"></i>
</a>
<div class="dropdown-menu dropdown-menu-center"
aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="{% url 'data_import_url' %}"><i
class="fas fa-file-import"></i> {% trans 'Import Recipe' %}</a>
<a class="dropdown-item " href="{% url 'new_recipe' %}"><i
class="fas fa-plus"></i> {% trans 'Create' %}</a>
</div>
</li>
<li class="nav-item dropdown {% if request.resolver_match.url_name in 'view_space,view_settings,view_history,view_system,docs_markdown' %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"><i
class="fas fa-fw fa-user-alt"></i> {{ user.get_user_display_name }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="{% url 'view_settings' %}"><i
class="fas fa-user-cog fa-fw"></i> {% trans 'Settings' %}</a>
<a class="dropdown-item" href="{% url 'data_sync' %}"><i
class="fas fa-sync-alt fa-fw"></i> {% trans 'External Recipes' %}</a>
{% if request.user == request.space.created_by %}
<a class="dropdown-item" href="{% url 'view_space_manage' request.space.pk %}"><i
class="fas fa-server fa-fw"></i> {% trans 'Space Settings' %}</a>
{% endif %}
{% if not DISABLE_EXTERNAL_CONNECTORS and request.user == request.space.created_by or not DISABLE_EXTERNAL_CONNECTORS and user.is_superuser %}
<a class="dropdown-item" href="{% url 'list_connector_config' %}"><i
class="fas fa-sync-alt fa-fw"></i> {% trans 'External Connectors' %}</a>
{% endif %}
{% if user.is_superuser %}
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'view_system' %}"><i
class="fas fa-server fa-fw"></i> {% trans 'System' %}</a>
<a class="dropdown-item" href="{% url 'admin:index' %}"><i
class="fas fa-user-shield fa-fw"></i> {% trans 'Admin' %}</a>
{% endif %}
{% if request.user.is_authenticated %}
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">{% trans 'Your Spaces' %}</h6>
{% for us in request.user.userspace_set.all %}
<a class="dropdown-item" href="{% url 'view_switch_space' us.space.id %}">
{% if us.active %}
<i class="far fa-dot-circle fa-fw"></i>
{% else %}
<i class="far fa-circle fa-fw"></i>
{% endif %}
{{ us.space.name }}</a>
{% endfor %}
<a class="dropdown-item" href="{% url 'view_space_overview' %}"><i
class="fas fa-list"></i> {% trans 'Overview' %}</a>
{% endif %}
{% plugin_dropdown_nav_templates as plugin_dropdown_nav_templates %}
{% for pn in plugin_dropdown_nav_templates %}
<div class="dropdown-divider"></div>
{% include pn %}
{% endfor %}
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'docs_markdown' %}"><i
class="fab fa-markdown fa-fw"></i> {% trans 'Markdown Guide' %}</a>
<a class="dropdown-item" href="https://github.com/vabene1111/recipes"><i
class="fab fa-github fa-fw"></i> {% trans 'GitHub' %}</a>
<a class="dropdown-item" href="https://translate.tandoor.dev/projects/tandoor/"><i
class="fas fa-language fa-fw"></i> {% trans 'Translate Tandoor' %}</a>
<a class="dropdown-item" href="{% url 'docs_api' %}"><i
class="fas fa-passport fa-fw"></i> {% trans 'API Documentation' %}</a>
<a class="dropdown-item" href="{% url 'api:api-root' %}"><i
class="fas fa-file-code fa-fw"></i> {% trans 'API Browser' %}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'account_logout' %}"><i
class="fas fa-sign-out-alt fa-fw"></i> {% trans 'Log out' %}</a>
</div>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'account_login' %}">{% trans 'Login' %} <i
class="fas fa-fw fa-sign-in-alt"></i></a>
</li>
{% endif %}
</ul>
</div>
</nav>
{% message_of_the_day request as message_of_the_day %}
{% if message_of_the_day %}
<div class="bg-info" style=" width: 100%; text-align: center!important; color: #ffffff; padding: 8px">
{{ message_of_the_day | markdown |safe }}
</div>
{% endif %}
{% if HOSTED and request.space.max_recipes == 10 %}
<div class="bg-warning" style=" width: 100%; text-align: center!important; color: #ffffff; padding: 8px">
{% trans 'You are using the free version of Tandor' %} <a class="btn-success btn-sm"
href="https://tandoor.dev/manage">{% trans 'Upgrade Now' %}</a>
</div>
{% endif %}
<div class="container-fluid mt-2 mt-md-3 mt-xl-3 mt-lg-3{% if request.user.userpreference.left_handed %} left-handed {% endif %}"
id="id_base_container">
<div class="row">
<div class="col-xl-2 d-none d-xl-block">
{% block content_xl_left %}
{% endblock %}
</div>
<div class="col-xl-8 col-12">
{% for message in messages %}
<div class="row">
<div class="col col-md-12">
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
</div>
{% endfor %}
{% block content %}
{% endblock %}
</div>
<div class="col-xl-2 d-none d-xl-block">
{% block content_xl_right %}
{% endblock %}
</div>
</div>
{% block content_fluid %}
{% endblock %}
{% user_prefs request as prefs %}
{{ prefs|json_script:'user_preference' }}
</div>
{% block script %}
{% endblock script %}
<script type="application/javascript">
localStorage.setItem('SCRIPT_NAME', "{% base_path request 'script' %}")
localStorage.setItem('BASE_PATH', "{% base_path request 'base' %}")
localStorage.setItem('STATIC_URL', "{% base_path request 'static_base' %}")
localStorage.setItem('DEBUG', "{% is_debug %}")
localStorage.setItem('USER_ID', "{{request.user.pk}}")
window.addEventListener("load", () => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("{% url 'service_worker' %}", {scope: "{% base_path request 'base' %}" + '/'}).then(function (reg) {
}).catch(function (err) {
console.warn('Error whilst registering service worker', err);
});
} else {
console.warn('service worker not in navigator');
}
});
</script>
<style>
@media screen and (max-width: 1000px) {
.navbar-collapse {
max-height: 60vh;
overflow-y: auto;
overflow-x: hidden;
}
.collapsing {
overflow-y: hidden;
overflow-x: hidden;
}
}
#id_base_container {
padding-bottom: env(safe-area-inset-bottom);
}
.fixed-bottom {
padding-bottom: max(0.5rem, calc(env(safe-area-inset-bottom) - 0.5rem)) !important;
}
</style>
</body>
</html>