idokep test 3
This commit is contained in:
@@ -369,84 +369,69 @@ data:
|
||||
- type: custom-api
|
||||
url: https://www.idokep.hu/idojaras/Budapest
|
||||
cache: 15m
|
||||
skip-json-validation: true # CRITICAL: Fixes the JSON error
|
||||
style:
|
||||
grid-column: span 4
|
||||
grid-row: span 3
|
||||
template: |
|
||||
{{/* 1. Extract Current Data */}}
|
||||
{{/* 1. Extract Current Weather Data */}}
|
||||
{{ $body := .Body }}
|
||||
{{ $temp := findSubmatch `(?s)current-temperature">([^˚<]+)` $body | trimSpace }}
|
||||
{{ $cond := findSubmatch `(?s)current-weather">([^<]+)</div>` $body | trimSpace }}
|
||||
{{ $icon := findSubmatch `(?s)forecast-bigicon"[^>]+src="([^"]+)"` $body }}
|
||||
{{ $temp := findSubmatch `current-temperature">([^˚<]+)` $body }}
|
||||
{{ $cond := findSubmatch `current-weather">([^<]+)</div>` $body }}
|
||||
{{ $icon := findSubmatch `forecast-bigicon"[^>]+src="([^"]+)"` $body }}
|
||||
{{ $sunrise := findSubmatch `Napkelte ([0-9:]+)` $body }}
|
||||
{{ $sunset := findSubmatch `Napnyugta ([0-9:]+)` $body }}
|
||||
|
||||
{{/* 2. Extract Daily Forecast (Regex patterns for specific day indices) */}}
|
||||
{{/* Day 1 */}}
|
||||
{{ $d1_pat := `(?s)dailyForecastCol.*?dfDayNum">([0-9]+).*?dfDay">([^<]+).*?src="([^"]+)".*?max[^>]+>([^<]+)</a>.*?min[^>]+>([^<]+)</a>` }}
|
||||
{{ $d1_num := findSubmatch $d1_pat $body }}
|
||||
{{ $d1_day := index (findSubmatch $d1_pat $body) 1 }}
|
||||
{{ $d1_icon := index (findSubmatch $d1_pat $body) 2 }}
|
||||
{{ $d1_max := index (findSubmatch $d1_pat $body) 3 }}
|
||||
{{ $d1_min := index (findSubmatch $d1_pat $body) 4 }}
|
||||
|
||||
{{/* Day 2 (skipping 1 column) */}}
|
||||
{{ $d2_pat := `(?s)dailyForecastCol.*?dailyForecastCol.*?dfDayNum">([0-9]+).*?dfDay">([^<]+).*?src="([^"]+)".*?max[^>]+>([^<]+)</a>.*?min[^>]+>([^<]+)</a>` }}
|
||||
{{ $d2_day := index (findSubmatch $d2_pat $body) 1 }}
|
||||
{{ $d2_icon := index (findSubmatch $d2_pat $body) 2 }}
|
||||
{{ $d2_max := index (findSubmatch $d2_pat $body) 3 }}
|
||||
{{ $d2_min := index (findSubmatch $d2_pat $body) 4 }}
|
||||
|
||||
<style>
|
||||
.idokep-container { background: rgba(0, 0, 0, 0.25); border-radius: 1rem; padding: 1.5rem; color: #fff; font-family: sans-serif; height: 100%; display: flex; flex-direction: column; }
|
||||
.idokep-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
|
||||
.idokep-main { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
|
||||
.idokep-temp { font-size: 3.5rem; font-weight: 800; line-height: 1; }
|
||||
.idokep-subinfo { display: flex; gap: 1rem; font-size: 0.8rem; opacity: 0.7; margin-bottom: 1rem; }
|
||||
.forecast-row { display: grid; grid-template-columns: 3rem 2rem 2.5rem 1fr 2.5rem; align-items: center; gap: 0.75rem; padding: 0.4rem 0; border-top: 1px solid rgba(255,255,255,0.1); }
|
||||
.temp-bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #4ade80, #fbbf24, #f87171); opacity: 0.8; }
|
||||
.idokep-card { background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(10px); border-radius: 1.25rem; padding: 1.5rem; color: #fff; border: 1px solid rgba(255,255,255,0.1); }
|
||||
.idokep-header { display: flex; justify-content: space-between; margin-bottom: 1.5rem; }
|
||||
.idokep-main { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 1.5rem; }
|
||||
.forecast-list { display: flex; flex-direction: column; gap: 0.5rem; border-top: 1px solid rgba(255,255,255,0.1); pt-4; }
|
||||
.forecast-item { display: grid; grid-template-columns: 2.5rem 2rem 2.5rem 1fr 2.5rem; align-items: center; font-size: 0.85rem; }
|
||||
.bar-container { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; margin: 0 8px; position: relative; }
|
||||
.bar-fill { position: absolute; height: 100%; border-radius: 2px; background: linear-gradient(90deg, #60a5fa, #f87171); }
|
||||
</style>
|
||||
|
||||
<div class="idokep-container">
|
||||
<div class="idokep-card">
|
||||
<div class="idokep-header">
|
||||
<div>
|
||||
<div class="text-xl font-bold uppercase tracking-wide">Budapest</div>
|
||||
<div class="text-xs opacity-60">{{ now | formatTime "Monday, Jan 02" }}</div>
|
||||
<div class="text-xl font-bold uppercase tracking-tight">Budapest</div>
|
||||
<div class="text-xs opacity-50">{{ now | formatTime "Monday, Jan 02" }}</div>
|
||||
</div>
|
||||
<div class="text-right text-xs opacity-60">
|
||||
<div>↑ {{ $sunrise }}</div>
|
||||
<div>↓ {{ $sunset }}</div>
|
||||
</div>
|
||||
<div class="idokep-temp">{{ $temp }}°</div>
|
||||
</div>
|
||||
|
||||
<div class="idokep-main">
|
||||
<div class="flex items-center gap-4">
|
||||
<img src="https://www.idokep.hu{{ $icon }}" class="w-16 h-16" alt="weather">
|
||||
<div class="text-lg font-medium">{{ $cond }}</div>
|
||||
<img src="https://www.idokep.hu{{ $icon }}" class="w-16 h-16 object-contain" alt="icon">
|
||||
<div>
|
||||
<div class="text-4xl font-black">{{ $temp }}°</div>
|
||||
<div class="text-sm font-medium opacity-80">{{ $cond }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="idokep-subinfo">
|
||||
<span><i class="fas fa-sun"></i> ↑ {{ $sunrise }}</span>
|
||||
<span><i class="fas fa-moon"></i> ↓ {{ $sunset }}</span>
|
||||
</div>
|
||||
<div class="forecast-list pt-4">
|
||||
{{/* Loop through daily forecast columns found in the HTML */}}
|
||||
{{ $dayBlocks := findAllMatches `(?s)<div class="ik dailyForecastCol">.*?</div>` $body }}
|
||||
{{ range $i, $block := $dayBlocks }}
|
||||
{{ if lt $i 5 }} {{/* Show only next 5 days */}}
|
||||
{{ $d_num := findSubmatch `dfDayNum">([0-9]+)` $block }}
|
||||
{{ $d_name := findSubmatch `dfDay">([^<]+)` $block }}
|
||||
{{ $d_icon := findSubmatch `src="([^"]+)"` $block }}
|
||||
{{ $d_max := findSubmatch `max[^>]+>([^<]+)</a>` $block }}
|
||||
{{ $d_min := findSubmatch `min[^>]+>([^<]+)</a>` $block }}
|
||||
|
||||
{{/* Daily Forecast Rows (Day 1 and 2 shown as examples) */}}
|
||||
<div class="forecast-row">
|
||||
<span class="font-bold">{{ $d1_day }}</span>
|
||||
<img src="https://www.idokep.hu{{ $d1_icon }}" class="w-6 h-6">
|
||||
<span class="text-right text-xs">{{ $d1_min }}°</span>
|
||||
<div class="temp-bar"></div>
|
||||
<span class="font-bold text-xs">{{ $d1_max }}°</span>
|
||||
</div>
|
||||
|
||||
<div class="forecast-row">
|
||||
<span class="font-bold">{{ $d2_day }}</span>
|
||||
<img src="https://www.idokep.hu{{ $d2_icon }}" class="w-6 h-6">
|
||||
<span class="text-right text-xs">{{ $d2_min }}°</span>
|
||||
<div class="temp-bar" style="width: 80%"></div>
|
||||
<span class="font-bold text-xs">{{ $d2_max }}°</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-auto pt-4 text-center">
|
||||
<a href="https://www.idokep.hu/elorejelzes/Budapest" class="text-[10px] uppercase opacity-40 hover:opacity-100 transition-opacity">idokep.hu 30 napos →</a>
|
||||
<div class="forecast-item py-1">
|
||||
<span class="font-bold opacity-90">{{ $d_num }} {{ $d_name }}</span>
|
||||
<img src="https://www.idokep.hu{{ $d_icon }}" class="w-6 h-6 mx-auto">
|
||||
<span class="text-right text-xs opacity-60">{{ $d_min }}°</span>
|
||||
<div class="bar-container"><div class="bar-fill" style="left: 20%; width: 60%;"></div></div>
|
||||
<span class="text-left text-xs font-bold">{{ $d_max }}°</span>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user