refactor: extract inline CSS/JS from views into separate asset files (20+ files)

Phase A — HTML removed from PHP files:
- RateLimitMiddleware.php: heredoc moved to views/errors/429.php
- public/index.php: inline HTML replaced with View::error()
- AuthMiddleware.php: <script> redirect replaced with <meta refresh>

Phase B — Inline CSS/JS extracted from views:
- CSS: landing.css (459 lines), legal.css (shared by terms+privacy)
- JS: 17 new files extracted from ~20 view files
  - main.js (layout sidebar + notifications)
  - dashboard-chart.js, server-show.js, server-services.js
  - nginx-manager.js, database-manager.js
  - terminal.js, team-show.js, team-index.js
  - server-list.js, server-permissions.js (shared by edit+create)
  - server-ssl.js, server-processes.js, system-users.js
  - admin-users.js, audit-log.js, admin-notifications.js, admin-security.js
  - notifications.js

Total: -3264 lines from views, +288 lines in new assets
This commit is contained in:
2026-06-14 08:04:01 -04:00
parent 142fe304c9
commit 88f3c1f964
51 changed files with 3152 additions and 3269 deletions

View File

@@ -41,7 +41,7 @@ $commandHistory = $commandHistory ?? [];
\___ \ / _ \ '__\ \ / / _ \ '__| | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \ '__|
___) | __/ | \ V / __/ | | | | | (_| | | | | (_| | (_| | __/ |
|____/ \___|_| \_/ \___|_| |_| |_|\__,_|_| |_|\__,_|\__, |\___|_|
|___/
|___/
</pre>
<p>Connected to <strong><?= htmlspecialchars($server['name']) ?></strong></p>
<p class="text-muted">Type commands below to execute them on the remote server.</p>
@@ -149,121 +149,5 @@ $commandHistory = $commandHistory ?? [];
<script>
const serverId = <?= $server['id'] ?>;
function getCsrfToken() {
return document.querySelector('meta[name="csrf-token"]')?.content || '';
}
const terminalInput = document.getElementById('terminalInput');
const terminalOutput = document.getElementById('terminalOutput');
const connectionStatus = document.getElementById('connectionStatus');
terminalInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
executeCommand();
}
});
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
function executeCommand() {
const command = terminalInput.value.trim();
if (!command) return;
appendTerminalLine(command, 'command');
terminalInput.value = '';
terminalInput.disabled = true;
document.getElementById('executeBtn').disabled = true;
updateStatus('executing', 'Executing...');
fetch('/terminal/' + serverId + '/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-CSRF-Token': getCsrfToken(),
},
body: 'command=' + encodeURIComponent(command) + '&_csrf_token=' + encodeURIComponent(getCsrfToken()),
})
.then(r => r.json())
.then(data => {
terminalInput.disabled = false;
document.getElementById('executeBtn').disabled = false;
terminalInput.focus();
if (data.success) {
if (data.output) {
appendTerminalLine(data.output, 'output');
}
if (data.stderr) {
appendTerminalLine(data.stderr, 'error');
}
updateStatus('connected', 'Connected');
} else {
appendTerminalLine(data.message || 'Command failed', 'error');
updateStatus('error', 'Error');
}
const terminalBody = document.getElementById('terminalOutput');
terminalBody.scrollTop = terminalBody.scrollHeight;
})
.catch(err => {
terminalInput.disabled = false;
document.getElementById('executeBtn').disabled = false;
appendTerminalLine('Connection error: ' + err.message, 'error');
updateStatus('error', 'Error');
});
}
function appendTerminalLine(text, type) {
const line = document.createElement('div');
line.className = 'terminal-line terminal-' + type;
if (type === 'command') {
line.innerHTML = '<span class="terminal-prompt-inline">$</span> ' + escapeHtml(text);
} else {
line.innerHTML = '<pre>' + escapeHtml(text) + '</pre>';
}
terminalOutput.appendChild(line);
terminalOutput.scrollTop = terminalOutput.scrollHeight;
}
function runQuickCmd(cmd) {
terminalInput.value = cmd;
executeCommand();
}
function clearTerminal() {
terminalOutput.innerHTML = '';
}
function clearHistory() {
if (!confirm('Clear all command history for this server?')) return;
fetch('/terminal/' + serverId + '/clear-history', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-CSRF-Token': getCsrfToken(),
},
body: '_csrf_token=' + encodeURIComponent(getCsrfToken()),
})
.then(r => r.json())
.then(data => {
showToast(data.success ? 'success' : 'error', data.message);
if (data.success) location.reload();
});
}
function updateStatus(status, text) {
const dot = connectionStatus.querySelector('.status-dot');
dot.className = 'status-dot ' + status;
connectionStatus.lastChild.textContent = ' ' + text;
}
terminalInput.focus();
</script>
<script src="/assets/js/terminal.js"></script>