112 lines
5.8 KiB
HTML
112 lines
5.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="th">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
<meta name="robots" content="noindex, nofollow">
|
|
<meta name="theme-color" content="#0b0d14">
|
|
<title>อัปขึ้น Gitea — Project justice</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root { --bg: #0b0d14; --card: #161922; --line: #2a3042; --txt: #c0caf5; --muted: #7a88b5; --accent: #7aa2f7; --ok: #9ece6a; --err: #f7768e; }
|
|
* { box-sizing: border-box; }
|
|
body { margin: 0; min-height: 100vh; font-family: Kanit, system-ui, sans-serif; background: var(--bg); color: var(--txt); padding: 1.25rem; }
|
|
.wrap { max-width: 42rem; margin: 0 auto; }
|
|
h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 0.35rem; }
|
|
.sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.25rem; }
|
|
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; }
|
|
label { display: block; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--muted); }
|
|
textarea { width: 100%; min-height: 4rem; padding: 0.65rem 0.75rem; border-radius: 8px; border: 1px solid var(--line); background: #13151f; color: var(--txt); font: inherit; resize: vertical; }
|
|
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 1rem; }
|
|
button { font: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 0.55rem 1.1rem; font-weight: 500; }
|
|
.btn-primary { background: var(--accent); color: #1a1b26; }
|
|
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
|
|
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
.msg { margin-top: 0.85rem; padding: 0.75rem; border-radius: 8px; font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
|
|
.msg.ok { background: rgba(158, 206, 106, 0.12); border: 1px solid rgba(158, 206, 106, 0.35); color: #c3e88d; }
|
|
.msg.err { background: rgba(247, 118, 142, 0.1); border: 1px solid rgba(247, 118, 142, 0.35); color: #f8b4c0; }
|
|
a { color: var(--accent); }
|
|
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="wrap">
|
|
<h1>อัปขึ้น Gitea — Project justice</h1>
|
|
<p class="sub">ซิงค์ <code>/var/www/html/</code> + ไฟล์ Nginx หลัก เข้า repo แล้ว <strong>git push</strong> (ต้องล็อกอิน Admin ก่อน)</p>
|
|
|
|
<div id="gate" class="card" hidden>
|
|
<p>ยังไม่ได้เข้า Admin — ไปที่หน้า Admin แล้วล็อกอินก่อน</p>
|
|
<p><a href="/Admin/">ไปหน้า Admin</a></p>
|
|
</div>
|
|
|
|
<div id="app" class="card" hidden>
|
|
<p>รีโป: <a href="https://git.srv1361159.hstgr.cloud/giteaadmin/justice" target="_blank" rel="noopener noreferrer">giteaadmin/justice</a></p>
|
|
<label for="commit-msg">ข้อความ commit (ไม่บังคับ — สูงสุด 180 ตัวอักษร)</label>
|
|
<textarea id="commit-msg" maxlength="180" placeholder="เช่น อัปเดตหน้า Login, แก้ Game lobby"></textarea>
|
|
<div class="row">
|
|
<button type="button" class="btn-primary" id="btn-push">อัปขึ้น Git (ซิงค์ + push)</button>
|
|
<a class="btn-ghost" href="/Admin/" style="text-decoration:none;display:inline-flex;align-items:center;padding:0.55rem 1.1rem;border-radius:8px;">← กลับ Admin</a>
|
|
</div>
|
|
<p class="hint">จะรันสคริปต์ <code>save-www-from-etc.sh</code> แล้ว <code>save-from-etc.sh</code> ตามลำดับ — ถ้าไม่มี diff จะขึ้น “No changes to commit.”</p>
|
|
<div id="out" class="msg" hidden role="status"></div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
(function () {
|
|
var gate = document.getElementById('gate');
|
|
var app = document.getElementById('app');
|
|
var btn = document.getElementById('btn-push');
|
|
var ta = document.getElementById('commit-msg');
|
|
var out = document.getElementById('out');
|
|
|
|
fetch('/Admin/api/session.php', { credentials: 'same-origin' })
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (j) {
|
|
if (j && j.ok && j.loggedIn) {
|
|
app.hidden = false;
|
|
} else {
|
|
gate.hidden = false;
|
|
}
|
|
})
|
|
.catch(function () {
|
|
gate.hidden = false;
|
|
});
|
|
|
|
if (btn) {
|
|
btn.addEventListener('click', function () {
|
|
out.hidden = true;
|
|
btn.disabled = true;
|
|
var msg = (ta && ta.value) ? ta.value.trim() : '';
|
|
fetch('/Admin/api/justice-push.php', {
|
|
method: 'POST',
|
|
credentials: 'same-origin',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ message: msg }),
|
|
})
|
|
.then(function (r) { return r.json().then(function (j) { return { ok: r.ok, j: j }; }); })
|
|
.then(function (x) {
|
|
out.hidden = false;
|
|
out.className = 'msg ' + (x.j && x.j.ok ? 'ok' : 'err');
|
|
if (x.j && x.j.ok) {
|
|
out.textContent = 'สำเร็จ\nข้อความ: ' + (x.j.message || '') + '\n\n' + (x.j.log || '');
|
|
} else {
|
|
out.textContent = (x.j && x.j.error) || 'ผิดพลาด' + (x.j && x.j.log ? '\n\n' + x.j.log : '');
|
|
}
|
|
})
|
|
.catch(function (e) {
|
|
out.hidden = false;
|
|
out.className = 'msg err';
|
|
out.textContent = String(e && e.message ? e.message : e);
|
|
})
|
|
.finally(function () {
|
|
btn.disabled = false;
|
|
});
|
|
});
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|