ranking.go 686 B

123456789101112131415161718192021222324252627282930313233343536
  1. package pages
  2. import (
  3. "strconv"
  4. core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
  5. "github.com/gofiber/fiber/v2"
  6. )
  7. func RankingPage(c *fiber.Ctx) error {
  8. mode := c.Query("mode", "daily")
  9. content := c.Query("content", "all")
  10. date := c.Query("date", "")
  11. page := c.Query("page", "1")
  12. pageInt, err := strconv.Atoi(page)
  13. if err != nil {
  14. panic(err)
  15. }
  16. works, err := core.GetRanking(c, mode, content, date, page)
  17. if err != nil {
  18. return err
  19. }
  20. return c.Render("pages/rank", fiber.Map{
  21. "Title": "Ranking",
  22. "Page": pageInt,
  23. "PageLimit": 10, // hard-coded by pixiv
  24. "Mode": mode,
  25. "Content": content,
  26. "Date": date,
  27. "Data": works,
  28. })
  29. }