diff --git a/admin-server.js b/admin-server.js index 45c688e..89d723c 100644 --- a/admin-server.js +++ b/admin-server.js @@ -15,10 +15,17 @@ const DATA_FILE = path.join(__dirname, 'data/gallery.json'); const HOMEPAGE_FILE = path.join(__dirname, 'data/homepage.json'); const CATEGORIES_FILE = path.join(__dirname, 'data/categories.json'); const UEBERMICH_FILE = path.join(__dirname, 'data/uebermich.json'); +const ERFOLGE_FILE = path.join(__dirname, 'data/erfolge.json'); +const ERFOLGE_IMG_DIR = path.join(__dirname, 'static/erfolge-img'); +const GALERIE_PAGE_FILE = path.join(__dirname, 'data/galerie.json'); +const GAESTEBUCH_FILE = path.join(__dirname, 'data/gaestebuch.json'); +const GLOBAL_FILE = path.join(__dirname, 'data/global.json'); +const GAESTEBUCH_IMG_DIR = path.join(__dirname, 'static/gaestebuch-img'); if (!fs.existsSync(UEBERMICH_IMG_DIR)) fs.mkdirSync(UEBERMICH_IMG_DIR, { recursive: true }); - if (!fs.existsSync(HERO_DIR)) fs.mkdirSync(HERO_DIR, { recursive: true }); +if (!fs.existsSync(ERFOLGE_IMG_DIR)) fs.mkdirSync(ERFOLGE_IMG_DIR, { recursive: true }); +if (!fs.existsSync(GAESTEBUCH_IMG_DIR)) fs.mkdirSync(GAESTEBUCH_IMG_DIR, { recursive: true }); app.use(express.json()); app.use('/images', express.static(IMAGES_DIR)); @@ -164,9 +171,14 @@ function rebuildAndDeploy() { app.put('/api/homepage', (req, res) => { const hp = readHomepage(); + if (req.body.siteTitle !== undefined) hp.siteTitle = req.body.siteTitle; if (req.body.badge !== undefined) hp.hero.badge = req.body.badge; if (req.body.description !== undefined) hp.hero.description = req.body.description; if (req.body.stats !== undefined) hp.stats = req.body.stats; + if (req.body.hero_karte !== undefined) hp.hero_karte = req.body.hero_karte; + if (req.body.pruefung_karte !== undefined) hp.pruefung_karte = req.body.pruefung_karte; + if (req.body.dojo_karte !== undefined) hp.dojo_karte = req.body.dojo_karte; + if (req.body.cta !== undefined) hp.cta = req.body.cta; writeHomepage(hp); res.json({ ok: true }); rebuildAndDeploy(); @@ -191,6 +203,8 @@ app.post('/api/homepage/image', upload.single('image'), async (req, res) => { app.use('/hero', express.static(HERO_DIR)); app.use('/uebermich', express.static(UEBERMICH_IMG_DIR)); +app.use('/erfolge-img', express.static(ERFOLGE_IMG_DIR)); +app.use('/gaestebuch-img', express.static(GAESTEBUCH_IMG_DIR)); // Über mich API function readUebermich() { @@ -228,6 +242,87 @@ app.post('/api/uebermich/image', upload.single('image'), async (req, res) => { } }); +// ── Erfolge API ─────────────────────────────────────────────── +function readErfolge() { + return JSON.parse(fs.readFileSync(ERFOLGE_FILE, 'utf8')); +} +function writeErfolge(data) { + fs.writeFileSync(ERFOLGE_FILE, JSON.stringify(data, null, 2)); +} + +app.get('/api/erfolge', (req, res) => { + res.json(readErfolge()); +}); + +app.put('/api/erfolge', (req, res) => { + writeErfolge(req.body); + res.json({ ok: true }); + rebuildAndDeploy(); +}); + +app.post('/api/erfolge/image', upload.single('image'), async (req, res) => { + try { + const filename = 'hero.webp'; + await sharp(req.file.buffer) + .resize(1200, 1500, { fit: 'inside', withoutEnlargement: true }) + .webp({ quality: 88 }) + .toFile(path.join(ERFOLGE_IMG_DIR, filename)); + const data = readErfolge(); + data.hero.image = filename; + writeErfolge(data); + res.json({ ok: true, image: filename }); + rebuildAndDeploy(); + } catch (e) { + res.status(500).json({ ok: false, error: e.message }); + } +}); + +// ── Galerie Seiten-Texte API ────────────────────────────────── +app.get('/api/galerie', (req, res) => { + res.json(JSON.parse(fs.readFileSync(GALERIE_PAGE_FILE, 'utf8'))); +}); +app.put('/api/galerie', (req, res) => { + fs.writeFileSync(GALERIE_PAGE_FILE, JSON.stringify(req.body, null, 2)); + res.json({ ok: true }); + rebuildAndDeploy(); +}); + +// ── Gästebuch API ───────────────────────────────────────────── +app.get('/api/gaestebuch', (req, res) => { + res.json(JSON.parse(fs.readFileSync(GAESTEBUCH_FILE, 'utf8'))); +}); +app.put('/api/gaestebuch', (req, res) => { + fs.writeFileSync(GAESTEBUCH_FILE, JSON.stringify(req.body, null, 2)); + res.json({ ok: true }); + rebuildAndDeploy(); +}); +app.post('/api/gaestebuch/image', upload.single('image'), async (req, res) => { + try { + const filename = 'hero.webp'; + await sharp(req.file.buffer) + .resize(1400, 600, { fit: 'cover', position: 'center' }) + .webp({ quality: 88 }) + .toFile(path.join(GAESTEBUCH_IMG_DIR, filename)); + const data = JSON.parse(fs.readFileSync(GAESTEBUCH_FILE, 'utf8')); + data.hero.image = filename; + fs.writeFileSync(GAESTEBUCH_FILE, JSON.stringify(data, null, 2)); + res.json({ ok: true, image: filename }); + rebuildAndDeploy(); + } catch (e) { + res.status(500).json({ ok: false, error: e.message }); + } +}); + +// ── Global (Social Links) API ───────────────────────────────── +app.get('/api/global', (req, res) => { + res.json(JSON.parse(fs.readFileSync(GLOBAL_FILE, 'utf8'))); +}); +app.put('/api/global', (req, res) => { + fs.writeFileSync(GLOBAL_FILE, JSON.stringify(req.body, null, 2)); + res.json({ ok: true }); + rebuildAndDeploy(); +}); + // Admin-UI app.get('/', (req, res) => { res.sendFile(path.join(__dirname, 'admin.html')); diff --git a/admin.html b/admin.html index 4016ca1..28eb2de 100644 --- a/admin.html +++ b/admin.html @@ -103,7 +103,7 @@ tailwind.config = { bolt
-

MiyaKarate

+

MiyaKarate

Admin Panel

@@ -178,7 +178,7 @@ tailwind.config = {
M
- MiyaKarate + MiyaKarate
@@ -265,6 +265,46 @@ tailwind.config = { + +

Hero-Karte (Rang auf dem Bild)

+
+
+ + +
+
+ + +
+
+ + +

Prüfungs-Karte (pinke Box)

+
+
+ + +
+
+ + +
+
+ + +

Dojo-Karte (graue Box)

+
+
+ + +
+
+ + +
+
+ + +

Galerie-CTA (dunkler Bereich)

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ -

Statistik-Boxen

@@ -517,22 +581,245 @@ tailwind.config = {

E-Mail

-

hallo@miyakarate.de

+

{{ $gb.kontakt.email }}

@@ -163,7 +167,7 @@

Dojo

-

Kiai Dojo Berlin

+

{{ $gb.kontakt.dojo }}

@@ -175,23 +179,18 @@

Neuester Eintrag

Alle ansehen + {{ with index $gb.eintraege 0 }}
-
- Gast Avatar -
+
{{ substr .name 0 1 }}
-

Jonas L.

-

vor 2 Stunden

+

{{ .name }}

+

{{ .rolle }}

-

"Mega Fortschritte bei deiner letzten Kata! Deine Hingabe ist wirklich inspirierend. Weiter so! Oss!"

-
- Teamkamerad - Inspiriert -
+

"{{ .text }}"

+ {{ end }} @@ -203,81 +202,33 @@

Nachrichten von Trainingspartnern, Familie und Freunden aus aller Welt.

-
-
-
- Gast -
+ {{ range $gb.eintraege }} + {{ $span := "" }}{{ if .breit }}{{ $span = "md:col-span-2" }}{{ end }} + {{ if eq .farbe "secondary" }} +
+
+
{{ substr .name 0 1 }}
-

Trainerin Elena

-

Sensei

+

{{ .name }}

+

{{ .rolle }}

+
+
+
"{{ .text }}"
+
+ {{ else }} +
+
+
{{ substr .name 0 1 }}
+
+

{{ .name }}

+

{{ .rolle }}

favorite
-

Deine Konzentration beim letzten Grading war außergewöhnlich. Die Körperkontrolle, die du entwickelst, ist selten für dein Alter. Ich bin stolz auf dich!

+

{{ .text }}

- -
-
-
- Gast -
-
-

Opa Karl

-

Familie

-
-
-

Wir drücken dir von zuhause alle die Daumen! Kann es kaum erwarten, den nächsten Pokal auf dem Regal zu sehen!

-
- -
-
-
- Gast -
-
-

Lea M.

-

Freundin

-
-
-

Die Website sieht so professionell aus! Mega cool, alle deine Erfolge an einem Ort zu sehen. Wir müssen bald mal wieder eis essen gehen!

-
- -
-
-
T
-
-

Trainer Thomas

-

Dojo Kiai Berlin

-
-
-
- "Ich trainiere viele Kinder, aber die kinetische Flüssigkeit in deinen Bewegungen ist etwas Besonderes. Du machst jede Kata zu einem Tanz. Weiter so – der nächste schwarze Gürtel wartet schon!" -
-
- -
-
-
- Gast -
-
-

Herr Braun

-

Lehrer

-
-
-

Balance im Sport führt zu Balance im Leben. Halt die Disziplin, die du im Dojo zeigst, auch in der Schule!

-
-
- -
- + {{ end }} + {{ end }}
@@ -285,13 +236,14 @@
-
MiyaKarate
+ {{ $social := .Site.Data.global.social }} +
{{ .Site.Data.homepage.siteTitle | default .Site.Title }}
-
© 2024 MiyaKarate. Alle Rechte vorbehalten.
+
© 2024 {{ .Site.Data.homepage.siteTitle | default .Site.Title }}. Alle Rechte vorbehalten.
diff --git a/layouts/galerie/list.html b/layouts/galerie/list.html index 0e775d1..0242903 100644 --- a/layouts/galerie/list.html +++ b/layouts/galerie/list.html @@ -3,7 +3,7 @@ -Galerie | MiyaKarate +Galerie | {{ .Site.Data.homepage.siteTitle | default .Site.Title }} @@ -61,7 +61,7 @@
- MiyaKarate + {{ .Site.Data.homepage.siteTitle | default .Site.Title }}