diff --git a/glance-system/glance-kisfenyo.yaml b/glance-system/glance-kisfenyo.yaml index 77ad8f4..c3fbb90 100644 --- a/glance-system/glance-kisfenyo.yaml +++ b/glance-system/glance-kisfenyo.yaml @@ -630,13 +630,18 @@ data: - type: custom-api title: Meal for the Day cache: 1d - url: ${TANDOOR_URL}/api/recipe/flat/ + + # Use the endpoint that definitely exists in your Tandoor + url: ${TANDOOR_URL}/api/recipe/ headers: Accept: application/json Authorization: Bearer ${TANDOOR_TOKEN} - # We use Prometheus just to get a stable "today" number (Unix time), - # so the 3 picks are deterministic for the day. + # Pass base url into template (NO env() needed) + options: + base_url: ${TANDOOR_URL} + + # Use Prometheus time() to make the pick stable for the day subrequests: epoch: url: ${PROMETHEUS_URL}/api/v1/query @@ -645,71 +650,32 @@ data: template: | - {{ $recipes := .JSON.Array "" }} - {{ $n := len $recipes }} + {{ $base := .Options.String "base_url" }} + {{/* Handle both: array response OR paginated {results:[...]} */}} + {{ $recipes := .JSON.Array "results" }} + {{ if eq (len $recipes) 0 }} + {{ $recipes = .JSON.Array "" }} + {{ end }} + + {{ $n := len $recipes }} {{ if lt $n 1 }}
No recipes returned from Tandoor.
Check token / permissions - Open Tandoor + Open Tandoor
{{ else }} @@ -717,7 +683,6 @@ data: {{ $epoch := (.Subrequest "epoch").JSON.Float "data.result.0.value.1" }} {{ $day := div $epoch 86400.0 | toInt }} - {{/* pick a "base" index for today; then next 2 indices */}} {{ $i0 := mod $day $n }} {{ $i1 := mod (add $i0 1) $n }} {{ $i2 := mod (add $i0 2) $n }} @@ -726,17 +691,10 @@ data: {{ $r1 := index $recipes $i1 }} {{ $r2 := index $recipes $i2 }} - {{ $base := env "TANDOOR_URL" }} - - {{/* helper: ensure absolute image URL */}} + {{/* images are already absolute in your API output */}} {{ $img0 := $r0.String "image" }} - {{ if and $img0 (not (hasPrefix "http" $img0)) }}{{ $img0 = print $base $img0 }}{{ end }} - {{ $img1 := $r1.String "image" }} - {{ if and $img1 (not (hasPrefix "http" $img1)) }}{{ $img1 = print $base $img1 }}{{ end }} - {{ $img2 := $r2.String "image" }} - {{ if and $img2 (not (hasPrefix "http" $img2)) }}{{ $img2 = print $base $img2 }}{{ end }}
@@ -745,40 +703,31 @@ data:
- {{/* Slide 1 */}} - {{/* Slide 2 */}} - {{/* Slide 3 */}}
- {{ end }} + # ---------- CENTER COLUMN ---------- - size: full widgets: