From eaca23b39588ec918200fccf004077a3cbdb4d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Wed, 18 Nov 2026 20:42:50 +0100 Subject: [PATCH 1/2] Load Tito widget on homepage only and source ticket prices from Tito - Move the js.tito.io script from head.html (every page) into partials/tickets.html, next to the widget, so other pages no longer download ~10 Tito JS/CSS files - Add partials/tito-data.html: fetch ticket names, prices and sale state from Tito's public checkout endpoint at build time; a Tito outage or bad slug logs a warning and hides prices instead of failing the build - Derive the widget event slug from params.ticketsUrl instead of hardcoding it - Homepage price range now comes from Tito - Event JSON-LD: one Offer per Tito release with real availability (InStock/SoldOut/PreOrder) instead of an AggregateOffer hardcoded to PreOrder - Remove [[params.tickets]] from hugo.toml (stale prices and features not offered on Tito); cap the getresource cache at 1h - Drop rel="me" from the Tito link (identity-verification attribute) - Declare Tito in csp-dynamic-loaders.yml (style-src, frame-src, connect-src) so the CSP checker guards the widget - Update CLAUDE.md accordingly --- CLAUDE.md | 14 +++--- csp-dynamic-loaders.yml | 12 +++++ hugo.toml | 35 +++---------- layouts/index.html | 8 ++- layouts/partials/head.html | 2 - layouts/partials/structured-data.html | 27 ++++++---- layouts/partials/tickets.html | 9 +++- layouts/partials/tito-data.html | 71 +++++++++++++++++++++++++++ 8 files changed, 127 insertions(+), 51 deletions(-) create mode 100644 layouts/partials/tito-data.html 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..1456898 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -71,5 +71,3 @@ {{/* Structured Data / Schema.org */}} {{ partial "structured-data.html" . }} -{{/* Tito tickets */}} - 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..a0b0ab1 100644 --- a/layouts/partials/tickets.html +++ b/layouts/partials/tickets.html @@ -1,3 +1,4 @@ +{{- $tito := partialCached "tito-data.html" . -}}
@@ -6,11 +7,15 @@

Tickets

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

- + {{- with $tito.slug }} + + {{- /* Loaded here rather than in so only the page showing the widget pays for it */}} + + {{- 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 -}} From d24ba3d05513358161b71a2f7756756eea24ab84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Wed, 18 Nov 2026 20:49:34 +0100 Subject: [PATCH 2/2] Load Tito script from on the homepage only Loading js.tito.io next to the widget in left the widget empty in some Firefox setups (reproduced on the deploy preview, while the same browser renders it fine when the script is in ). Keep the script in , but only on the homepage, which is the only page rendering the widget. --- layouts/partials/head.html | 7 +++++++ layouts/partials/tickets.html | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 1456898..df95def 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -71,3 +71,10 @@ {{/* Structured Data / Schema.org */}} {{ partial "structured-data.html" . }} +{{/* 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/tickets.html b/layouts/partials/tickets.html index a0b0ab1..c864477 100644 --- a/layouts/partials/tickets.html +++ b/layouts/partials/tickets.html @@ -12,9 +12,8 @@

Tickets

{{- with $tito.slug }} + {{- /* The js.tito.io script is loaded from head.html, on the homepage only */}} - {{- /* Loaded here rather than in so only the page showing the widget pays for it */}} - {{- end }}