added daily meal
This commit is contained in:
@@ -627,6 +627,158 @@ data:
|
|||||||
url: https://pihole.dooplex.hu/admin
|
url: https://pihole.dooplex.hu/admin
|
||||||
icon: si:pihole
|
icon: si:pihole
|
||||||
|
|
||||||
|
- type: custom-api
|
||||||
|
title: Meal for the Day
|
||||||
|
cache: 1d
|
||||||
|
url: ${TANDOOR_URL}/api/recipe/flat/
|
||||||
|
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.
|
||||||
|
subrequests:
|
||||||
|
epoch:
|
||||||
|
url: ${PROMETHEUS_URL}/api/v1/query
|
||||||
|
parameters:
|
||||||
|
query: time()
|
||||||
|
|
||||||
|
template: |
|
||||||
|
<style>
|
||||||
|
.mealwrap { display: flex; flex-direction: column; gap: 10px; }
|
||||||
|
.mealmeta { opacity: .65; font-size: 12px; display:flex; justify-content: space-between; align-items:center; }
|
||||||
|
.mealmeta a { opacity: .9; }
|
||||||
|
|
||||||
|
.mealscroller {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
overflow-x: auto;
|
||||||
|
scroll-snap-type: x mandatory;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
.mealscroller::-webkit-scrollbar { height: 8px; }
|
||||||
|
.mealscroller::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(255,255,255,0.18); }
|
||||||
|
.mealscroller::-webkit-scrollbar-track { background: rgba(255,255,255,0.06); border-radius: 999px; }
|
||||||
|
|
||||||
|
.mealslide {
|
||||||
|
min-width: 100%;
|
||||||
|
scroll-snap-align: start;
|
||||||
|
border-radius: 14px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mealimg {
|
||||||
|
height: 150px;
|
||||||
|
background: rgba(0,0,0,0.15);
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
.mealimg img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
.mealnoimg { opacity:.55; font-size: 12px; padding: 18px; text-align:center; }
|
||||||
|
|
||||||
|
.mealname {
|
||||||
|
padding: 10px 12px 12px 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
opacity: .95;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.meallink {
|
||||||
|
display:block;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{{ $recipes := .JSON.Array "" }}
|
||||||
|
{{ $n := len $recipes }}
|
||||||
|
|
||||||
|
{{ if lt $n 1 }}
|
||||||
|
<div class="mealwrap">
|
||||||
|
<div class="color-negative">No recipes returned from Tandoor.</div>
|
||||||
|
<div class="mealmeta">
|
||||||
|
<span>Check token / permissions</span>
|
||||||
|
<a href="{{ .Options.StringOr "tandoor-url" (print (env "TANDOOR_URL")) }}" target="_blank" rel="noreferrer">Open Tandoor</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ else }}
|
||||||
|
|
||||||
|
{{ $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 }}
|
||||||
|
|
||||||
|
{{ $r0 := index $recipes $i0 }}
|
||||||
|
{{ $r1 := index $recipes $i1 }}
|
||||||
|
{{ $r2 := index $recipes $i2 }}
|
||||||
|
|
||||||
|
{{ $base := env "TANDOOR_URL" }}
|
||||||
|
|
||||||
|
{{/* helper: ensure absolute image URL */}}
|
||||||
|
{{ $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 }}
|
||||||
|
|
||||||
|
<div class="mealwrap">
|
||||||
|
<div class="mealmeta">
|
||||||
|
<span>Today’s picks ({{ printf "%d" $n }} total)</span>
|
||||||
|
<a href="{{ $base }}" target="_blank" rel="noreferrer">Open Tandoor</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mealscroller">
|
||||||
|
{{/* Slide 1 */}}
|
||||||
|
<div class="mealslide">
|
||||||
|
<a class="meallink" href="{{ $base }}/recipe/{{ $r0.Int "id" }}" target="_blank" rel="noreferrer">
|
||||||
|
<div class="mealimg">
|
||||||
|
{{ if $img0 }}<img src="{{ $img0 }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||||
|
</div>
|
||||||
|
<div class="mealname">{{ $r0.String "name" }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{/* Slide 2 */}}
|
||||||
|
<div class="mealslide">
|
||||||
|
<a class="meallink" href="{{ $base }}/recipe/{{ $r1.Int "id" }}" target="_blank" rel="noreferrer">
|
||||||
|
<div class="mealimg">
|
||||||
|
{{ if $img1 }}<img src="{{ $img1 }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||||
|
</div>
|
||||||
|
<div class="mealname">{{ $r1.String "name" }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{/* Slide 3 */}}
|
||||||
|
<div class="mealslide">
|
||||||
|
<a class="meallink" href="{{ $base }}/recipe/{{ $r2.Int "id" }}" target="_blank" rel="noreferrer">
|
||||||
|
<div class="mealimg">
|
||||||
|
{{ if $img2 }}<img src="{{ $img2 }}" alt="" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||||
|
</div>
|
||||||
|
<div class="mealname">{{ $r2.String "name" }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
# ---------- CENTER COLUMN ----------
|
# ---------- CENTER COLUMN ----------
|
||||||
- size: full
|
- size: full
|
||||||
widgets:
|
widgets:
|
||||||
@@ -2069,6 +2221,10 @@ spec:
|
|||||||
value: "http://uptimekuma.uptimekuma-system.svc.cluster.local:3001"
|
value: "http://uptimekuma.uptimekuma-system.svc.cluster.local:3001"
|
||||||
- name: UPTIME_KUMA_STATUS_SLUG
|
- name: UPTIME_KUMA_STATUS_SLUG
|
||||||
value: "homepage"
|
value: "homepage"
|
||||||
|
- name: TANDOOR_URL
|
||||||
|
value: "https://tandoor.dooplex.hu"
|
||||||
|
- name: TANDOOR_TOKEN
|
||||||
|
value: "tda_069f4aa1_ed21_454c_987f_641a523a6cdc"
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
containerPort: 8080
|
containerPort: 8080
|
||||||
|
|||||||
Reference in New Issue
Block a user