# -*- coding: utf-8 -*- """Dashboard pictures on the website (2026-10-08): a home-page section after „Mit tud a doboz ma?" and two pictures in the technology page's dashboard card, each page in its own language. Reads the CURRENT pages; every insert asserts its anchor once.""" import io, os, re, sys W = "/mnt/5_hdd/felhom.eu/git/felhom.eu/website" def rd(p): return io.open(os.path.join(W, p), encoding="utf-8-sig").read() def wr(p, s): with io.open(os.path.join(W, p), "w", encoding="utf-8-sig", newline="\n") as f: f.write(s) def sub1(s, old, new): assert s.count(old) == 1, (old[:80], s.count(old)); return s.replace(old, new) SHOTS = { # page: (hu alt, hu caption, en alt, en caption) "start": ("A vezérlőpult Indítópultja: az otthon telepített alkalmazások csempéi", "Indítópult — minden alkalmazásod egy kattintásra.", "The Dashboard's Launcher: tiles of the apps installed at home", "Launcher — every app you have, one click away."), "apps": ("Az Alkalmazások oldal: telepített és telepíthető alkalmazások kártyái, állapottal", "Alkalmazások — telepítés pár kattintással, és látod, mi fut és mi naprakész.", "The Apps page: cards of installed and installable apps, with their status", "Apps — install in a few clicks, and see what runs and what is up to date."), "app": ("Egy alkalmazás saját oldala: mire jó, képek, és az első lépések", "Egy alkalmazás oldala — mire jó, hova tedd a fájlokat, és hogyan kezdj hozzá.", "An app's own page: what it is for, pictures, and the first steps", "An app's page — what it is for, where your files go, and how to start."), "backups": ("A mentések oldala: minden alkalmazás adatbázisának éjszakai mentése, ellenőrizve", "Mentések — minden éjjel minden alkalmazás adatbázisa mentésre kerül, és ellenőrizzük.", "The backups page: each app's database backed up overnight, and checked", "Backups — every night each app's database is backed up and checked."), } def fig(page, lang): hu_alt, hu_cap, en_alt, en_cap = SHOTS[page] alt, cap = (hu_alt, hu_cap) if lang == "hu" else (en_alt, en_cap) src = "/assets/dashboard-%s-%s.webp" % (page, lang) return ('
\n' ' %s\n' '
%s
\n' '
') % (src, src, alt, cap) def home_section(lang): if lang == "hu": sid, h2, sub = "vezerlopult", "Így néz ki a vezérlőpult", "Valódi képek egy Felhom dobozról — kattints rájuk a teljes mérethez" else: sid, h2, sub = "dashboard", "What the Dashboard looks like", "Real pictures from a Felhom box — click one for the full size" figs = "\n".join(fig(p, lang) for p in ("start", "apps", "app", "backups")) return ('
\n
\n' '
\n

%s

\n

%s

\n
\n' '
\n%s\n
\n
\n
\n\n') % (sid, h2, sub, figs) ANCHOR_HOME = '
\n' for p, lang in (("index.html", "hu"), ("en/index.html", "en")): s = rd(p) i = s.index('id="mit-tud"' if lang == "hu" else 'id="what-it-does"') j = s.index(ANCHOR_HOME, i) s = s[:j] + home_section(lang) + s[j:] wr(p, s) print(p, "section added") TECH_ANCHOR = {"hu": '
\n

Tökéletes:', "en": '

\n

Good for:'} for p, lang in (("technologiak.html", "hu"), ("en/technology.html", "en")): s = rd(p) block = ('

\n%s\n
\n\n' % "\n".join(" " + l for f in (fig("apps", lang), fig("backups", lang)) for l in f.split("\n"))) s = sub1(s, TECH_ANCHOR[lang], block + TECH_ANCHOR[lang]) wr(p, s) print(p, "pictures added")