From eaddeb16be67205315dd8db7145e9b7a84f8bde9 Mon Sep 17 00:00:00 2001 From: bonzei Date: Mon, 13 Apr 2026 01:24:27 +0200 Subject: [PATCH] meine erfolge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit neue erfolge hinzufügen, tausch von bild, angabe von datu und ort --- admin-server.js | 41 +++++ admin.html | 296 +++++++++++++++++++++++++++++++++++- data/categories.json | 7 +- data/uebermich.json | 112 ++++++++++++++ layouts/uebermich/list.html | 161 ++++++++++---------- 5 files changed, 535 insertions(+), 82 deletions(-) create mode 100644 data/uebermich.json diff --git a/admin-server.js b/admin-server.js index af25c52..45c688e 100644 --- a/admin-server.js +++ b/admin-server.js @@ -10,9 +10,13 @@ const PORT = 3001; const IMAGES_DIR = path.join(__dirname, 'static/gallery/images'); const HERO_DIR = path.join(__dirname, 'static/hero'); +const UEBERMICH_IMG_DIR = path.join(__dirname, 'static/uebermich'); 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'); + +if (!fs.existsSync(UEBERMICH_IMG_DIR)) fs.mkdirSync(UEBERMICH_IMG_DIR, { recursive: true }); if (!fs.existsSync(HERO_DIR)) fs.mkdirSync(HERO_DIR, { recursive: true }); @@ -186,6 +190,43 @@ 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)); + +// Über mich API +function readUebermich() { + return JSON.parse(fs.readFileSync(UEBERMICH_FILE, 'utf8')); +} +function writeUebermich(data) { + fs.writeFileSync(UEBERMICH_FILE, JSON.stringify(data, null, 2)); +} + +app.get('/api/uebermich', (req, res) => { + res.json(readUebermich()); +}); + +app.put('/api/uebermich', (req, res) => { + const data = req.body; + writeUebermich(data); + res.json({ ok: true }); + rebuildAndDeploy(); +}); + +app.post('/api/uebermich/image', upload.single('image'), async (req, res) => { + try { + const filename = 'portrait.webp'; + await sharp(req.file.buffer) + .resize(800, 1000, { fit: 'cover', position: 'top' }) + .webp({ quality: 88 }) + .toFile(path.join(UEBERMICH_IMG_DIR, filename)); + const data = readUebermich(); + data.hero.image = filename; + writeUebermich(data); + res.json({ ok: true, image: filename }); + rebuildAndDeploy(); + } catch (e) { + res.status(500).json({ ok: false, error: e.message }); + } +}); // Admin-UI app.get('/', (req, res) => { diff --git a/admin.html b/admin.html index 6dd2e5c..4016ca1 100644 --- a/admin.html +++ b/admin.html @@ -135,6 +135,11 @@ tailwind.config = { home Startseite + + person + Über mich + tune @@ -384,6 +389,132 @@ tailwind.config = { + + +