{{- /* Map of an event's tour locations with routes from the Congress, on OpenStreetMap tiles. Reads the map and tours sections of data/schedule/.yaml (format in README.md). Without JavaScript it shows a list of the locations with links to OpenStreetMap. Usage: {{< tour-map >}} on a section page (the event is the section name), or {{< tour-map 39c3 >}}. */ -}} {{- $event := .Get 0 | default .Page.Section -}} {{- $lang := .Page.Language.Name -}} {{- $other := cond (eq $lang "de") "en" "de" -}} {{- $data := dict -}} {{- with hugo.Data.schedule }}{{ with index . $event }}{{ $data = . }}{{ end }}{{ end -}} {{- /* Tour page titles start with the event name ("39C3 Rote Flora"); the map doesn't need it. */ -}} {{- $prefix := printf `(?i)^%s\s+` $event -}} {{- $tours := slice -}} {{- range $slug, $tour := $data.tours -}} {{- with $tour.geo -}} {{- $title := $slug -}} {{- $url := "" -}} {{- with $.Page.GetPage $slug -}} {{- $title = .LinkTitle | replaceRE $prefix "" -}} {{- $url = .RelPermalink -}} {{- else -}} {{- warnf "tour-map: %s: no page for tour %q" $event $slug -}} {{- end -}} {{- $directions := "" -}} {{- with $tour.directions -}} {{- with index . $lang | default (index . $other) -}} {{- $directions = $.Page.RenderString (dict "display" "block") . -}} {{- end -}} {{- end -}} {{- $tours = $tours | append (dict "title" $title "url" $url "lat" .lat "lon" .lon "color" ($tour.color | default "") "icon" ($tour.icon | default "") "directions" $directions "route" ($tour.route | default slice) ) -}} {{- end -}} {{- end -}} {{- $origin := dict -}} {{- with $data.map }}{{ with .origin }}{{ with .geo -}} {{- $name := "" -}} {{- with $data.map.origin.name }}{{ $name = index . $lang | default (index . $other) }}{{ end -}} {{- $origin = dict "name" $name "lat" .lat "lon" .lon "icon" ($data.map.origin.icon | default "") -}} {{- end }}{{ end }}{{ end -}} {{- if not $tours -}} {{- warnidf "warning-tour-map-empty" "tour-map: no tours with geo in data/schedule/%s.yaml: %s" $event .Position -}} {{- else -}} {{- $tours = sort $tours "title" -}}
{{- end -}}