add blog index to admin dashboard

This commit is contained in:
ari melody 2025-11-07 01:04:10 +00:00
parent ee8bf6543e
commit 65366032fd
Signed by: ari
GPG key ID: CF99829C92678188
10 changed files with 603 additions and 91 deletions

View file

@ -7,6 +7,7 @@ import (
"arimelody-web/admin/account"
"arimelody-web/admin/auth"
"arimelody-web/admin/blog"
"arimelody-web/admin/core"
"arimelody-web/admin/logs"
"arimelody-web/admin/music"
@ -24,8 +25,10 @@ func Handler(app *model.AppState) http.Handler {
mux.Handle("/totp", auth.LoginTOTPHandler(app))
mux.Handle("/logout", core.RequireAccount(auth.LogoutHandler(app)))
mux.Handle("/music/", core.RequireAccount(http.StripPrefix("/music", music.Handler(app))))
mux.Handle("/logs", core.RequireAccount(logs.Handler(app)))
mux.Handle("/music/", core.RequireAccount(http.StripPrefix("/music", music.Handler(app))))
mux.Handle("/blogs/", core.RequireAccount(http.StripPrefix("/blogs", blog.Handler(app))))
mux.Handle("/account/", core.RequireAccount(http.StripPrefix("/account", account.Handler(app))))
mux.Handle("/static/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@ -42,13 +45,13 @@ func Handler(app *model.AppState) http.Handler {
view.ServeFiles("./admin/static"))).ServeHTTP(w, r)
}))
mux.Handle("/", core.RequireAccount(AdminIndexHandler(app)))
mux.Handle("/", core.RequireAccount(adminIndexHandler(app)))
// response wrapper to make sure a session cookie exists
return core.EnforceSession(app, mux)
}
func AdminIndexHandler(app *model.AppState) http.Handler {
func adminIndexHandler(app *model.AppState) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)