diff --git a/content-editor.js b/content-editor.js index 4e5322c..97eaf2a 100644 --- a/content-editor.js +++ b/content-editor.js @@ -11,6 +11,7 @@ const http = require('http'); const fs = require('fs'); const path = require('path'); +const { exec } = require('child_process'); const PORT = 4001; const CONTENT_DIR = path.join(__dirname, 'proto', 'src', 'content'); @@ -99,9 +100,12 @@ const HTML = (activeFile, jsonData, message) => ` .btn-save { background: linear-gradient(135deg,#3b82f6,#6366f1); color: #fff; border: none; padding: 11px 26px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .2s, transform .1s; } .btn-save:hover { opacity: .9; transform: translateY(-1px); } .btn-save:active { transform: translateY(0); } - .preview-link { color: #64748b; font-size: 13px; text-decoration: none; } + .btn-publish { background: linear-gradient(135deg,#10b981,#059669); color: #fff; border: none; padding: 11px 26px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .2s, transform .1s; } + .btn-publish:hover { opacity: .9; transform: translateY(-1px); } + .btn-publish:active { transform: translateY(0); } + .preview-link { color: #64748b; font-size: 13px; text-decoration: none; margin-left: auto; } .preview-link:hover { color: #94a3b8; } - .save-status { font-size: 12px; color: #10b981; display: none; } + .save-status { font-size: 13px; font-weight: 500; display: none; margin-left: 8px; } /* Toast */ .toast { position: fixed; top: 20px; right: 20px; padding: 13px 18px; border-radius: 9px; font-size: 14px; font-weight: 500; z-index: 200; animation: slideIn .3s ease; } @@ -132,7 +136,8 @@ ${message ? `
${messag
- ✅ Mentve! + + 🔗 Előnézet →
@@ -340,6 +345,38 @@ async function save() { setTimeout(() => status.style.display = 'none', 3000); } +async function publish() { + const btn = document.getElementById('publishBtn'); + const status = document.getElementById('saveStatus'); + + // Save first + await save(); + + btn.textContent = '⏳ Élesítés folyamatban...'; + btn.disabled = true; + + try { + const res = await fetch('/publish', { method: 'POST' }); + const json = await res.json(); + + if (json.ok) { + status.textContent = '🚀 Sikeresen elküldve a szerverre!'; + status.style.color = '#10b981'; + } else { + status.textContent = '❌ Hiba az élesítésnél: ' + json.error; + status.style.color = '#f87171'; + } + } catch (e) { + status.textContent = '❌ Hálózati hiba'; + status.style.color = '#f87171'; + } + + btn.textContent = '🚀 Publikálás & Élesítés'; + btn.disabled = false; + status.style.display = 'inline'; + setTimeout(() => status.style.display = 'none', 5000); +} + function esc(v) { return String(v).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } @@ -392,6 +429,26 @@ const server = http.createServer(async (req, res) => { return; } + // POST /publish — Git Commit & Push + if (req.method === 'POST' && u.pathname === '/publish') { + exec('git add . && git commit -m "content: frissítve a CMS-ből" && git push', { cwd: CONTENT_DIR }, (error, stdout, stderr) => { + res.writeHead(200, { 'Content-Type': 'application/json' }); + if (error) { + // If there's nothing to commit, it's fine + if (stdout.includes('nothing to commit') || stdout.includes('working tree clean')) { + res.end(JSON.stringify({ ok: true, output: 'No changes to commit' })); + } else { + res.end(JSON.stringify({ ok: false, error: stderr || stdout || error.message })); + } + } else { + // If a deploy.sh script exists, run it optionally in background + exec('cd ../../../ && ./deploy.sh production > deploy.log 2>&1 &'); + res.end(JSON.stringify({ ok: true, output: stdout })); + } + }); + return; + } + // GET / — editor UI let message = null; let jsonData = '{}'; diff --git a/proto/src/content/pages/home.json b/proto/src/content/pages/home.json index 0e2c178..3751928 100755 --- a/proto/src/content/pages/home.json +++ b/proto/src/content/pages/home.json @@ -1,7 +1,7 @@ { "hero": { "0": { - "$1escription": "A mozdIT Bt. megbízható, személyes szolgáltatásokkal segíti ügyfeleit az online térben." + "$1escription": "A mozdIT Bt. célja, hogy megbízható, támogató szolgáltatásokkal segítse ügyfeleit a digitális térben való sikerben." }, "title": "Web és e-mail – testreszabott szolgáltatásokkal", "subtitle": "Kis ügyfélkör, nagy figyelem: stabil tárhely, üzembiztos levelezés és DNS adminisztráció — gyors reakcióval.", @@ -20,7 +20,7 @@ }, "secon": { "$1ary": { - "text": "Webmail Ugrás", + "text": "mozdIT Webmail", "href": "https://mail.mozdit.hu", "external": "true" } @@ -28,7 +28,7 @@ }, "trustBullets[0]": "Saját dedikált infrastruktúra", "trustBullets[1]": "Webtárhely, domain, e-mail egy helyen", - "trustBullets[2]": "Kifejezetten kisvállalkozásokra szabva" + "trustBullets[2]": "Kisvállalkozásokra szabva" }, "about": { "title": "Miért érdemes minket választani?",