tag.go 852 B

123456789101112131415161718192021222324252627282930313233343536
  1. package pages
  2. import (
  3. "net/url"
  4. "strconv"
  5. core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
  6. "github.com/gofiber/fiber/v2"
  7. )
  8. func TagPage(c *fiber.Ctx) error {
  9. queries := make(map[string]string, 3)
  10. queries["Mode"] = c.Query("mode", "safe")
  11. queries["Category"] = c.Query("category", "artworks")
  12. queries["Order"] = c.Query("order", "date_d")
  13. name, err := url.PathUnescape(c.Params("name"))
  14. if err != nil {
  15. return err
  16. }
  17. page := c.Query("page", "1")
  18. pageInt, _ := strconv.Atoi(page)
  19. tag, err := core.GetTagData(c, name)
  20. if err != nil {
  21. return err
  22. }
  23. result, err := core.GetSearch(c, queries["Category"], name, queries["Order"], queries["Mode"], page)
  24. if err != nil {
  25. return err
  26. }
  27. return c.Render("pages/tag", fiber.Map{"Title": "Results for " + tag.Name, "Tag": tag, "Data": result, "Queries": queries, "Page": pageInt})
  28. }