This commit is contained in:
iacore
2024-08-19 22:55:19 +00:00
parent e34fabdeb2
commit bfac777b92
8 changed files with 27 additions and 19 deletions
+5 -5
View File
@@ -20,7 +20,7 @@ const (
UserArt_AnyAlt UserArtCategory = "artworks"
UserArt_Illustration UserArtCategory = "illustrations"
UserArt_Manga UserArtCategory = "manga"
UserArt_Bookmarked UserArtCategory = "bookmarks" // what this user has bookmarked; not art by this user
UserArt_Bookmarks UserArtCategory = "bookmarks" // what this user has bookmarked; not art by this user
UserArt_Novel UserArtCategory = "novels"
)
@@ -29,9 +29,9 @@ func (s UserArtCategory) Validate() error {
s != UserArt_AnyAlt &&
s != UserArt_Illustration &&
s != UserArt_Manga &&
s != UserArt_Bookmarked &&
s != UserArt_Bookmarks &&
s != UserArt_Novel {
return fmt.Errorf("Invalid work category: %#v. "+`Only "%s", "%s", "%s", "%s", "%s" and "%s" are available`, s, UserArt_Any, UserArt_AnyAlt, UserArt_Illustration, UserArt_Manga, UserArt_Bookmarked, UserArt_Novel)
return fmt.Errorf("Invalid work category: %#v. "+`Only "%s", "%s", "%s", "%s", "%s" and "%s" are available`, s, UserArt_Any, UserArt_AnyAlt, UserArt_Illustration, UserArt_Manga, UserArt_Bookmarks, UserArt_Novel)
} else {
return nil
}
@@ -267,7 +267,7 @@ func GetUserArtwork(c *fiber.Ctx, id string, category UserArtCategory, page int,
return user, err
}
if category == "bookmarks" {
if category == UserArt_Bookmarks {
// Bookmarks
works, count, err := GetUserBookmarks(c, id, "show", page)
if err != nil {
@@ -278,7 +278,7 @@ func GetUserArtwork(c *fiber.Ctx, id string, category UserArtCategory, page int,
// Public bookmarks count
user.ArtworksCount = count
} else if category == "novels" {
} else if category == UserArt_Novel {
ids, count, err := GetUserArtworksID(c, id, category, page)
if err != nil {
return user, err
@@ -58,7 +58,7 @@ func ArtworkMultiPage(c *fiber.Ctx) error {
return err_global
}
return c.Render("artwork-multi", fiber.Map{
return c.Render("artworkMulti", fiber.Map{
"Artworks": artworks,
"Title": fmt.Sprintf("(%d images)", len(artworks)),
})
+4 -9
View File
@@ -41,7 +41,7 @@ func fetchData(c *fiber.Ctx, getTags bool) (userPageData, error) {
var worksCount int
var worksPerPage float64
if category == core.UserArt_Bookmarked {
if category == core.UserArt_Bookmarks {
worksPerPage = 48.0
} else {
worksPerPage = 30.0
@@ -75,7 +75,9 @@ func UserAtomFeed(c *fiber.Ctx) error {
return err
}
err = c.Render("user.atom", fiber.Map{
c.Context().SetContentType("application/atom+xml")
return c.Render("user.atom", fiber.Map{
"URL": string(c.Request().RequestURI()),
"Title": data.user.Name,
"User": data.user,
@@ -85,11 +87,4 @@ func UserAtomFeed(c *fiber.Ctx) error {
"Page": data.page,
// "MetaImage": data.user.BackgroundImage,
}, "")
if err != nil {
return err
}
c.Context().SetContentType("application/atom+xml")
return nil
}
+10 -2
View File
@@ -87,6 +87,14 @@ rules:
message: "raw UserArtCategory string"
languages: [go]
severity: WARNING
pattern-either:
patterns:
- pattern: |
($A : UserArtCategory) == "$B"
($A : UserArtCategory) == $B
- pattern-not: |
($A : UserArtCategory) == ($B : UserArtCategory)
- id: rule-7
message: "c.Render"
languages: [go]
severity: INFO
pattern: |
c.Render(...)
@@ -1,4 +1,4 @@
package main_test
package main
import (
"log"
+6
View File
@@ -0,0 +1,6 @@
# About testing
There are two places where data transformations aren't type checked.
1. passing data from Go to Jet (layout engine)
2. whether response from pixiv API fit our JSON schema or not
-1
View File
@@ -1 +0,0 @@
package tests