Show tour photos in schedule cards

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Vincent Mahnke 2026-11-14 03:19:02 +01:00
commit 0e86c57987
Signed by: ViMaSter
GPG key ID: 6D787326BA7D6469
5 changed files with 70 additions and 14 deletions

View file

@ -114,6 +114,7 @@ days:
- `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.
- The first local photo in the tour page is shown on its card when it has alt text; its gallery credit is displayed below it.
For the events managed with Hackertours-Admin, the data file is generated by its website sync; don't edit it by hand.

View file

@ -133,6 +133,29 @@
gap: 0 0.5rem;
}
.schedule__card--photo {
grid-template-columns: minmax(0, 1fr) auto minmax(0, 6rem);
.schedule__title {
grid-column: 1 / 3;
}
}
.schedule__photo {
grid-column: 3;
grid-row: 1 / 3;
margin: 0;
font-size: var(--fs-xs);
color: var(--color-text-meta);
overflow-wrap: anywhere;
img {
display: block;
width: 100%;
height: auto;
}
}
.schedule__status {
font-family: var(--ff-alt);
font-size: var(--fs-xs);

View file

@ -0,0 +1,19 @@
{{- $result := dict -}}
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
{{- $alt := index . 0 1 -}}
{{- $dest := index . 0 2 -}}
{{- $credit := "" -}}
{{- with index . 0 3 -}}
{{- $dest = "" -}}
{{- $alt = "" -}}
{{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- with findRESubmatch "\\bcredit=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $credit = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- end -}}
{{- $resource := false -}}
{{- if not (findRE `^https?://` $dest) -}}
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
{{- end -}}
{{- $result = dict "alt" $alt "credit" $credit "dest" $dest "resource" $resource -}}
{{- end -}}
{{- return $result -}}

View file

@ -6,24 +6,15 @@ gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt t
og:image:alt.
*/ -}}
{{- if not ($.Param "image") -}}
{{- /* Whichever comes first: a Markdown image or a gallery-image shortcode (src and alt in "…" or `…`). */ -}}
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
{{- $alt := index . 0 1 -}}
{{- $dest := index . 0 2 -}}
{{- with index . 0 3 -}}
{{- $dest = "" -}}
{{- $alt = "" -}}
{{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- end -}}
{{- with partialCached "first-page-image.html" . .RelPermalink -}}
{{- $alt := .alt -}}
{{- $dest := .dest -}}
{{- $url := "" -}}
{{- $width := 0 -}}
{{- $height := 0 -}}
{{- $resource := false -}}
{{- $resource := .resource -}}
{{- if findRE `^https?://` $dest -}}
{{- $url = $dest -}}
{{- else -}}
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
{{- end -}}
{{- with $resource -}}
{{- $image := . -}}

View file

@ -81,7 +81,23 @@ so an hour without tours still gets a row.
{{- /* A tour's own title, in the page's language, replaces its page's title. */}}
{{- $ownTitle := "" }}
{{- with .title }}{{ $ownTitle = index . site.Language.Name | default (index . "en") }}{{ end }}
<li class="schedule__card{{ if $soldOut }} schedule__card--soldout{{ end }}" style="--schedule-row: {{ add (index $slotRow .time) $nth }}">
{{- $photo := false }}
{{- $photoAlt := "" }}
{{- $photoCredit := "" }}
{{- with $page }}
{{- with partialCached "first-page-image.html" . .RelPermalink }}
{{- if and .resource .alt }}
{{- if and (eq .resource.ResourceType "image") (ne .resource.MediaType.SubType "svg") }}
{{- $oriented := .resource.Filter images.AutoOrient }}
{{- $side := math.Min 240 $oriented.Width $oriented.Height | int }}
{{- $photo = $oriented.Fill (printf "%dx%d Smart" $side $side) }}
{{- $photoAlt = .alt }}
{{- $photoCredit = .credit }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
<li class="schedule__card{{ if $soldOut }} schedule__card--soldout{{ end }}{{ if $photo }} schedule__card--photo{{ end }}" style="--schedule-row: {{ add (index $slotRow .time) $nth }}">
<span class="schedule__when">
<time class="schedule__time" datetime="{{ $day.date }}T{{ .time }}">{{ .time }}</time>
{{- if $soldOut }}
@ -97,6 +113,12 @@ so an hour without tours still gets a row.
{{- else }}
<span class="schedule__title">{{ $ownTitle | default $entry.tour }}</span>
{{- end }}
{{- with $photo }}
<figure class="schedule__photo">
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="{{ $photoAlt }}" loading="lazy" decoding="async">
{{- with $photoCredit }}<figcaption>{{ . }}</figcaption>{{ end }}
</figure>
{{- end }}
</li>
{{- end }}
</ol>