register.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package routes
  2. import (
  3. "io/fs"
  4. "git.aetherial.dev/aeth/keiji/pkg/controller"
  5. "git.aetherial.dev/aeth/keiji/pkg/helpers"
  6. "github.com/gin-gonic/gin"
  7. )
  8. func Register(e *gin.Engine, domain string, database helpers.DocumentIO, files fs.FS) {
  9. c := controller.NewController(domain, database, files)
  10. web := e.Group("")
  11. web.GET("/", c.ServeHome)
  12. web.GET("/blog", c.ServeBlog)
  13. web.GET("/digital", c.ServeDigitalArt)
  14. web.GET("/creative", c.ServeCreative)
  15. web.GET("/writing/:id", c.ServePost)
  16. web.GET("/login", c.ServeLogin)
  17. web.POST("/login", c.Auth)
  18. cdn := e.Group("/api/v1")
  19. cdn.GET("/images/:file", c.ServeImage)
  20. cdn.GET("/cdn/:file", c.ServeGeneric)
  21. cdn.GET("assets/:file", c.ServeAsset)
  22. priv := e.Group("/admin")
  23. priv.Use(c.IsAuthenticated)
  24. priv.GET("/upload", c.ServeFileUpload)
  25. priv.POST("/upload", c.SaveFile)
  26. priv.POST("/asset", c.AddAsset)
  27. priv.GET("/panel", c.AdminPanel)
  28. priv.POST("/panel", c.AddAdminTableEntry)
  29. priv.POST("/menu", c.AddMenuItem)
  30. priv.POST("/navbar", c.AddNavbarItem)
  31. priv.POST("/images/upload", c.SaveFile)
  32. priv.GET("/posts/:id", c.GetBlogPostEditor)
  33. priv.GET("/options/:id", c.PostOptions)
  34. priv.POST("/posts", c.MakeBlogPost)
  35. priv.GET("/posts/all", c.ServeBlogDirectory)
  36. priv.GET("/posts", c.ServeNewBlogPage)
  37. priv.PATCH("/posts", c.UpdateBlogPost)
  38. priv.DELETE("/posts/:id", c.DeleteDocument)
  39. }