Mercurial > libervia-templates
annotate sat_templates/templates/default/base/base.html @ 237:caa3767707fb
base/base.html: expose CSRF token to script + fixed script content
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Jun 2020 17:57:01 +0200 |
parents | 739c3e6999fa |
children |
rev | line source |
---|---|
209 | 1 {# embedded is set to avoid including base.html several times if a generic page is included (e.g. blog/articles.html) #} |
2 {% set embedded = True %} | |
66 | 3 {% import 'components/common.html' as component with context %} |
229
739c3e6999fa
base: `scripts` variable can be used to create suitable tags + new `body_onload` variable
Goffi <goffi@goffi.org>
parents:
215
diff
changeset
|
4 {{ script.include('common', '') }} {# common.js is, as its name states, a common script, so it's useful to import it here #} |
166
178f55b825b7
small refactoring/redesign, better BEM integration:
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
5 {{ script.include('dom_update') }} {# will check page for dom element to modify when javascript is enabled #} |
0 | 6 <!DOCTYPE html> |
7 <html> | |
8 <head> | |
75 | 9 <meta charset="utf-8"> |
10 <meta name="viewport" content="width=device-width, initial-scale=1"> | |
25
b046a7835374
base/base.html: if norobots is set, add a <meta> to tell robots no to index or follow this page.
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
11 |
b046a7835374
base/base.html: if norobots is set, add a <meta> to tell robots no to index or follow this page.
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
12 {% if norobots %} |
b046a7835374
base/base.html: if norobots is set, add a <meta> to tell robots no to index or follow this page.
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
13 <meta name="robots" content="noindex, nofollow"> |
b046a7835374
base/base.html: if norobots is set, add a <meta> to tell robots no to index or follow this page.
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
14 {% endif %} |
b046a7835374
base/base.html: if norobots is set, add a <meta> to tell robots no to index or follow this page.
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
15 |
0 | 16 <title>{% block title %}{{C.APP_NAME}}{% endblock %}</title> |
26
d782227c088d
base/base.html: generate <script> element and include css.js by default
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
17 |
1
b13a26d55c64
base: updated CSS handling to follow changes in backend, moved CSS file to /static with splitted files
Goffi <goffi@goffi.org>
parents:
0
diff
changeset
|
18 {% if css_content is defined %} |
0 | 19 <style type="text/css"> |
20 {{css_content}} | |
21 </style> | |
164
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
22 {% if css_content_noscript is defined %} |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
23 <noscript> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
24 <style type="text/css"> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
25 {{css_content_noscript}} |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
26 </style> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
27 </noscript> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
28 {% endif %} |
0 | 29 {% else %} |
1
b13a26d55c64
base: updated CSS handling to follow changes in backend, moved CSS file to /static with splitted files
Goffi <goffi@goffi.org>
parents:
0
diff
changeset
|
30 {% for css_file in css_files %} |
164
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
31 <link rel='stylesheet' type="text/css" href='{{css_file}}'> |
1
b13a26d55c64
base: updated CSS handling to follow changes in backend, moved CSS file to /static with splitted files
Goffi <goffi@goffi.org>
parents:
0
diff
changeset
|
32 {% endfor %} |
164
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
33 {% if css_files_noscript %} |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
34 <noscript> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
35 {% for css_file in css_files_noscript %} |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
36 <link rel='stylesheet' type="text/css" href='{{css_file}}'> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
37 {% endfor %} |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
38 </noscript> |
e9f0a4215e46
multi-sites handling (moved templates to "templates" sub-directory) + noscript styles handling.
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
39 {% endif %} |
0 | 40 {% endif %} |
26
d782227c088d
base/base.html: generate <script> element and include css.js by default
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
41 |
190
cda2aad3eed0
base: "links" template variable can now be used:
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
42 {% if links is defined %} |
cda2aad3eed0
base: "links" template variable can now be used:
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
43 {% for link_data in links %} |
cda2aad3eed0
base: "links" template variable can now be used:
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
44 <link{{link_data|xmlattr}}> |
cda2aad3eed0
base: "links" template variable can now be used:
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
45 {% endfor %} |
cda2aad3eed0
base: "links" template variable can now be used:
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
46 {% endif %} |
cda2aad3eed0
base: "links" template variable can now be used:
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
47 |
125
04609722add0
base: add a XMPP uri <link> if xmpp_uri is set
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
48 {% if xmpp_uri is defined %} |
04609722add0
base: add a XMPP uri <link> if xmpp_uri is set
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
49 <link rel="alternate" type="application/atom+xml" href="{{xmpp_uri}}" > |
04609722add0
base: add a XMPP uri <link> if xmpp_uri is set
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
50 {% endif %} |
04609722add0
base: add a XMPP uri <link> if xmpp_uri is set
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
51 |
103
ff7bd09911f7
base: replaced background_image by a way to add dynamic style
Goffi <goffi@goffi.org>
parents:
94
diff
changeset
|
52 {% if dynamic_style is defined %} |
ff7bd09911f7
base: replaced background_image by a way to add dynamic style
Goffi <goffi@goffi.org>
parents:
94
diff
changeset
|
53 {# be extra careful about dynamic style, insure escaping if you use untrusted values ! #} |
19
422c54e0204a
event: adaptation to changes in backend/Libervia + background_image can now be specified in template data
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
54 <style type="text/css"> |
103
ff7bd09911f7
base: replaced background_image by a way to add dynamic style
Goffi <goffi@goffi.org>
parents:
94
diff
changeset
|
55 {{dynamic_style}} |
19
422c54e0204a
event: adaptation to changes in backend/Libervia + background_image can now be specified in template data
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
56 </style> |
422c54e0204a
event: adaptation to changes in backend/Libervia + background_image can now be specified in template data
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
57 {% endif %} |
26
d782227c088d
base/base.html: generate <script> element and include css.js by default
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
58 |
84
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
59 {# JS handling #} |
237
caa3767707fb
base/base.html: expose CSRF token to script + fixed script content
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
60 {% if csrf_token is defined %} |
caa3767707fb
base/base.html: expose CSRF token to script + fixed script content
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
61 <script>var csrf_token = "{{csrf_token}}";</script> |
caa3767707fb
base/base.html: expose CSRF token to script + fixed script content
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
62 {% endif %} |
84
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
63 {% if websocket is defined %} |
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
64 {{ script.include('websocket', '') }} |
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
65 {% endif %} |
166
178f55b825b7
small refactoring/redesign, better BEM integration:
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
66 {# FIXME: following ugly hack is temporarily needed for dom_update, until a proper way to handle gettext dynamicly is implemented #} |
178f55b825b7
small refactoring/redesign, better BEM integration:
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
67 <script>expand_txt="{% trans %}Click to expand…{% endtrans %}"; reduce_txt="{% trans %}Click to reduce…{% endtrans %}";</script> |
26
d782227c088d
base/base.html: generate <script> element and include css.js by default
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
68 {{ script.generate_scripts() }} |
229
739c3e6999fa
base: `scripts` variable can be used to create suitable tags + new `body_onload` variable
Goffi <goffi@goffi.org>
parents:
215
diff
changeset
|
69 {% for script in scripts %} |
237
caa3767707fb
base/base.html: expose CSRF token to script + fixed script content
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
70 <script{{ {'src': script.src, 'type': script.type} | xmlattr }}>{{script.content|safe}}</script> |
229
739c3e6999fa
base: `scripts` variable can be used to create suitable tags + new `body_onload` variable
Goffi <goffi@goffi.org>
parents:
215
diff
changeset
|
71 {% endfor %} |
84
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
72 {% if websocket is defined %} |
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
73 <script>var socket=new WSHandler("{{websocket.url}}", "{{websocket.token}}", {{websocket.debug}});</script> |
b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
Goffi <goffi@goffi.org>
parents:
82
diff
changeset
|
74 {% endif %} |
94 | 75 |
76 {% block favicon %} | |
77 <link rel="icon" href="{{media_path}}icons/apps/64/sat.png"> | |
78 {% endblock favicon %} | |
0 | 79 </head> |
229
739c3e6999fa
base: `scripts` variable can be used to create suitable tags + new `body_onload` variable
Goffi <goffi@goffi.org>
parents:
215
diff
changeset
|
80 |
739c3e6999fa
base: `scripts` variable can be used to create suitable tags + new `body_onload` variable
Goffi <goffi@goffi.org>
parents:
215
diff
changeset
|
81 <body{{ {'onload': body_onload} | xmlattr }}> |
215
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
82 {% if atom_url is defined %} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
83 {{ icon_defs('feed') }} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
84 {% endif %} |
165
9e8d9d754337
base/base.html: don't show menu if main_menu is defined but none or empty
Goffi <goffi@goffi.org>
parents:
164
diff
changeset
|
85 {% if main_menu %} |
66 | 86 {% block main_menu %} |
183 | 87 {% call component.menu(main_menu, class="main_menu") %} |
88 <form action="" method="get" class="menu__language"> | |
89 <select name="{{C.KEY_LANG}}" id="{{C.KEY_LANG}}" onchange="this.form.submit()"> | |
90 {% if locales|length>1 %} | |
91 {% for l in locales %} | |
92 <option value="{{l}}" {{"selected" if l==locale}}> | |
93 {{l.language_name}} | |
94 </option> | |
95 {% endfor %} | |
96 {% endif %} | |
97 </select> | |
98 <button type="submit" class="menu__language-btn"> | |
99 {% trans %}change{% endtrans %} | |
100 </button> | |
101 </form> | |
102 {% endcall %} | |
66 | 103 {% endblock main_menu %} |
104 {% endif %} | |
61 | 105 |
70
90a303a14112
base: use <main> for main area, for better semantic.
Goffi <goffi@goffi.org>
parents:
66
diff
changeset
|
106 <main id='main_area'> |
66 | 107 <header> |
108 {% if confirm %} | |
109 {# confirmation message used when post data has been handled correctly #} | |
110 {% block confirm %} | |
111 <div class="box post_confirm"> | |
112 {% block confirm_message %} | |
113 {% trans %}Your data has been sent correctly.{% endtrans %} | |
114 {% endblock confirm_message %} | |
115 </div> | |
116 {% endblock confirm %} | |
117 {% endif %} | |
202
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
118 {% if notifications %} |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
119 {% block notifications %} |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
120 {% for notification in notifications %} |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
121 <div class="box notification notification--{{notification.level}}"> |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
122 {{ notification.message }} |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
123 </div> |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
124 {% endfor %} |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
125 {% endblock notifications %} |
a1fa6744c78e
base: handle notifications through "notifications" variable
Goffi <goffi@goffi.org>
parents:
190
diff
changeset
|
126 {% endif %} |
48
37fd11d71233
base: confirmation message can now be customised using "confirm" blog
Goffi <goffi@goffi.org>
parents:
39
diff
changeset
|
127 |
66 | 128 </header> |
129 | |
130 <div id="body"> | |
131 {% block category_menu scoped %} | |
132 {% if category_menu is defined %} | |
133 {{ component.menu(category_menu, class="category_menu") }} | |
134 {% endif %} | |
135 {% endblock category_menu %} | |
136 {% block body %} | |
137 {% endblock body %} | |
138 </div> | |
215
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
139 <footer class="page__footer"> |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
140 {% block footer %} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
141 <span> |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
142 {% trans app_name=C.APP_NAME %}Powered by {{app_name}}{% endtrans %} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
143 {% if atom_url is defined %} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
144 – |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
145 <a href="{{atom_url}}" class="text--clickable"> |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
146 {% trans %}subscribe{% endtrans %} {{ icon('feed', cls='icon--text')}} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
147 </a> |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
148 {% endif %} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
149 </span> |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
150 {% endblock %} |
b2f0f81b2cd2
base: if `atom_url` is defined, a "subscribe" link is added to footer:
Goffi <goffi@goffi.org>
parents:
209
diff
changeset
|
151 </footer> |
70
90a303a14112
base: use <main> for main area, for better semantic.
Goffi <goffi@goffi.org>
parents:
66
diff
changeset
|
152 </main> |
0 | 153 </body> |
154 </html> |