ranking.go 635 B

12345678910111213141516171819202122232425262728293031323334
  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("rank", fiber.Map{
  21. "Title": "Ranking",
  22. "Page": pageInt,
  23. "PageLimit": 10, // hard-coded by pixiv
  24. "Date": date,
  25. "Data": works,
  26. })
  27. }