pixivision.go 921 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package routes
  2. import (
  3. "codeberg.org/vnpower/pixivfe/v2/session"
  4. "codeberg.org/vnpower/pixivision"
  5. "net/http"
  6. )
  7. func PixivisionHomePage(w http.ResponseWriter, r *http.Request) error {
  8. data, err := pixivision.GetHomepage()
  9. if err != nil {
  10. return err
  11. }
  12. for i := range data {
  13. data[i].Thumbnail = session.ProxyImageUrlNoEscape(r, data[i].Thumbnail)
  14. }
  15. return Render(w, r, Data_pixivision_index{Data: data})
  16. }
  17. func PixivisionArticlePage(w http.ResponseWriter, r *http.Request) error {
  18. id := GetPathVar(r, "id")
  19. data, err := pixivision.GetArticle(id)
  20. if err != nil {
  21. return err
  22. }
  23. data.Thumbnail = session.ProxyImageUrlNoEscape(r, data.Thumbnail)
  24. for i := range data.Items {
  25. data.Items[i].Image = session.ProxyImageUrlNoEscape(r, data.Items[i].Image)
  26. data.Items[i].Avatar = session.ProxyImageUrlNoEscape(r, data.Items[i].Avatar)
  27. }
  28. return Render(w, r, Data_pixivision_article{Article: data})
  29. }