-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.html
240 lines (215 loc) · 8.05 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
{% extends "layout/_template.njk" %}
{% from "components/cookies-banner/_macro.njk" import onsCookiesBanner %}
{% from "component_overrides/header/_macro.njk" import onsHeaderNew %}
{% set page_title %}
{% if current_site and page.pk == current_site.root_page.pk and current_site.site_name %}{{ current_site.site_name }} | {% endif %}{% block title %}{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title}}{% endif %}{% endblock %}{% block title_suffix %}{% if current_site and page.pk != current_site.root_page.pk and current_site.site_name %} | {{ current_site.site_name }}{% endif %}{% endblock %}
{% endset %}
{# fmt:off #}
{% set languages = languages | default([
{
"url": "#",
"isoCode": "en",
"text": "English",
"current": true
},
{
"url": "#",
"isoCode": "cy",
"text": "Cymraeg",
"current": false
}
])
%}
{% if page %}
{% set body_class = ["template-", page.get_verbose_name()| lower | replace(" ", "-")] | join %}
{% else %}
{% set body_class = '' %}
{% endif %}
{%- set page_title -%}
{%- with current_site=wagtail_site() -%}
{% if current_site and page.pk == current_site.root_page.pk and current_site.site_name %}{{ current_site.site_name }} - {% endif %}{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.display_title | default(page.title) }}{% endif %}{% if current_site and page.pk != current_site.root_page.pk and current_site.site_name %} - {{ current_site.site_name }}{% endif %}
{%- endwith -%}
{%- endset -%}
{% set navigation_settings = settings.navigation.NavigationSettings %}
{% set main_menu = main_menu | default(navigation_settings.main_menu) %}
{% set keyLinksList = [] %}
{% if main_menu and main_menu.highlights %}
{% for highlight in main_menu.highlights %}
{% if highlight.value.page and highlight.value.page.live %}
{% set _ = keyLinksList.append({
'text': highlight.value.title if highlight.value.title else highlight.value.page.title,
'description': highlight.value.description,
'url': pageurl(highlight.value.page),
}) %}
{% elif highlight.value.external_url %}
{% set _ = keyLinksList.append({
'text': highlight.value.title,
'description': highlight.value.description,
'url': highlight.value.external_url,
}) %}
{% endif %}
{% endfor %}
{% endif %}
{% set itemsList = [] %}
{% if main_menu and main_menu.columns %}
{% for column in main_menu.columns %}
{% set columnData = {
'column': loop.index,
'linksList': []
} %}
{% for section in column.value.sections %}
{% if section.section_link.page and section.section_link.page.live %}
{% set sectionData = {
'text': section.section_link.title or section.section_link.page.title,
'url': pageurl(section.section_link.page),
'children': []
} %}
{% elif section.section_link.external_url %}
{% set sectionData = {
'text': section.section_link.title,
'url': section.section_link.external_url,
'children': []
} %}
{% endif %}
{% if sectionData %}
{% for link in section.links %}
{% if link.page and link.page.live%}
{% do sectionData.children.append({
'text': link.title or link.page.title,
'url': pageurl(link.page),
}) %}
{% elif link.external_url %}
{% do sectionData.children.append({
'text': link.title,
'url': link.external_url,
}) %}
{% endif %}
{% endfor %}
{% endif %}
{% do columnData.linksList.append(sectionData) %}
{% endfor %}
{% do itemsList.append(columnData) %}
{% endfor %}
{% endif %}
{% set pageConfig = {
"bodyClasses": body_class,
"title": page_title,
"header": {
"phase": {
"badge": 'Beta',
"html": 'This is a new service.'
},
"language": {
"languages": languages
},
"mastheadLogoUrl": "/",
"navLinks": {
"id": "nav-links-external",
"ariaLabel": 'Main menu',
"ariaListLabel": 'Menu',
"toggleNavButton": {
"text": 'Menu',
"ariaLabel": 'Toggle main menu'
},
"keyLinksList": keyLinksList,
"itemsList": itemsList
}
},
"footer": {
"rows": [
{
"itemsList": [
{
"text": 'Contact us',
"url": '#0'
},
{
"text": 'Cookies and privacy',
"url": '#0'
}
]
}
],
"oglLink": {
"pre": 'All content is available under the',
"text": 'Open Government Licence v3.0',
"url": 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
"post": ', except where otherwise stated'
}
}
}
%}
{# fmt:on #}
{% block head %}
<link rel="stylesheet" href="{{ static ('css/main.css') }}">
{% if GOOGLE_TAG_MANAGER_CONTAINER_ID and not request.is_preview %}
<script>
function loadGTM(){
(function(w,d,s,l,i){
w[l]=w[l]||[];
w[l].push({
'gtm.start': new Date().getTime(),
event:'gtm.js'
});
var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
f.parentNode.insertBefore(j,f);
})
(window,document,'script','dataLayer', "{{ GOOGLE_TAG_MANAGER_CONTAINER_ID|escape }}");
}
function isUsageCookieAllowed(){
var re = /^(.*)?\s*'usage':true\s*[^;]+(.*)?$/;
return document.cookie.match(re);
}
if (isUsageCookieAllowed()) {
loadGTM();
}
</script>
{% endif %}
{% endblock %}
{% block preMain %}
{% if not IS_EXTERNAL_ENV %}
{{ wagtailuserbar() }}
{% endif %}
{% endblock %}
{% block header %}
{{
onsHeaderNew({
"wide": pageConfig.wide,
"fullWidth": pageConfig.fullWidth,
"language": pageConfig.header.language,
"button": pageConfig.header.signoutButton,
"toggleNavigationButton": pageConfig.header.toggleNavigationButton,
"navigation": pageConfig.header.navigation,
"siteSearchAutosuggest": pageConfig.header.siteSearchAutosuggest,
"browserBanner": pageConfig.header.browserBanner,
"phase": pageConfig.header.phase,
"navLinks": pageConfig.header.navLinks,
"variants": pageConfig.header.variants,
"classes": pageConfig.header.classes,
"mastheadLogo": pageConfig.header.mastheadLogo,
"mastheadLogoUrl": pageConfig.header.mastheadLogoUrl,
"titleUrl": pageConfig.header.titleUrl,
"title": pageConfig.header.title | default(pageConfig.title),
"description": pageConfig.header.description,
"titleAsH1": pageConfig.header.titleAsH1,
"titleLogo": pageConfig.header.titleLogo
})
}}
{% endblock %}
{% block scripts %}
<script src="{{ static('js/main.js') }}"></script>
{% endblock %}
{% block preHeader %}
{# fmt:off #}
{{
onsCookiesBanner({
'lang': "cy" if LANGUAGE_CODE == "cy" else "en",
'serviceName': COOKIE_BANNER_SERVICE_NAME,
'settingsLinkUrl': MANAGE_COOKIE_SETTINGS_URL,
})
}}
{# fmt:on #}
{% endblock %}