mirror of
https://hacklab.nilfm.cc/nirvash
synced 2024-10-22 14:01:49 +00:00
49 lines
1 KiB
Go
49 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
core "nilfm.cc/git/nirvash/archetype"
|
|
shell "nilfm.cc/git/nirvash/lfo"
|
|
"nilfm.cc/git/quartzgun/indentalUserDB"
|
|
"nilfm.cc/git/quartzgun/middleware"
|
|
"nilfm.cc/git/quartzgun/renderer"
|
|
"nilfm.cc/git/quartzgun/router"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func main() {
|
|
cfg := core.ReadConfig()
|
|
udb := indentalUserDB.CreateIndentalUserDB(
|
|
filepath.Join(
|
|
core.GetConfigLocation(),
|
|
"user.db"))
|
|
if core.ProcessCmd(os.Args, udb, cfg) {
|
|
os.Exit(0)
|
|
}
|
|
if cfg.IsNull() {
|
|
cfg.RunWizard()
|
|
}
|
|
|
|
cfg.Adapter.Init(cfg)
|
|
|
|
rtr := &router.Router{
|
|
StaticPaths: map[string]string{
|
|
"/static": cfg.AssetRoot,
|
|
},
|
|
}
|
|
|
|
rtr.Get("/login", renderer.Template(
|
|
"templates/login.html"))
|
|
|
|
rtr.Post("/login", middleware.Authorize("/", udb, "/login?tryagain=1"))
|
|
|
|
rtr.Get("/", middleware.Protected(
|
|
shell.WithAdapter(
|
|
renderer.Template(
|
|
"templates/cms_list.html",
|
|
"templates/header.html",
|
|
"templates/footer.html"), cfg.Adapter), http.MethodGet, udb, "/login"))
|
|
|
|
http.ListenAndServe(":8080", rtr)
|
|
}
|