mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-12-06 00:18:07 +00:00
Admin: Isolate the panel view
This commit is contained in:
19
web/admin.go
19
web/admin.go
@@ -2,6 +2,7 @@ package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/admin"
|
||||
"github.com/bouncepaw/mycorrhiza/viewutil"
|
||||
"io"
|
||||
"log"
|
||||
@@ -20,23 +21,23 @@ import (
|
||||
)
|
||||
|
||||
// initAdmin sets up /admin routes if auth is used. Call it after you have decided if you want to use auth.
|
||||
func initAdmin(r *mux.Router) {
|
||||
r.HandleFunc("/shutdown", handlerAdminShutdown).Methods(http.MethodPost)
|
||||
r.HandleFunc("/reindex-users", handlerAdminReindexUsers).Methods(http.MethodPost)
|
||||
func initAdmin(rtr *mux.Router) {
|
||||
rtr.HandleFunc("/shutdown", handlerAdminShutdown).Methods(http.MethodPost)
|
||||
rtr.HandleFunc("/reindex-users", handlerAdminReindexUsers).Methods(http.MethodPost)
|
||||
|
||||
r.HandleFunc("/new-user", handlerAdminUserNew).Methods(http.MethodGet, http.MethodPost)
|
||||
r.HandleFunc("/users/{username}/edit", handlerAdminUserEdit).Methods(http.MethodGet, http.MethodPost)
|
||||
r.HandleFunc("/users/{username}/delete", handlerAdminUserDelete).Methods(http.MethodGet, http.MethodPost)
|
||||
r.HandleFunc("/users", handlerAdminUsers)
|
||||
rtr.HandleFunc("/new-user", handlerAdminUserNew).Methods(http.MethodGet, http.MethodPost)
|
||||
rtr.HandleFunc("/users/{username}/edit", handlerAdminUserEdit).Methods(http.MethodGet, http.MethodPost)
|
||||
rtr.HandleFunc("/users/{username}/delete", handlerAdminUserDelete).Methods(http.MethodGet, http.MethodPost)
|
||||
rtr.HandleFunc("/users", handlerAdminUsers)
|
||||
|
||||
r.HandleFunc("/", handlerAdmin)
|
||||
rtr.HandleFunc("/", handlerAdmin)
|
||||
}
|
||||
|
||||
// handlerAdmin provides the admin panel.
|
||||
func handlerAdmin(w http.ResponseWriter, rq *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
views.AdminPanel(viewutil.MetaFrom(w, rq))
|
||||
admin.AdminPanel(viewutil.MetaFrom(w, rq))
|
||||
}
|
||||
|
||||
// handlerAdminShutdown kills the wiki.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"github.com/bouncepaw/mycorrhiza/admin"
|
||||
"github.com/bouncepaw/mycorrhiza/backlinks"
|
||||
"github.com/bouncepaw/mycorrhiza/categories"
|
||||
"github.com/bouncepaw/mycorrhiza/help"
|
||||
@@ -61,6 +62,7 @@ func Handler() http.Handler {
|
||||
adminRouter := wikiRouter.PathPrefix("/admin").Subrouter()
|
||||
adminRouter.Use(groupMiddleware("admin"))
|
||||
initAdmin(adminRouter)
|
||||
admin.Init(adminRouter)
|
||||
}
|
||||
|
||||
// Index page
|
||||
|
||||
Reference in New Issue
Block a user