2024-01-06 20:20:58 +00:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
2024-03-19 20:16:26 +00:00
|
|
|
"log"
|
|
|
|
|
2024-01-18 17:01:30 +00:00
|
|
|
"git.matterlinux.xyz/Matter/website/lib"
|
2024-01-06 20:20:58 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func WikiMainRoute(c *fiber.Ctx) error {
|
|
|
|
con, err := lib.GetContent("wiki", "main")
|
|
|
|
if err != nil {
|
2024-03-19 20:16:26 +00:00
|
|
|
log.Printf("GetContent failed: %s", err.Error())
|
2024-01-06 20:20:58 +00:00
|
|
|
return lib.RenderError(c, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Render("post", fiber.Map{
|
|
|
|
"title": "Wiki",
|
|
|
|
"post": con,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func WikiRoute(c *fiber.Ctx) error{
|
|
|
|
docid := c.Params("id")
|
|
|
|
if len(docid) == 0 {
|
|
|
|
return lib.RenderError(c, 404)
|
|
|
|
}
|
|
|
|
|
|
|
|
contents, err := lib.ListContent("wiki")
|
|
|
|
if err != nil {
|
2024-03-19 20:16:26 +00:00
|
|
|
log.Printf("ListContent failed: %s", err.Error())
|
2024-01-06 20:20:58 +00:00
|
|
|
return lib.RenderError(c, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, con := range contents {
|
|
|
|
if(con.ID != docid) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
con, err = lib.GetContent(con.Dir, con.Name)
|
|
|
|
if err != nil {
|
2024-03-19 20:16:26 +00:00
|
|
|
log.Printf("GetContent failed: %s", err.Error())
|
2024-01-06 20:20:58 +00:00
|
|
|
return lib.RenderError(c, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
con.Title = "Wiki: "+con.Title
|
|
|
|
return c.Render("post", fiber.Map{
|
|
|
|
"title": "Wiki",
|
|
|
|
"post": con,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return lib.RenderError(c, 404)
|
|
|
|
}
|