novel.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package pages
  2. import (
  3. "fmt"
  4. "strconv"
  5. "strings"
  6. session "codeberg.org/vnpower/pixivfe/v2/core/session"
  7. core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
  8. "github.com/gofiber/fiber/v2"
  9. )
  10. func NovelPage(c *fiber.Ctx) error {
  11. id := c.Params("id")
  12. if _, err := strconv.Atoi(id); err != nil {
  13. return fmt.Errorf("Invalid ID: %s", id)
  14. }
  15. novel, err := core.GetNovelByID(c, id)
  16. if err != nil {
  17. return err
  18. }
  19. related, err := core.GetNovelRelated(c, id)
  20. if err != nil {
  21. return err
  22. }
  23. user, err := core.GetUserBasicInformation(c, novel.UserID)
  24. if err != nil {
  25. return err
  26. }
  27. fontType := session.GetCookie(c, session.Cookie_NovelFontType, "gothic")
  28. viewMode := session.GetCookie(c, session.Cookie_NovelViewMode, strconv.Itoa(novel.Settings.ViewMode))
  29. // println("fontType", fontType)
  30. return c.Render("novel", fiber.Map{
  31. "Novel": novel,
  32. "NovelRelated": related,
  33. "User": user,
  34. "Title": novel.Title,
  35. "FontType": fontType,
  36. "ViewMode": viewMode,
  37. "Language": strings.ToLower(novel.Language),
  38. })
  39. }