pixivision.go 951 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package routes
  2. import (
  3. "codeberg.org/vnpower/pixivfe/v2/session"
  4. "codeberg.org/vnpower/pixivision"
  5. "github.com/gofiber/fiber/v2"
  6. )
  7. func PixivisionHomePage(c *fiber.Ctx) error {
  8. // Note: don't process images here?
  9. data, err := pixivision.GetHomepage()
  10. if err != nil {
  11. return err
  12. }
  13. for i := range data {
  14. data[i].Thumbnail = session.ProxyImageUrlNoEscape(c, data[i].Thumbnail)
  15. }
  16. return Render(c, Data_pixivision_index{Data: data})
  17. }
  18. func PixivisionArticlePage(c *fiber.Ctx) error {
  19. // Note: don't process images here?
  20. id := c.Params("id")
  21. data, err := pixivision.GetArticle(id)
  22. if err != nil {
  23. return err
  24. }
  25. data.Thumbnail = session.ProxyImageUrlNoEscape(c, data.Thumbnail)
  26. for i := range data.Items {
  27. data.Items[i].Image = session.ProxyImageUrlNoEscape(c, data.Items[i].Image)
  28. data.Items[i].Avatar = session.ProxyImageUrlNoEscape(c, data.Items[i].Avatar)
  29. }
  30. return Render(c, Data_pixivision_article{Article: data})
  31. }