Tour pages: tour-date and fewseats shortcodes; one few-seats mark per card
tour-date formats one date in a tour page's list of dates from its parameters: day and date, time, title, language, note, status (soldout, fewseats), "Book now" button and calendar links. Hackertours-Admin can write it instead of the formatted text. fewseats shows the badge for the tour as a whole from params.fewseats, unless a date on the page already says so. book and calendar keep working; their HTML moved to partials. In the schedule, the tour badge is left out on dates with a status of their own, so a card no longer says "few seats left" twice.
This commit is contained in:
parent
9e0cdf5264
commit
47c4008dd4
14 changed files with 266 additions and 101 deletions
|
|
@ -2,6 +2,7 @@
|
|||
@import './_schedule-40c3.css';
|
||||
@import './_tour-map.css';
|
||||
@import './_fewseats.css';
|
||||
@import './_tour-date.css';
|
||||
@import './_gallery.css';
|
||||
@import './_events.css';
|
||||
|
||||
|
|
@ -522,7 +523,7 @@ span.content-image {
|
|||
}
|
||||
|
||||
/* Square, like the language badges. */
|
||||
.schedule__status--fewseats,
|
||||
.fewseats-note,
|
||||
.fewseats-badge {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
@import './_schedule.css';
|
||||
@import './_tour-map.css';
|
||||
@import './_fewseats.css';
|
||||
@import './_tour-date.css';
|
||||
@import './_gallery.css';
|
||||
@import './_events.css';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,25 @@
|
|||
/* "Only a few seats left": amber highlight with dark text, which keeps its contrast on the
|
||||
light and the dark page background. The date note in the schedule is filled
|
||||
(_schedule.css); the badge for a tour as a whole is tinted, with an amber outline. */
|
||||
light and the dark page background. The note for a single date (schedule cards, the dates
|
||||
on a tour page) is filled; the badge for a tour as a whole is tinted, with an amber outline. */
|
||||
:root {
|
||||
--fewseats: #ffbc40;
|
||||
--fewseats-text: #001300;
|
||||
}
|
||||
|
||||
/* After .schedule__status, which it overrides. If it doesn't fit next to the time it moves
|
||||
below it as a whole, and only breaks (in balanced lines) when it is wider than the card. */
|
||||
.fewseats-note {
|
||||
min-width: 0;
|
||||
padding: 0 0.4rem;
|
||||
border-radius: var(--radius-s);
|
||||
background: var(--fewseats);
|
||||
color: var(--fewseats-text);
|
||||
font-weight: normal;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
.fewseats-badge {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
|
|
|
|||
|
|
@ -196,21 +196,6 @@
|
|||
color: var(--color-text-meta);
|
||||
}
|
||||
|
||||
/* Only a few seats left on this date: an amber highlight (_fewseats.css), in the case the
|
||||
tour pages use. If it doesn't fit next to the time it moves below it as a whole, and only
|
||||
breaks (in balanced lines) when the card is narrower than the note. */
|
||||
.schedule__status--fewseats {
|
||||
min-width: 0;
|
||||
padding: 0 0.4rem;
|
||||
border-radius: var(--radius-s);
|
||||
background: var(--fewseats);
|
||||
color: var(--fewseats-text);
|
||||
font-weight: normal;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
/* The tour as a whole has only a few seats left: a badge below the title. It stays under
|
||||
the card-wide link, so clicking it opens the tour. */
|
||||
.schedule__fewseats {
|
||||
|
|
|
|||
20
themes/hackertours/assets/css/_tour-date.css
Normal file
20
themes/hackertours/assets/css/_tour-date.css
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* Dates on a tour page (tour-date shortcode) and the note for the tour as a whole (fewseats
|
||||
shortcode). The highlight itself is in _fewseats.css. */
|
||||
|
||||
/* Fully booked: struck through and muted, with the status in full colour. */
|
||||
.tour-date--soldout del {
|
||||
color: var(--color-text-meta);
|
||||
}
|
||||
|
||||
.tour-date__status {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* The note stays in one piece; the button and the calendar links wrap after it. */
|
||||
.tour-date .fewseats-note {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tour-fewseats {
|
||||
margin-block-end: 0.5rem;
|
||||
}
|
||||
|
|
@ -14,6 +14,12 @@ schedule_day: "Tag {{ .Day }}"
|
|||
schedule_pick_day: "Tag auswählen"
|
||||
schedule_soldout: "ausgebucht"
|
||||
skip_to_content: "Zum Inhalt springen"
|
||||
tour_date_day: "Tag {{ .Day }} ({{ .Date }})"
|
||||
tour_date_date_format: "2.1."
|
||||
tour_date_time: "{{ .Time }} Uhr"
|
||||
tour_date_lang_de: "auf Deutsch"
|
||||
tour_date_lang_en: "auf Englisch"
|
||||
tour_date_lang_deen: "auf Deutsch und Englisch"
|
||||
tour_map_label: "Karte der Tourorte"
|
||||
tour_map_osm: "auf OpenStreetMap"
|
||||
tour_map_zoom_in: "Vergrößern"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ schedule_day: "Day {{ .Day }}"
|
|||
schedule_pick_day: "Choose a day"
|
||||
schedule_soldout: "fully booked"
|
||||
skip_to_content: "Skip to content"
|
||||
tour_date_day: "Day {{ .Day }} ({{ .Date }})"
|
||||
tour_date_date_format: "2 January"
|
||||
tour_date_time: "{{ .Time }}"
|
||||
tour_date_lang_de: "in German"
|
||||
tour_date_lang_en: "in English"
|
||||
tour_date_lang_deen: "in German and English"
|
||||
tour_map_label: "Map of the tour locations"
|
||||
tour_map_osm: "on OpenStreetMap"
|
||||
tour_map_zoom_in: "Zoom in"
|
||||
|
|
|
|||
6
themes/hackertours/layouts/_partials/tour-book.html
Normal file
6
themes/hackertours/layouts/_partials/tour-book.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{{- /* "Book now" button for one date of a tour (see the book shortcode, which calls this, and
|
||||
tour-date). Param: the date's URL in the ticket shop. */ -}}
|
||||
<a class="button button--small tour-book" href="{{ . }}">
|
||||
{{- partial "fa-icon.html" "solid/cart-shopping" }}{{ i18n "book_now" -}}
|
||||
</a>
|
||||
{{- /* chomp */ -}}
|
||||
81
themes/hackertours/layouts/_partials/tour-calendar.html
Normal file
81
themes/hackertours/layouts/_partials/tour-calendar.html
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{{- /*
|
||||
Calendar links for one date of a tour (see the calendar shortcode, which calls this, and
|
||||
tour-date). Params, as a dict: page, date (YYYY-MM-DD), time (HH:MM), duration (optional,
|
||||
minutes), title (optional), position (for error messages).
|
||||
*/ -}}
|
||||
{{- $page := .page -}}
|
||||
{{- $lang := $page.Language.Name -}}
|
||||
{{- $other := cond (eq $lang "de") "en" "de" -}}
|
||||
{{- $event := $page.Section -}}
|
||||
{{- $slug := $page.File.ContentBaseName -}}
|
||||
{{- $date := .date -}}
|
||||
{{- $time := .time -}}
|
||||
{{- if not (and (findRE `^\d{4}-\d{2}-\d{2}$` $date) (findRE `^\d{2}:\d{2}$` $time)) -}}
|
||||
{{- errorf "calendar: date must be YYYY-MM-DD and time HH:MM, got %q %q: %s" $date $time .position -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $data := dict -}}
|
||||
{{- with hugo.Data.schedule }}{{ with index . $event }}{{ $data = . }}{{ end }}{{ end -}}
|
||||
{{- $tourData := dict -}}
|
||||
{{- with $data.tours }}{{ with index . $slug }}{{ $tourData = . }}{{ end }}{{ end -}}
|
||||
{{- /* This date in the schedule, for its title. */ -}}
|
||||
{{- $slot := dict -}}
|
||||
{{- range $data.days -}}
|
||||
{{- if eq .date $date -}}
|
||||
{{- range .tours }}{{ if and (eq .tour $slug) (eq .time $time) }}{{ $slot = . }}{{ end }}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $title := .title -}}
|
||||
{{- if not $title }}{{ with $slot.title }}{{ $title = index . $lang | default (index . $other) }}{{ end }}{{ end -}}
|
||||
{{- $title = $title | default $page.Title -}}
|
||||
|
||||
{{- $minutes := int (.duration | default ($tourData.duration | default 0)) -}}
|
||||
{{- if not $minutes -}}
|
||||
{{- warnidf "warning-calendar-duration" "calendar: no duration for %s on %s %s, the calendar entry has no end time: %s" $slug $date $time .position -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $start := time.AsTime (printf "%sT%s:00" $date $time) "Europe/Berlin" -}}
|
||||
{{- $end := $start.Add (time.ParseDuration (printf "%dm" $minutes)) -}}
|
||||
{{- $utc := "20060102T150405Z" -}}
|
||||
|
||||
{{- /* Everyone meets at the Hackertours desk, which is where the routes on the map start. */ -}}
|
||||
{{- $location := i18n "calendar_meeting_point" -}}
|
||||
{{- with $data.map }}{{ with .origin }}{{ with .name -}}
|
||||
{{- $location = printf "%s, %s" $location (index . $lang | default (index . $other)) -}}
|
||||
{{- end }}{{ end }}{{ end -}}
|
||||
{{- /* The front matter summary: .Summary would render this page again from inside its own shortcode. */ -}}
|
||||
{{- $summary := $page.Params.summary | default $page.Description | default "" -}}
|
||||
{{- $description := printf "%s\n\n%s" ($page.RenderString $summary | plainify | htmlUnescape | strings.TrimSpace) $page.Permalink -}}
|
||||
|
||||
{{- $ics := printf "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//CCC Hansestadt Hamburg//Hackertours//%s\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\n" (upper $lang) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "UID" "value" (printf "%s-%s-%s-%s@%s" $event $slug $date (replace $time ":" "") (urls.Parse site.BaseURL).Host))) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DTSTAMP" "value" ($page.Lastmod.UTC.Format $utc))) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DTSTART" "value" ($start.UTC.Format $utc))) -}}
|
||||
{{- if $minutes }}{{ $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DTEND" "value" ($end.UTC.Format $utc))) }}{{ end -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "SUMMARY" "value" $title "text" true)) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "LOCATION" "value" $location "text" true)) -}}
|
||||
{{- with $data.map }}{{ with .origin }}{{ with .geo -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "GEO" "value" (printf "%v;%v" .lat .lon))) -}}
|
||||
{{- end }}{{ end }}{{ end -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DESCRIPTION" "value" $description "text" true)) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "URL" "value" $page.Permalink)) -}}
|
||||
{{- $ics = printf "%sEND:VEVENT\r\nEND:VCALENDAR\r\n" $ics -}}
|
||||
|
||||
{{- $file := printf "%s-%s-%s.ics" $slug $date (replace $time ":" "") -}}
|
||||
{{- $icsFile := resources.FromString (path.Join (strings.TrimPrefix "/" $page.RelPermalink) $file) $ics -}}
|
||||
{{- /* The link texts are the same for every date, so their names for screen readers include the date. */ -}}
|
||||
{{- $when := printf "%s %s" ($start | time.Format "Mon 2.1.") $time -}}
|
||||
{{- $google := printf "https://calendar.google.com/calendar/render?%s" (querify
|
||||
"action" "TEMPLATE"
|
||||
"text" $title
|
||||
"dates" (printf "%s/%s" ($start.UTC.Format $utc) ($end.UTC.Format $utc))
|
||||
"details" $description
|
||||
"location" $location
|
||||
"ctz" "Europe/Berlin"
|
||||
) -}}
|
||||
<span class="tour-calendar">{{ partial "fa-icon.html" "regular/calendar-plus" -}}
|
||||
<a href="{{ $icsFile.RelPermalink }}" download="{{ $file }}">{{ i18n "calendar_ics" }}<span class="visually-hidden"> {{ $when }}</span></a>
|
||||
{{- /* */ -}}<span class="tour-calendar__separator" aria-hidden="true">|</span>
|
||||
{{- /* */ -}}<a href="{{ $google }}">{{ i18n "calendar_google" }}<span class="visually-hidden"> {{ $when }}</span></a></span>
|
||||
{{- /* chomp */ -}}
|
||||
|
|
@ -8,7 +8,5 @@ Param: url, the date in the ticket shop.
|
|||
*/ -}}
|
||||
{{- $url := .Get "url" -}}
|
||||
{{- if not $url }}{{ errorf "book: no url: %s" .Position }}{{ end -}}
|
||||
<a class="button button--small tour-book" href="{{ $url }}">
|
||||
{{- partial "fa-icon.html" "solid/cart-shopping" }}{{ i18n "book_now" -}}
|
||||
</a>
|
||||
{{- partial "tour-book.html" $url -}}
|
||||
{{- /* chomp */ -}}
|
||||
|
|
|
|||
|
|
@ -10,79 +10,12 @@ Params: date (YYYY-MM-DD), time (HH:MM, local time in Hamburg), duration in minu
|
|||
(optional, else tours.<slug>.duration in data/schedule/<event>.yaml), title (optional, else the
|
||||
title of this date in the schedule data, else the page title).
|
||||
*/ -}}
|
||||
{{- $page := .Page -}}
|
||||
{{- $lang := $page.Language.Name -}}
|
||||
{{- $other := cond (eq $lang "de") "en" "de" -}}
|
||||
{{- $event := $page.Section -}}
|
||||
{{- $slug := $page.File.ContentBaseName -}}
|
||||
{{- $date := .Get "date" -}}
|
||||
{{- $time := .Get "time" -}}
|
||||
{{- if not (and (findRE `^\d{4}-\d{2}-\d{2}$` $date) (findRE `^\d{2}:\d{2}$` $time)) -}}
|
||||
{{- errorf "calendar: date must be YYYY-MM-DD and time HH:MM, got %q %q: %s" $date $time .Position -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $data := dict -}}
|
||||
{{- with hugo.Data.schedule }}{{ with index . $event }}{{ $data = . }}{{ end }}{{ end -}}
|
||||
{{- $tourData := dict -}}
|
||||
{{- with $data.tours }}{{ with index . $slug }}{{ $tourData = . }}{{ end }}{{ end -}}
|
||||
{{- /* This date in the schedule, for its title. */ -}}
|
||||
{{- $slot := dict -}}
|
||||
{{- range $data.days -}}
|
||||
{{- if eq .date $date -}}
|
||||
{{- range .tours }}{{ if and (eq .tour $slug) (eq .time $time) }}{{ $slot = . }}{{ end }}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $title := .Get "title" -}}
|
||||
{{- if not $title }}{{ with $slot.title }}{{ $title = index . $lang | default (index . $other) }}{{ end }}{{ end -}}
|
||||
{{- $title = $title | default $page.Title -}}
|
||||
|
||||
{{- $minutes := int (.Get "duration" | default ($tourData.duration | default 0)) -}}
|
||||
{{- if not $minutes -}}
|
||||
{{- warnidf "warning-calendar-duration" "calendar: no duration for %s on %s %s, the calendar entry has no end time: %s" $slug $date $time .Position -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $start := time.AsTime (printf "%sT%s:00" $date $time) "Europe/Berlin" -}}
|
||||
{{- $end := $start.Add (time.ParseDuration (printf "%dm" $minutes)) -}}
|
||||
{{- $utc := "20060102T150405Z" -}}
|
||||
|
||||
{{- /* Everyone meets at the Hackertours desk, which is where the routes on the map start. */ -}}
|
||||
{{- $location := i18n "calendar_meeting_point" -}}
|
||||
{{- with $data.map }}{{ with .origin }}{{ with .name -}}
|
||||
{{- $location = printf "%s, %s" $location (index . $lang | default (index . $other)) -}}
|
||||
{{- end }}{{ end }}{{ end -}}
|
||||
{{- /* The front matter summary: .Summary would render this page again from inside its own shortcode. */ -}}
|
||||
{{- $summary := $page.Params.summary | default $page.Description | default "" -}}
|
||||
{{- $description := printf "%s\n\n%s" ($page.RenderString $summary | plainify | htmlUnescape | strings.TrimSpace) $page.Permalink -}}
|
||||
|
||||
{{- $ics := printf "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//CCC Hansestadt Hamburg//Hackertours//%s\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\n" (upper $lang) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "UID" "value" (printf "%s-%s-%s-%s@%s" $event $slug $date (replace $time ":" "") (urls.Parse site.BaseURL).Host))) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DTSTAMP" "value" ($page.Lastmod.UTC.Format $utc))) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DTSTART" "value" ($start.UTC.Format $utc))) -}}
|
||||
{{- if $minutes }}{{ $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DTEND" "value" ($end.UTC.Format $utc))) }}{{ end -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "SUMMARY" "value" $title "text" true)) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "LOCATION" "value" $location "text" true)) -}}
|
||||
{{- with $data.map }}{{ with .origin }}{{ with .geo -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "GEO" "value" (printf "%v;%v" .lat .lon))) -}}
|
||||
{{- end }}{{ end }}{{ end -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "DESCRIPTION" "value" $description "text" true)) -}}
|
||||
{{- $ics = printf "%s%s" $ics (partial "ics-line.html" (dict "name" "URL" "value" $page.Permalink)) -}}
|
||||
{{- $ics = printf "%sEND:VEVENT\r\nEND:VCALENDAR\r\n" $ics -}}
|
||||
|
||||
{{- $file := printf "%s-%s-%s.ics" $slug $date (replace $time ":" "") -}}
|
||||
{{- $icsFile := resources.FromString (path.Join (strings.TrimPrefix "/" $page.RelPermalink) $file) $ics -}}
|
||||
{{- /* The link texts are the same for every date, so their names for screen readers include the date. */ -}}
|
||||
{{- $when := printf "%s %s" ($start | time.Format "Mon 2.1.") $time -}}
|
||||
{{- $google := printf "https://calendar.google.com/calendar/render?%s" (querify
|
||||
"action" "TEMPLATE"
|
||||
"text" $title
|
||||
"dates" (printf "%s/%s" ($start.UTC.Format $utc) ($end.UTC.Format $utc))
|
||||
"details" $description
|
||||
"location" $location
|
||||
"ctz" "Europe/Berlin"
|
||||
{{- partial "tour-calendar.html" (dict
|
||||
"page" .Page
|
||||
"date" (.Get "date")
|
||||
"time" (.Get "time")
|
||||
"duration" (.Get "duration")
|
||||
"title" (.Get "title")
|
||||
"position" (string .Position)
|
||||
) -}}
|
||||
<span class="tour-calendar">{{ partial "fa-icon.html" "regular/calendar-plus" -}}
|
||||
<a href="{{ $icsFile.RelPermalink }}" download="{{ $file }}">{{ i18n "calendar_ics" }}<span class="visually-hidden"> {{ $when }}</span></a>
|
||||
{{- /* */ -}}<span class="tour-calendar__separator" aria-hidden="true">|</span>
|
||||
{{- /* */ -}}<a href="{{ $google }}">{{ i18n "calendar_google" }}<span class="visually-hidden"> {{ $when }}</span></a></span>
|
||||
{{- /* chomp */ -}}
|
||||
|
|
|
|||
11
themes/hackertours/layouts/_shortcodes/fewseats.html
Normal file
11
themes/hackertours/layouts/_shortcodes/fewseats.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{{- /*
|
||||
"Only a few seats left" for the tour as a whole, when the page's front matter has
|
||||
params.fewseats: true. Hackertours-Admin puts it on its own line, right before the list of
|
||||
dates. It shows nothing when a date on the page already says so (tour-date with
|
||||
status="fewseats"), so the page doesn't say it twice.
|
||||
*/ -}}
|
||||
{{- if eq .Page.Params.fewseats true -}}
|
||||
{{- if not (findRE `\{\{<\s*tour-date\s[^>]*\bstatus=["\x60]?fewseats\b` .Page.RawContent) -}}
|
||||
<p class="tour-fewseats">{{ partial "fewseats-badge.html" dict }}</p>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
@ -110,7 +110,7 @@ so an hour without tours still gets a row.
|
|||
{{- if $soldOut }}
|
||||
<span class="schedule__status">{{ i18n "schedule_soldout" }}</span>
|
||||
{{- else if $fewSeats }}
|
||||
<span class="schedule__status schedule__status--fewseats">{{ i18n "fewseats" }}</span>
|
||||
<span class="schedule__status fewseats-note">{{ i18n "fewseats" }}</span>
|
||||
{{- end }}
|
||||
</span>
|
||||
{{- with .lang }}
|
||||
|
|
@ -122,7 +122,8 @@ so an hour without tours still gets a row.
|
|||
{{- else }}
|
||||
<span class="schedule__title">{{ $ownTitle | default $entry.tour }}</span>
|
||||
{{- end }}
|
||||
{{- if in $fewSeatsTours $entry.tour }}
|
||||
{{- /* The tour badge only on dates without a status of their own, so the card never says it twice. */}}
|
||||
{{- if and (in $fewSeatsTours $entry.tour) (not $soldOut) (not $fewSeats) }}
|
||||
<span class="schedule__fewseats">{{ partial "fewseats-badge.html" dict }}</span>
|
||||
{{- end }}
|
||||
{{- with $photo }}
|
||||
|
|
|
|||
56
themes/hackertours/layouts/_shortcodes/tour-date.html
Normal file
56
themes/hackertours/layouts/_shortcodes/tour-date.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{{- /*
|
||||
One date of a tour, for the list of dates on a tour page: day and date, time, the date's own
|
||||
title, language and a note, then on a new line the "Book now" button and the calendar links.
|
||||
Hackertours-Admin writes one per date:
|
||||
|
||||
* {{< tour-date day=1 date="2026-12-27" time="17:45" lang="deen" book=`https://…/258/` status="fewseats" >}}
|
||||
|
||||
Without day (dates grouped under a day) only the time and what follows is shown.
|
||||
status: soldout strikes the date through and marks it fully booked, without the button and the
|
||||
calendar links; fewseats adds the "only a few seats left" note before the button. Other values
|
||||
are ignored. Params and their wording: README, "Shortcode: Tour date".
|
||||
*/ -}}
|
||||
{{- $position := string .Position -}}
|
||||
{{- $day := .Get "day" -}}
|
||||
{{- $date := .Get "date" -}}
|
||||
{{- $time := .Get "time" -}}
|
||||
{{- if not (and (findRE `^\d{4}-\d{2}-\d{2}$` $date) (findRE `^\d{2}:\d{2}$` $time)) -}}
|
||||
{{- errorf "tour-date: date must be YYYY-MM-DD and time HH:MM, got %q %q: %s" $date $time $position -}}
|
||||
{{- end -}}
|
||||
{{- $lang := .Get "lang" | default "" | lower -}}
|
||||
{{- if and $lang (not (in (slice "de" "en" "deen") $lang)) -}}
|
||||
{{- errorf "tour-date: lang must be de, en or deen, got %q: %s" $lang $position -}}
|
||||
{{- end -}}
|
||||
{{- $status := .Get "status" | default "" -}}
|
||||
{{- $soldOut := eq $status "soldout" -}}
|
||||
{{- $fewSeats := eq $status "fewseats" -}}
|
||||
{{- $book := .Get "book" | default "" -}}
|
||||
|
||||
{{- $parts := slice -}}
|
||||
{{- if isset .Params "day" -}}
|
||||
{{- $dateLabel := time.AsTime $date | time.Format (i18n "tour_date_date_format") -}}
|
||||
{{- $parts = $parts | append (i18n "tour_date_day" (dict "Day" $day "Date" $dateLabel)) -}}
|
||||
{{- end -}}
|
||||
{{- $parts = $parts | append (printf "<strong>%s</strong>" (i18n "tour_date_time" (dict "Time" $time))) -}}
|
||||
{{- with .Get "title" }}{{ $parts = $parts | append (printf "<em>%s</em>" (. | htmlEscape)) }}{{ end -}}
|
||||
{{- with $lang }}{{ $parts = $parts | append (i18n (printf "tour_date_lang_%s" .)) }}{{ end -}}
|
||||
{{- $text := delimit $parts " " -}}
|
||||
{{- with .Get "note" }}{{ $text = printf "%s – %s" $text ($.Page.RenderString .) }}{{ end -}}
|
||||
|
||||
<span class="tour-date{{ if or $soldOut $fewSeats }} tour-date--{{ $status }}{{ end }}">
|
||||
{{- if $soldOut -}}
|
||||
<del>{{ $text | safeHTML }}</del> <span class="tour-date__status">{{ i18n "schedule_soldout" }}</span>
|
||||
{{- else -}}
|
||||
{{ $text | safeHTML }}<br>
|
||||
{{- if $fewSeats }}<span class="fewseats-note">{{ i18n "fewseats" }}</span> {{ end -}}
|
||||
{{- with $book }}{{ partial "tour-book.html" . }} {{ end -}}
|
||||
{{- partial "tour-calendar.html" (dict
|
||||
"page" .Page
|
||||
"date" $date
|
||||
"time" $time
|
||||
"duration" (.Get "duration")
|
||||
"position" $position
|
||||
) -}}
|
||||
{{- end -}}
|
||||
</span>
|
||||
{{- /* chomp */ -}}
|
||||
Loading…
Reference in a new issue