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
15 changed files with 266 additions and 101 deletions
54
README.md
54
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/*/<event>/_index.md`) shows the schedule with `{{< schedule >}}`. It reads `data/schedule/<event>.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" >}}
|
||||
|
|
|
|||
|
|
@ -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