index.go 750 B

1234567891011121314151617181920212223242526272829303132333435
  1. package pages
  2. import (
  3. session "codeberg.org/vnpower/pixivfe/v2/core/config"
  4. core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
  5. "github.com/gofiber/fiber/v2"
  6. )
  7. func IndexPage(c *fiber.Ctx) error {
  8. // If token is set, do the landing request...
  9. if token := session.CheckToken(c); token != "" {
  10. mode := c.Query("mode", "all")
  11. works, err := core.GetLanding(c, mode)
  12. if err != nil {
  13. return err
  14. }
  15. return c.Render("pages/index", fiber.Map{
  16. "Title": "Landing", "Data": works,
  17. })
  18. }
  19. // ...otherwise, default to today's illustration ranking
  20. works, err := core.GetRanking(c, "daily", "illust", "", "1")
  21. if err != nil {
  22. return err
  23. }
  24. return c.Render("pages/index", fiber.Map{
  25. "Title": "Landing", "NoTokenData": works,
  26. })
  27. }