novel.go 966 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package routes
  2. import (
  3. "fmt"
  4. "strconv"
  5. "strings"
  6. "codeberg.org/vnpower/pixivfe/v2/core"
  7. "codeberg.org/vnpower/pixivfe/v2/session"
  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 Render(c, Data_novel{Novel: novel, NovelRelated: related, User: user, Title: novel.Title, FontType: fontType, ViewMode: viewMode, Language: strings.ToLower(novel.Language)})
  31. }