types.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package routes
  2. import (
  3. "net/http"
  4. "codeberg.org/vnpower/pixivfe/v2/core"
  5. "codeberg.org/vnpower/pixivfe/v2/template"
  6. "codeberg.org/vnpower/pixivision"
  7. )
  8. func Render[T any](w http.ResponseWriter, r *http.Request, data T) error {
  9. return template.Render(w, r, data)
  10. }
  11. // Tutorial: adding new types in this file
  12. // Whenever you add new types, update `TestTemplates` in render_test.go to include the type in the test
  13. // Do not use pointer in Data_* struct. faker will insert nil.
  14. // Do not name template file a.b.jet.html or it won't be able to be used here, since Data_a.b is not a valid identifier.
  15. type Data_error struct {
  16. Title string
  17. Error error
  18. }
  19. type Data_about struct {
  20. Time string
  21. Version string
  22. ImageProxy string
  23. AcceptLanguage string
  24. }
  25. type Data_artwork struct {
  26. Illust core.Illust
  27. Title string
  28. MetaDescription string
  29. MetaImage string
  30. MetaAuthor string
  31. MetaAuthorID string
  32. }
  33. type Data_artworkMulti struct {
  34. Artworks []core.Illust
  35. Title string
  36. }
  37. type Data_userAtom struct {
  38. URL string
  39. Title string
  40. User core.User
  41. Category core.UserArtCategory
  42. Updated string
  43. PageLimit int
  44. Page int
  45. // MetaImage string
  46. }
  47. type Data_index struct {
  48. Title string
  49. LoggedIn bool
  50. Data core.LandingArtworks
  51. NoTokenData core.Ranking
  52. }
  53. type Data_unauthorized struct{}
  54. type Data_discovery struct {
  55. Artworks []core.ArtworkBrief
  56. Title string
  57. Queries template.PartialURL
  58. }
  59. type Data_novelDiscovery struct {
  60. Novels []core.NovelBrief
  61. Title string
  62. }
  63. type Data_newest struct {
  64. Items []core.ArtworkBrief
  65. Title string
  66. }
  67. type Data_novel struct {
  68. Novel core.Novel
  69. NovelRelated []core.NovelBrief
  70. User core.UserBrief
  71. Title string
  72. FontType string
  73. ViewMode string
  74. Language string
  75. }
  76. type Data_following struct {
  77. Title string
  78. Mode string
  79. Artworks []core.ArtworkBrief
  80. CurPage string
  81. Page int
  82. }
  83. type Data_pixivision_index struct {
  84. Data []pixivision.Article
  85. }
  86. type Data_pixivision_article struct {
  87. Article pixivision.Article
  88. }
  89. type Data_rank struct {
  90. Title string
  91. Page int
  92. PageLimit int
  93. Date string
  94. Data core.Ranking
  95. }
  96. type Data_rankingCalendar struct {
  97. Title string
  98. Render core.HTML
  99. Mode string
  100. Year int
  101. MonthBefore DateWrap
  102. MonthAfter DateWrap
  103. ThisMonth DateWrap
  104. }
  105. type Data_settings struct {
  106. ProxyList []string
  107. WorkingProxyList []string
  108. }
  109. type Data_tag struct {
  110. Title string
  111. Tag core.TagDetail
  112. Data core.SearchResult
  113. QueriesC template.PartialURL
  114. TrueTag string
  115. Page int
  116. }
  117. type Data_user struct {
  118. Title string
  119. User core.User
  120. Category core.UserArtCategory
  121. PageLimit int
  122. Page int
  123. MetaImage string
  124. }