feat: добавить веб-интерфейс админ-панели для управления модпаками
This commit is contained in:
@@ -41,6 +41,7 @@ func (h *Handler) RegisterRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("GET /login", h.loginPage)
|
||||
mux.HandleFunc("GET /register", h.registerPage)
|
||||
mux.HandleFunc("GET /profile", h.profilePage)
|
||||
mux.HandleFunc("GET /admin", h.adminPage)
|
||||
}
|
||||
|
||||
// ── Page handlers ──────────────────────────────────────────────
|
||||
@@ -65,6 +66,13 @@ func (h *Handler) profilePage(w http.ResponseWriter, r *http.Request) {
|
||||
h.render(w, "profile.html", pageData{Title: "Профиль"})
|
||||
}
|
||||
|
||||
func (h *Handler) adminPage(w http.ResponseWriter, r *http.Request) {
|
||||
// Check if user is logged in via token in cookie or localStorage?
|
||||
// For simplicity, we rely on the API endpoints to check auth.
|
||||
// We'll just render the admin page; the JS will check for token and redirect to login if needed.
|
||||
h.render(w, "admin.html", pageData{Title: "Админ-панель"})
|
||||
}
|
||||
|
||||
// render executes the "base.html" template which {{template "content" .}}
|
||||
// pulls in the per-page content block.
|
||||
func (h *Handler) render(w http.ResponseWriter, page string, data pageData) {
|
||||
@@ -88,7 +96,7 @@ func (h *Handler) render(w http.ResponseWriter, page string, data pageData) {
|
||||
// multiple {{define "content"}} blocks in wildcard-parsed files overwrite
|
||||
// each other (last alphabetically wins).
|
||||
func (h *Handler) parseTemplates() {
|
||||
pages := []string{"index.html", "login.html", "register.html", "profile.html"}
|
||||
pages := []string{"index.html", "login.html", "register.html", "profile.html", "admin.html"}
|
||||
for _, page := range pages {
|
||||
tmpl, err := template.New("base.html").Funcs(template.FuncMap{}).ParseFS(templateFS, "html/base.html", "html/"+page)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user