diff --git a/CLAUDE.md b/CLAUDE.md index f203d36..30ed931 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -137,7 +137,8 @@ The site implements **comprehensive JSON-LD schemas** across three layers: - `layouts/partials/about.html` — About section with feature cards from `site.yml` - `layouts/partials/sponsors-home.html` — Homepage sponsor logos by tier - `layouts/partials/venue-home.html` — Venue showcase -- `layouts/partials/tickets.html` — Dynamic pricing cards from `hugo.toml` params +- `layouts/partials/tickets.html` — Tito ticket widget; the `js.tito.io` script is loaded here only, not site-wide +- `layouts/partials/tito-data.html` — Fetches ticket names, prices and sale state from Tito at build time (use with `partialCached`) - `layouts/partials/stats.html` — Animated statistics counters - `layouts/partials/keynotes.html` — Featured keynote speakers - `layouts/partials/speaker-card.html` — Reusable speaker card component @@ -155,7 +156,7 @@ Commented out (pending content): Keynotes, Sponsors, Tickets, Newsletter CTA - `[params]` — Conference details (dates, venue, contact, social). Key social params: `twitterHandle`, `mastodonHandle` (`@Python_Ireland`), `mastodonUrl` (`https://mastodon.ie/@Python_Ireland` — instance is mastodon.ie, not mastodon.social), `youtubeUrl` - `[params.hero]` — Hero section content - `[params.stats]` — Statistics for counters (attendees, speakers, tracks, days) -- `[[params.tickets]]` — Ticket types with pricing (Student, Early Bird, General, Corporate) +- `ticketsUrl` — Tito event URL (`https://ti.to//`). Ticket prices are **not** stored in `hugo.toml`: they come from Tito's public checkout endpoint at build time and feed the homepage price range and the Event `offers` JSON-LD - `[menus.main]` — Navigation menu items (Sponsors menu currently commented out) **Build configuration:** @@ -319,11 +320,10 @@ Commit message style: Keynote {{ end }} -{{ if .Site.Params.tickets }} - {{ range .Site.Params.tickets }} - {{ if .highlight }} -
...
- {{ end }} +{{ $tito := partialCached "tito-data.html" . }} +{{ if $tito.ok }} + {{ range $tito.releases }} +

{{ .name }}: {{ $tito.currencySymbol }}{{ .priceLabel }}

{{ end }} {{ end }} ``` diff --git a/csp-dynamic-loaders.yml b/csp-dynamic-loaders.yml index 4472ab0..631b373 100644 --- a/csp-dynamic-loaders.yml +++ b/csp-dynamic-loaders.yml @@ -32,3 +32,15 @@ also-loads: - directive: font-src domain: fonts.gstatic.com # actual font files served from gstatic + +- name: Tito ticket widget + trigger: + directive: script-src + domain: js.tito.io + also-loads: + - directive: style-src + domain: js.tito.io # widget CSS injected by https://js.tito.io/v2 + - directive: frame-src + domain: js.tito.io # widget and checkout overlay iframes + - directive: connect-src + domain: checkout.tito.io # event/ticket JSON fetched by the widget diff --git a/hugo.toml b/hugo.toml index fb39f76..43f318c 100644 --- a/hugo.toml +++ b/hugo.toml @@ -56,7 +56,7 @@ enableGitInfo = true cfpUrl = "https://sessionize.com/pycon-ireland-2026/" cfpOpens = "2026-05-25" cfpCloses = "2026-08-30" - ticketsUrl = "https://ti.to/python-ireland/pycon-ireland-2026" # Set to Tito/Eventbrite URL when tickets go on sale + ticketsUrl = "https://ti.to/python-ireland/pycon-ireland-2026" # Tito event URL; ticket names, prices and availability are fetched from Tito at build time ticketsValidFrom = "2026-10-01" # Date pricing tiers were announced; required by Google's Offer.validFrom check # Contact & social @@ -84,34 +84,6 @@ enableGitInfo = true tracks = 3 days = 1 - [[params.tickets]] - name = "Student" - price = 35 - currency = "EUR" - features = ["Full conference access", "Lunch & refreshments", "Community networking"] - highlight = false - - # [[params.tickets]] - # name = "Early Bird" - # price = 49 - # currency = "EUR" - # features = ["Full conference access", "Lunch & refreshments", "Conference t-shirt", "Workshop access"] - # highlight = true - - [[params.tickets]] - name = "General" - price = 59 - currency = "EUR" - features = ["Full conference access", "Lunch & refreshments", "Workshop access"] - highlight = false - - [[params.tickets]] - name = "Corporate" - price = 159 - currency = "EUR" - features = ["Full conference access", "Lunch & refreshments", "Workshop access", "Priority seating", "Networking reception"] - highlight = false - [menus] [[menus.main]] name = "Tickets" @@ -186,3 +158,8 @@ enableGitInfo = true name = "Blog" url = "/blog/" weight = 70 + +# Remote resources (Tito ticket data) are cached by Hugo; keep it short so a +# local `hugo server` does not show stale prices forever. +[caches.getresource] + maxAge = "1h" diff --git a/layouts/index.html b/layouts/index.html index b33d752..10d659e 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -26,10 +26,16 @@ Learn more {{ end }} + {{- with partialCached "tito-data.html" . }}{{ if .ok }} - Tickets from €{{ (index .Site.Params.tickets 0).price }} to €{{ (index .Site.Params.tickets (sub (len .Site.Params.tickets) 1)).price }} + {{- if eq .minPrice .maxPrice }} + Tickets {{ .currencySymbol }}{{ .minPrice }} + {{- else }} + Tickets from {{ .currencySymbol }}{{ .minPrice }} to {{ .currencySymbol }}{{ .maxPrice }} + {{- end }} + {{- end }}{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index bea7192..df95def 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -71,5 +71,10 @@ {{/* Structured Data / Schema.org */}} {{ partial "structured-data.html" . }} -{{/* Tito tickets */}} - +{{/* Tito tickets: only the homepage renders the widget (partials/tickets.html). + Kept in : loading it next to the widget in left the widget + empty in some Firefox setups. */}} +{{ if .IsHome }}{{ with (partialCached "tito-data.html" .).slug }} + +{{ end }}{{ end }} + diff --git a/layouts/partials/structured-data.html b/layouts/partials/structured-data.html index 44be968..7d37634 100644 --- a/layouts/partials/structured-data.html +++ b/layouts/partials/structured-data.html @@ -65,17 +65,24 @@ "organizer": { "@type": "Organization", "@id": "{{ .Site.Params.organizerUrl }}#organization" - }, - "offers": { - "@type": "AggregateOffer", - "lowPrice": {{ (index .Site.Params.tickets 0).price }}, - "highPrice": {{ (index .Site.Params.tickets (sub (len .Site.Params.tickets) 1)).price }}, - "offerCount": {{ len .Site.Params.tickets }}, - "priceCurrency": "EUR", - "url": "{{ if .Site.Params.ticketsUrl }}{{ .Site.Params.ticketsUrl }}{{ else }}{{ .Site.BaseURL }}{{ end }}", - "availability": "https://schema.org/PreOrder", - "validFrom": "{{ .Site.Params.ticketsValidFrom }}" } + {{- $tito := partialCached "tito-data.html" . }} + {{- if $tito.ok }} + {{- $offers := slice }} + {{- range $tito.releases }} + {{- $offer := dict + "@type" "Offer" + "name" .name + "price" (printf "%.2f" .price) + "priceCurrency" $tito.currency + "url" site.Params.ticketsUrl + "validFrom" site.Params.ticketsValidFrom + }} + {{- with .availability }}{{ $offer = merge $offer (dict "availability" .) }}{{ end }} + {{- $offers = $offers | append $offer }} + {{- end }}, + "offers": {{ $offers | jsonify | safeJS }} + {{- end }} } {{ end }} diff --git a/layouts/partials/tickets.html b/layouts/partials/tickets.html index 1ef9138..c864477 100644 --- a/layouts/partials/tickets.html +++ b/layouts/partials/tickets.html @@ -1,3 +1,4 @@ +{{- $tito := partialCached "tito-data.html" . -}}
@@ -6,11 +7,14 @@

Tickets

Secure your spot at {{ .Site.Title }}. Buy your tickets from Tito. + target="_blank" rel="noopener">Tito.

- + {{- with $tito.slug }} + {{- /* The js.tito.io script is loaded from head.html, on the homepage only */}} + + {{- end }}
diff --git a/layouts/partials/tito-data.html b/layouts/partials/tito-data.html new file mode 100644 index 0000000..642c14d --- /dev/null +++ b/layouts/partials/tito-data.html @@ -0,0 +1,71 @@ +{{- /* + Ticket data fetched from Tito at build time. + + Tito is the single source of truth for ticket names, prices and sale state. + The event slug is derived from site.Params.ticketsUrl + (https://ti.to//), and the public checkout endpoint used by + the Tito widget itself is queried: https://checkout.tito.io/.json + + Returns a dict: + ok bool false if ticketsUrl is unset or Tito is unreachable + slug string "/" (set whenever ticketsUrl is set) + currency string ISO code, e.g. "EUR" + currencySymbol string e.g. "€" + releases slice dicts: name, price (float), priceLabel, state, availability + minPrice string formatted lowest price (no currency symbol) + maxPrice string formatted highest price + + A Tito outage must not break the build: on error a warning is logged and + callers hide price information. + + Use with partialCached so Tito is queried once per build. +*/ -}} +{{- $result := dict "ok" false "slug" "" -}} +{{- with site.Params.ticketsUrl -}} + {{- $slug := . | strings.TrimPrefix "https://ti.to/" | strings.TrimSuffix "/" -}} + {{- $result = merge $result (dict "slug" $slug) -}} + {{- $api := printf "https://checkout.tito.io/%s.json" $slug -}} + {{- $remote := try (resources.GetRemote $api) -}} + {{- with $remote.Err -}} + {{- warnf "tito-data: cannot fetch %s: %s" $api . -}} + {{- else with $remote.Value -}} + {{- $event := (. | transform.Unmarshal).event -}} + {{- $availability := dict + "on_sale" "https://schema.org/InStock" + "sold_out" "https://schema.org/SoldOut" + "upcoming" "https://schema.org/PreOrder" + -}} + {{- $releases := slice -}} + {{- $prices := slice -}} + {{- range $event.releases -}} + {{- $price := float .price -}} + {{- $label := cond (eq $price (math.Floor $price)) (printf "%.0f" $price) (printf "%.2f" $price) -}} + {{- $releases = $releases | append (dict + "name" .title + "price" $price + "priceLabel" $label + "state" .state + "availability" (index $availability .state | default "") + ) -}} + {{- $prices = $prices | append $price -}} + {{- end -}} + {{- if $releases -}} + {{- $min := math.Min $prices -}} + {{- $max := math.Max $prices -}} + {{- $result = merge $result (dict + "ok" true + "currency" $event.currency + "currencySymbol" $event.currency_symbol + "releases" $releases + "minPrice" (cond (eq $min (math.Floor $min)) (printf "%.0f" $min) (printf "%.2f" $min)) + "maxPrice" (cond (eq $max (math.Floor $max)) (printf "%.0f" $max) (printf "%.2f" $max)) + ) -}} + {{- else -}} + {{- warnf "tito-data: no releases returned by %s" $api -}} + {{- end -}} + {{- else -}} + {{- /* resources.GetRemote returns nil without error on a 404 */ -}} + {{- warnf "tito-data: %s not found (check params.ticketsUrl)" $api -}} + {{- end -}} +{{- end -}} +{{- return $result -}}