58 lines
1.3 KiB
Text
58 lines
1.3 KiB
Text
package modweb
|
|
|
|
import (
|
|
"git.ddd.rip/ptrcnull/modweb/config"
|
|
"git.ddd.rip/ptrcnull/modweb/module"
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/session/v2"
|
|
"github.com/gofiber/template/html"
|
|
_ "github.com/hashicorp/go-plugin"
|
|
)
|
|
|
|
func main() {
|
|
views := html.New("./templates", ".html")
|
|
conf, _ := config.Load()
|
|
app := fiber.New(fiber.Config{Views: views})
|
|
sessions := session.New()
|
|
|
|
modules, err := module.LoadAll(conf.ModulePath)
|
|
//for _, mod := range modules {
|
|
//app.Get("/" + mod.Name() + "/", func(ctx *fiber.Ctx) error {
|
|
// //ctx.Render("module", "")
|
|
// //templates.Send(ctx, fiber.Map{
|
|
// // "modules": modules,
|
|
// // "currentModule": mod,
|
|
// //}, static.Navbar, static.ModulePage)
|
|
// return nil
|
|
//})
|
|
//}
|
|
|
|
data := func(d fiber.Map) fiber.Map {
|
|
base := fiber.Map{
|
|
"appName": conf.AppName,
|
|
"modules": modules,
|
|
"username": "ptrcnull",
|
|
"allowRegistration": conf.AllowRegistration,
|
|
}
|
|
for k, v := range d {
|
|
base[k] = v
|
|
}
|
|
return base
|
|
}
|
|
|
|
app.Get("/", func(ctx *fiber.Ctx) error {
|
|
store := sessions.Get(ctx)
|
|
defer store.Save()
|
|
|
|
// _, loggedIn := store.Get("discordId")
|
|
|
|
return ctx.Render("homepage", data(fiber.Map{
|
|
"title": "Homepage",
|
|
}), "layouts/main")
|
|
})
|
|
|
|
err = app.Listen(conf.ListenAddress)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|