package handler import ( "fmt" "net/http" "github.com/panelhosting/panel/internal/middleware" "github.com/panelhosting/panel/internal/setup" ) func Health(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte(`{"status":"ok"}`)) } func IndexPage(setupSvc *setup.Service) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { required, err := setupSvc.Status(r.Context()) if err != nil { writeError(w, http.StatusInternalServerError, "internal error") return } if required { serveHTML(w, setupPageHTML) return } if user, ok := middleware.UserFromContext(r.Context()); ok { serveHTML(w, dashboardPageHTML(user.Username)) return } serveHTML(w, loginPageHTML) } } func serveHTML(w http.ResponseWriter, html string) { w.Header().Set("Content-Type", "text/html; charset=utf-8") w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte(html)) } const baseCSS = ` * { box-sizing: border-box; } body { font-family: system-ui, sans-serif; background: #0f172a; color: #e2e8f0; margin: 0; min-height: 100vh; } a { color: #60a5fa; } .wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem; } .card { background: #1e293b; border-radius: 12px; padding: 1.5rem; box-shadow: 0 12px 32px rgba(0,0,0,.25); margin-bottom: 1rem; } h1 { margin: 0 0 .5rem; font-size: 1.5rem; } h2 { margin: 0 0 1rem; font-size: 1.1rem; color: #cbd5e1; } p.sub { color: #94a3b8; margin: 0 0 1.25rem; } label { display: block; margin-bottom: .35rem; font-size: .85rem; color: #cbd5e1; } input, select { width: 100%; padding: .65rem .75rem; margin-bottom: 1rem; border: 1px solid #334155; border-radius: 8px; background: #0f172a; color: #f8fafc; font-size: 1rem; } input:focus, select:focus { outline: 2px solid #3b82f6; border-color: transparent; } button { padding: .65rem 1rem; background: #3b82f6; color: #fff; border: none; border-radius: 8px; font-size: .95rem; font-weight: 600; cursor: pointer; } button:hover { background: #2563eb; } button:disabled { opacity: .6; cursor: not-allowed; } button.secondary { background: #334155; } button.secondary:hover { background: #475569; } .row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; } @media (max-width: 640px) { .row { grid-template-columns: 1fr; } } .msg { margin-top: 1rem; padding: .75rem; border-radius: 8px; font-size: .9rem; display: none; } .msg.error { display: block; background: #7f1d1d; color: #fecaca; } .msg.ok { display: block; background: #14532d; color: #bbf7d0; } .topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; } table { width: 100%; border-collapse: collapse; font-size: .9rem; } th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid #334155; } th { color: #94a3b8; font-weight: 500; } .badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; background: #14532d; color: #bbf7d0; } .center-card { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; } .center-card .card { width: 100%; max-width: 420px; } label.check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; font-size: .9rem; color: #cbd5e1; } label.check input { width: auto; margin: 0; } .badge.ssl-pending { background: #713f12; color: #fde68a; } .badge.ssl-active { background: #14532d; color: #bbf7d0; } .badge.ssl-error { background: #7f1d1d; color: #fecaca; } ` const setupPageHTML = ` PanelHosting — настройка

PanelHosting

Создайте суперадминистратора

` const loginPageHTML = ` PanelHosting — вход

PanelHosting

Войдите в панель

` func dashboardPageHTML(username string) string { return fmt.Sprintf(` PanelHosting

PanelHosting

%s

Новый сайт

Сайты

ИмяДоменPHPSSLСтатусПуть
`, baseCSS, username) }