diff --git a/README.md b/README.md index 2698cb7..d1894ae 100644 --- a/README.md +++ b/README.md @@ -101,11 +101,12 @@ Use the `lang` shortcode to mark whether a tour is in German, English or bilingu The tour overview of an event (`content/*//_index.md`) shows the schedule with `{{< schedule >}}`. It reads `data/schedule/.yaml`, which is shared by both languages: ```yaml +fewseats: [xfel] days: - day: 1 date: "2025-12-27" tours: - - { time: "11:30", tour: xfel, lang: deen } + - { time: "11:30", tour: xfel, lang: deen, status: fewseats } - { time: "12:00", tour: city-walk, lang: de } ``` @@ -113,7 +114,8 @@ days: - `lang` is `de`, `en` or `deen`, or a list of these. It renders the same badge as the `lang` shortcode. - `time` is `HH:MM` with a leading zero (`09:30`). Tours are sorted by time, so their order in the file doesn't matter. - `title` (optional) replaces the page's title on the card, with one entry per language: `title: { de: "Hafen am Abend", en: "Harbour by Night" }`. -- `status` (optional): `soldout` marks the tour as fully booked. Other values are ignored. +- `status` (optional): `soldout` marks the date as fully booked; `fewseats` highlights "Nur wenige Plätze über" / "only a few seats left" next to the time, for a date on sale with 5 seats or fewer. Other values are ignored. +- `fewseats` (optional, top level): slugs of the tours with only a few seats left as a whole. Their cards get a small "only a few seats left" badge below the title, except on dates that have a `status` of their own, so a card never says it twice. A date can be `fewseats` without its tour being in the list, and the other way round. - With JavaScript at viewport widths of at least 667px, the first local photo in the tour page fills the right 40% of its card behind a fade when it has alt text; its gallery credit remains visible. For the events managed with Hackertours-Admin, the data file is generated by its website sync; don't edit it by hand. @@ -123,9 +125,53 @@ With JavaScript, narrow screens show a day picker, starting with today's day dur For a different event than the page's section, pass its name: `{{< schedule 39c3 >}}`. Without a data file, or without any tours in it, the shortcode renders nothing and the build logs a warning. To silence it, for example for an upcoming event, add `warning-schedule-empty` to `ignoreLogs` in `hugo.yaml`. + +## Shortcode: Tour date + +`{{< tour-date >}}` is one date in the list of dates on a tour page. Hackertours-Admin writes the facts as parameters, and the shortcode formats them the same way on every page: day and date, time, the date's own title, language, a note, and on a new line the "only a few seats left" note, the "Book now" button and the calendar links. Use it inside a list item: + +```markdown +* Touren: + * {{< tour-date day=1 date="2026-12-27" time="13:30" lang="de" title=`Piraten!?` book=`https://…/40c3ht/229/` duration=180 >}} + * {{< tour-date day=2 date="2026-12-28" time="12:55" lang="deen" note=`Die Tour wird auf Deutsch präsentiert, …` book=`https://…/40c3ht/227/` status="fewseats" >}} +``` + +renders (on the German page) + +> * Touren: +> * Tag 1 (27.12.) **13:30 Uhr** *Piraten!?* auf Deutsch\ +> [Jetzt buchen] [iCal Download | Google Calendar] +> * Tag 2 (28.12.) **12:55 Uhr** auf Deutsch und Englisch – Die Tour wird auf Deutsch präsentiert, …\ +> Nur wenige Plätze über [Jetzt buchen] [iCal Download | Google Calendar] + +| Param | Required | Content | +|---|---|---| +| `date` | yes | `YYYY-MM-DD` | +| `time` | yes | Start time `HH:MM`, local time in Hamburg | +| `day` | no | Day number of the event (`0` for the day before day 1). Shown as "Tag 1 (27.12.)" / "Day 1 (27 December)". Leave it out for dates grouped under a day heading, as in `* Tag 1 (27.12.):` followed by the times. | +| `lang` | no | `de`, `en` or `deen`: "auf Deutsch", "auf Englisch", "auf Deutsch und Englisch" / "in German", "in English", "in German and English". Anything else stops the build. | +| `title` | no | The date's own title, in italics after the time, in the page's language. | +| `note` | no | Text after the language, after a dash, in the page's language. Markdown is allowed. | +| `book` | no | The date in the ticket shop, for the "Book now" button. | +| `duration` | no | Length in minutes, for the calendar entry (see "Shortcode: Calendar entry"). | +| `status` | no | `soldout` strikes the date through and adds "ausgebucht" / "fully booked", without the button and the calendar links. `fewseats` adds the highlighted "Nur wenige Plätze über" / "only a few seats left" before the button. Other values are ignored, as in the schedule. | + +Use backticks around values that contain double quotes. The wording is in the theme's i18n files (`tour_date_*`, `fewseats`, `schedule_soldout`). + +## Shortcode: Few seats left + +`{{< fewseats >}}` says "Nur wenige Plätze über" / "only a few seats left" for the tour as a whole, as a small badge, when the page's front matter has + +```yaml +params: + fewseats: true +``` + +Hackertours-Admin puts it on its own line, right before the list of dates. It shows nothing without `params.fewseats: true`, and nothing when a date on the page already says so (a `tour-date` with `status="fewseats"`), so the page doesn't say it twice. The tour lists (the event's overview page, the home page, the tour-map's list of locations) show the same badge from `params.fewseats`, without the shortcode. + ## Shortcode: Calendar entry -`{{< calendar >}}` adds a small pill after a tour date with a calendar icon and two links: "iCal download", a calendar file (`.ics`) for that date, and "Google calendar", which adds the date in Google Calendar. Hackertours-Admin puts it into the list of dates on each tour page: +`{{< calendar >}}` adds a small pill after a tour date with a calendar icon and two links: "iCal download", a calendar file (`.ics`) for that date, and "Google calendar", which adds the date in Google Calendar. `tour-date` includes it; for a hand-written list of dates, use it on its own: ```markdown * Tag 1 (27.12.) **17:30 Uhr** {{< calendar date="2026-12-27" time="17:30" duration="210" >}} @@ -146,7 +192,7 @@ Each entry starts at the time given, in Hamburg time, at the Hackertours desk (w ## Shortcode: Book now -`{{< book >}}` adds a "Book now" button with a shopping cart icon after a tour date, linking to that date in the ticket shop. Hackertours-Admin puts it into the list of dates on each tour page, before the calendar pill: +`{{< book >}}` adds a "Book now" button with a shopping cart icon after a tour date, linking to that date in the ticket shop. `tour-date` includes it; for a hand-written list of dates, use it on its own, before the calendar pill: ```markdown * Tag 1 (27.12.) **13:00 Uhr** {{< book url="https://…/hackertours/40c3ht/100/" >}} {{< calendar date="2026-12-27" time="13:00" >}} diff --git a/themes/hackertours-40c3/assets/css/_custom.css b/themes/hackertours-40c3/assets/css/_custom.css index 2d754b7..d6988d7 100644 --- a/themes/hackertours-40c3/assets/css/_custom.css +++ b/themes/hackertours-40c3/assets/css/_custom.css @@ -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; } diff --git a/themes/hackertours/assets/css/_custom.css b/themes/hackertours/assets/css/_custom.css index fe78da1..dd74724 100644 --- a/themes/hackertours/assets/css/_custom.css +++ b/themes/hackertours/assets/css/_custom.css @@ -1,6 +1,7 @@ @import './_schedule.css'; @import './_tour-map.css'; @import './_fewseats.css'; +@import './_tour-date.css'; @import './_gallery.css'; @import './_events.css'; diff --git a/themes/hackertours/assets/css/_fewseats.css b/themes/hackertours/assets/css/_fewseats.css index 5f9780d..7312184 100644 --- a/themes/hackertours/assets/css/_fewseats.css +++ b/themes/hackertours/assets/css/_fewseats.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%; diff --git a/themes/hackertours/assets/css/_schedule.css b/themes/hackertours/assets/css/_schedule.css index c36edb7..795256d 100644 --- a/themes/hackertours/assets/css/_schedule.css +++ b/themes/hackertours/assets/css/_schedule.css @@ -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 { diff --git a/themes/hackertours/assets/css/_tour-date.css b/themes/hackertours/assets/css/_tour-date.css new file mode 100644 index 0000000..6fdd80e --- /dev/null +++ b/themes/hackertours/assets/css/_tour-date.css @@ -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; +} diff --git a/themes/hackertours/i18n/de.yaml b/themes/hackertours/i18n/de.yaml index cef42f0..a355266 100644 --- a/themes/hackertours/i18n/de.yaml +++ b/themes/hackertours/i18n/de.yaml @@ -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" diff --git a/themes/hackertours/i18n/en.yaml b/themes/hackertours/i18n/en.yaml index 3cbff15..a61cb5a 100644 --- a/themes/hackertours/i18n/en.yaml +++ b/themes/hackertours/i18n/en.yaml @@ -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" diff --git a/themes/hackertours/layouts/_partials/tour-book.html b/themes/hackertours/layouts/_partials/tour-book.html new file mode 100644 index 0000000..c0241a3 --- /dev/null +++ b/themes/hackertours/layouts/_partials/tour-book.html @@ -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. */ -}} + + {{- partial "fa-icon.html" "solid/cart-shopping" }}{{ i18n "book_now" -}} + +{{- /* chomp */ -}} diff --git a/themes/hackertours/layouts/_partials/tour-calendar.html b/themes/hackertours/layouts/_partials/tour-calendar.html new file mode 100644 index 0000000..b57fb58 --- /dev/null +++ b/themes/hackertours/layouts/_partials/tour-calendar.html @@ -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" +) -}} +{{ partial "fa-icon.html" "regular/calendar-plus" -}} +{{ i18n "calendar_ics" }} {{ $when }} +{{- /* */ -}} +{{- /* */ -}}{{ i18n "calendar_google" }} {{ $when }} +{{- /* chomp */ -}} diff --git a/themes/hackertours/layouts/_shortcodes/book.html b/themes/hackertours/layouts/_shortcodes/book.html index 1e10a9a..17123b9 100644 --- a/themes/hackertours/layouts/_shortcodes/book.html +++ b/themes/hackertours/layouts/_shortcodes/book.html @@ -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 -}} - - {{- partial "fa-icon.html" "solid/cart-shopping" }}{{ i18n "book_now" -}} - +{{- partial "tour-book.html" $url -}} {{- /* chomp */ -}} diff --git a/themes/hackertours/layouts/_shortcodes/calendar.html b/themes/hackertours/layouts/_shortcodes/calendar.html index 45ab606..ef1f10c 100644 --- a/themes/hackertours/layouts/_shortcodes/calendar.html +++ b/themes/hackertours/layouts/_shortcodes/calendar.html @@ -10,79 +10,12 @@ Params: date (YYYY-MM-DD), time (HH:MM, local time in Hamburg), duration in minu (optional, else tours..duration in data/schedule/.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) ) -}} -{{ partial "fa-icon.html" "regular/calendar-plus" -}} -{{ i18n "calendar_ics" }} {{ $when }} -{{- /* */ -}} -{{- /* */ -}}{{ i18n "calendar_google" }} {{ $when }} {{- /* chomp */ -}} diff --git a/themes/hackertours/layouts/_shortcodes/fewseats.html b/themes/hackertours/layouts/_shortcodes/fewseats.html new file mode 100644 index 0000000..7accf9d --- /dev/null +++ b/themes/hackertours/layouts/_shortcodes/fewseats.html @@ -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) -}} +

{{ partial "fewseats-badge.html" dict }}

+ {{- end -}} +{{- end -}} diff --git a/themes/hackertours/layouts/_shortcodes/schedule.html b/themes/hackertours/layouts/_shortcodes/schedule.html index 48f9c9f..8e4da4a 100644 --- a/themes/hackertours/layouts/_shortcodes/schedule.html +++ b/themes/hackertours/layouts/_shortcodes/schedule.html @@ -110,7 +110,7 @@ so an hour without tours still gets a row. {{- if $soldOut }} {{ i18n "schedule_soldout" }} {{- else if $fewSeats }} -{{ i18n "fewseats" }} +{{ i18n "fewseats" }} {{- end }} {{- with .lang }} @@ -122,7 +122,8 @@ so an hour without tours still gets a row. {{- else }} {{ $ownTitle | default $entry.tour }} {{- 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) }} {{ partial "fewseats-badge.html" dict }} {{- end }} {{- with $photo }} diff --git a/themes/hackertours/layouts/_shortcodes/tour-date.html b/themes/hackertours/layouts/_shortcodes/tour-date.html new file mode 100644 index 0000000..f4d67cc --- /dev/null +++ b/themes/hackertours/layouts/_shortcodes/tour-date.html @@ -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 "%s" (i18n "tour_date_time" (dict "Time" $time))) -}} +{{- with .Get "title" }}{{ $parts = $parts | append (printf "%s" (. | 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 -}} + + +{{- if $soldOut -}} + {{ $text | safeHTML }} {{ i18n "schedule_soldout" }} +{{- else -}} + {{ $text | safeHTML }}
+ {{- if $fewSeats }}{{ i18n "fewseats" }} {{ 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 -}} +
+{{- /* chomp */ -}}