2024-01-06 20:20:58 +00:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
2024-01-18 17:01:30 +00:00
|
|
|
"git.matterlinux.xyz/Matter/website/lib"
|
2024-08-13 21:32:48 +00:00
|
|
|
"git.matterlinux.xyz/Matter/website/log"
|
2024-01-06 20:20:58 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
2024-08-13 21:32:48 +00:00
|
|
|
func GET_Wiki(c *fiber.Ctx) error {
|
|
|
|
var (
|
|
|
|
con lib.Content
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
if con, err = lib.GetContent("wiki", "main"); err != nil {
|
|
|
|
log.Error("GetContent failed: %s", err.Error())
|
|
|
|
return lib.RenderError(c, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Render("post", fiber.Map{
|
|
|
|
"title": "Wiki",
|
|
|
|
"post": con,
|
|
|
|
})
|
2024-01-06 20:20:58 +00:00
|
|
|
}
|
|
|
|
|
2024-08-13 21:32:48 +00:00
|
|
|
func GET_WikiPage(c *fiber.Ctx) error {
|
|
|
|
var (
|
|
|
|
contents []lib.Content
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
docid := c.Params("id")
|
|
|
|
if len(docid) == 0 {
|
|
|
|
return lib.RenderError(c, 404)
|
|
|
|
}
|
|
|
|
|
|
|
|
if contents, err = lib.ListContent("wiki"); err != nil {
|
|
|
|
log.Error("ListContent failed: %s", err.Error())
|
|
|
|
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 {
|
|
|
|
log.Error("GetContent failed: %s", err.Error())
|
|
|
|
return lib.RenderError(c, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
con.Title = "Wiki: " + con.Title
|
|
|
|
|
|
|
|
return c.Render("post", fiber.Map{
|
|
|
|
"title": con.Title,
|
|
|
|
"post": con,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return lib.RenderError(c, 404)
|
2024-01-06 20:20:58 +00:00
|
|
|
}
|