Skip to content

Commit d798f1c

Browse files
committed
Merge branch 'develop'
2 parents 639e871 + 2622593 commit d798f1c

5 files changed

Lines changed: 75 additions & 4 deletions

File tree

‎assets/js/base.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,41 @@ function determineMastodonFollowersCount(locale, globalData) {
4545
});
4646
}
4747

48+
function determineWebinarBanner(webinarId, lang, labels, webinar) {
49+
$.getJSON(`${API_BASE_URL}/connect/contact/webinar/${webinarId}`).done(d => {
50+
if (d.status !== 'Planned' || !d.dateStart) {
51+
webinar.state = 'none';
52+
return;
53+
}
54+
const start = new Date(d.dateStart.replace(' ', 'T') + 'Z');
55+
const end = d.dateEnd ? new Date(d.dateEnd.replace(' ', 'T') + 'Z') : null;
56+
const now = new Date();
57+
if (end && now >= end) {
58+
webinar.state = 'none';
59+
return;
60+
}
61+
webinar.name = d.name;
62+
webinar.dateStart = start.toISOString();
63+
if (now >= start) {
64+
webinar.state = 'live';
65+
webinar.label = labels.live.replace('%NAME%', d.name);
66+
} else {
67+
webinar.state = 'upcoming';
68+
webinar.label = labels.upcoming.replace('%NAME%', d.name).replace('%WHEN%', formatWebinarWhen(start, lang));
69+
}
70+
}).fail(xhr => {
71+
console.error('Fetching webinar banner data failed:', xhr.responseJSON?.message || xhr.statusText);
72+
});
73+
}
74+
75+
function formatWebinarWhen(date, lang) {
76+
return new Intl.DateTimeFormat(lang || 'en', {
77+
timeZone: 'Europe/Berlin',
78+
month: 'long', day: 'numeric',
79+
hour: 'numeric', minute: '2-digit', timeZoneName: 'short'
80+
}).format(date);
81+
}
82+
4883
function formatNumber(num, locale) {
4984
let formatted = num;
5085
if (num >= 1000 && num < 1000000) {

‎i18n/de.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,14 @@
13661366
# Live Webinar Banner
13671367
- id: webinar_banner
13681368
translation: "Live-Webinar – <a class=\"whitespace-nowrap font-bold\" href=\"/de/webinar/\">Jetzt anmelden<i class=\"fa-regular fa-arrow-right ml-1\" aria-hidden=\"true\"></i></a>"
1369+
- id: webinar_banner_upcoming
1370+
translation: "Live-Webinar: %NAME% · %WHEN%"
1371+
- id: webinar_banner_live
1372+
translation: "Jetzt live: %NAME%"
1373+
- id: webinar_banner_cta
1374+
translation: "Jetzt anmelden"
1375+
- id: webinar_banner_cta_live
1376+
translation: "Jetzt beitreten"
13691377

13701378
# Webinar Form
13711379
- id: webinar_first_name

‎i18n/en.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,14 @@
14051405
# Live Webinar Banner
14061406
- id: webinar_banner
14071407
translation: "Live Webinar – <a class=\"whitespace-nowrap font-bold\" href=\"/webinar/\">Sign up<i class=\"fa-regular fa-arrow-right ml-1\" aria-hidden=\"true\"></i></a>"
1408+
- id: webinar_banner_upcoming
1409+
translation: "Live Webinar: %NAME% · %WHEN%"
1410+
- id: webinar_banner_live
1411+
translation: "Live now: %NAME%"
1412+
- id: webinar_banner_cta
1413+
translation: "Sign up"
1414+
- id: webinar_banner_cta_live
1415+
translation: "Join now"
14081416

14091417
# Webinar Form
14101418
- id: webinar_first_name

‎layouts/_default/baseof.html‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
<meta name="robots" content="noindex">
6464
{{ end }}
6565
</head>
66-
<body x-data="{ isNavOpen: false, globalData: { githubStargazers: null, mastodonFollowers: null } }" x-init="determineGlobalData('{{ .Site.Language.Lang }}', globalData)" :class="isNavOpen && 'overflow-hidden'" class="bg-dark font-body text-gray-900">
6766
{{- $anniversaryBanner := .Site.Params.anniversaryBanner -}}
6867
{{- $showAnniversaryBanner := false -}}
6968
{{- if and $anniversaryBanner $anniversaryBanner.enabled -}}
@@ -100,6 +99,7 @@
10099
{{- end -}}
101100
{{- end -}}
102101
{{- .Scratch.Set "saleBannerActive" $showSaleBanner -}}
102+
<body x-data="{ isNavOpen: false, globalData: { githubStargazers: null, mastodonFollowers: null }, webinar: { state: 'loading', name: '', dateStart: null, label: '' } }" x-init="determineGlobalData('{{ .Site.Language.Lang }}', globalData){{ if $showWebinarBanner }}; determineWebinarBanner('{{ .Site.Params.webinar.webinarId }}', '{{ .Site.Language.Lang }}', { upcoming: {{ i18n "webinar_banner_upcoming" | jsonify }}, live: {{ i18n "webinar_banner_live" | jsonify }} }, webinar){{ end }}" :class="isNavOpen && 'overflow-hidden'" class="bg-dark font-body text-gray-900">
103103
{{ partial "nav.html" . }}
104104
{{- if $showAnniversaryBanner -}}
105105
{{ partial "anniversary-banner.html" . }}
@@ -113,7 +113,13 @@
113113
{{- else if and $showThinStrip $showAnniversaryBanner -}}
114114
{{- $topPadding = cond .IsHome "" "pt-40 md:pt-32" -}}
115115
{{- end -}}
116-
<div class="bg-gray-100 min-h-[80vh] {{ $topPadding }}">
116+
{{- /* The webinar banner hides itself client-side when no webinar is live/upcoming; collapse its reserved padding to match. */ -}}
117+
{{- $webinarIsThinStrip := and $showWebinarBanner (not $showSaleBanner) -}}
118+
{{- $paddingNoStrip := cond .IsHome "" "pt-12" -}}
119+
{{- if $showAnniversaryBanner -}}
120+
{{- $paddingNoStrip = cond .IsHome "" "pt-28 md:pt-24" -}}
121+
{{- end -}}
122+
<div class="bg-gray-100 min-h-[80vh]{{ if not $webinarIsThinStrip }} {{ $topPadding }}{{ end }}"{{ if $webinarIsThinStrip }} :class="webinar.state === 'none' ? '{{ $paddingNoStrip }}' : '{{ $topPadding }}'"{{ end }}>
117123
<!-- Code that all your templates share, like a header -->
118124
{{ block "main" . }}
119125
<!-- The part of the page that begins to differ between templates -->

‎layouts/partials/nav.html‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@
99
<p>{{ i18n "nav_promotion" . | emojify }}</p>
1010
</div>
1111
{{- else if .Scratch.Get "webinarBannerActive" -}}
12-
<div class="nav-promo-strip w-full bg-primary text-center text-sm text-white p-0.5">
13-
<p>{{ i18n "webinar_banner" | safeHTML }}</p>
12+
{{- $webinarPath := printf "%s/webinar/" .Site.LanguagePrefix -}}
13+
<div class="nav-promo-strip w-full bg-primary text-center text-sm text-white p-0.5" x-show="webinar.state !== 'none'">
14+
<p>
15+
<span x-show="webinar.state !== 'upcoming' && webinar.state !== 'live'">{{ i18n "webinar_banner" | safeHTML }}</span>
16+
<span x-show="webinar.state === 'upcoming'" x-cloak>
17+
<span x-text="webinar.label"></span>
18+
<span aria-hidden="true"> – </span>
19+
<a class="whitespace-nowrap font-bold" href="{{ $webinarPath }}">{{ i18n "webinar_banner_cta" }}<i class="fa-regular fa-arrow-right ml-1" aria-hidden="true"></i></a>
20+
</span>
21+
<span x-show="webinar.state === 'live'" x-cloak>
22+
<span class="inline-block w-2 h-2 rounded-full bg-red-500 animate-pulse align-middle" aria-hidden="true"></span>
23+
<span class="ml-1" x-text="webinar.label"></span>
24+
<span aria-hidden="true"> – </span>
25+
<a class="whitespace-nowrap font-bold" href="{{ $webinarPath }}">{{ i18n "webinar_banner_cta_live" }}<i class="fa-regular fa-arrow-right ml-1" aria-hidden="true"></i></a>
26+
</span>
27+
</p>
1428
</div>
1529
{{- end -}}
1630
<div class="flex justify-between items-stretch w-full lg:px-8">

0 commit comments

Comments
 (0)