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.
56 lines
2.6 KiB
HTML
56 lines
2.6 KiB
HTML
{{- /*
|
||
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 */ -}}
|