diff --git a/entity/models.go b/entity/models.go index 261512b..d6c6aa4 100644 --- a/entity/models.go +++ b/entity/models.go @@ -17,7 +17,7 @@ type Illust struct { Bookmarks int `json:"total_bookmarks"` SingleImage map[string]string `json:"meta_single_page"` MultipleImage []map[string]map[string]string `json:"meta_pages"` - // Tags Tag[]; + Tags []Tag `json:"tags"` } type Spotlight struct { @@ -28,6 +28,11 @@ type Spotlight struct { Date string `json:"publish_date"` } +type Tag struct { + Name string `json:"name"` + TranslatedName string `json:"translated_name"` +} + type UserBrief struct { ID int `json:"id"` Name string `json:"name"` diff --git a/handler/illust.go b/handler/illust.go index a22c157..f0cf982 100644 --- a/handler/illust.go +++ b/handler/illust.go @@ -56,6 +56,21 @@ func GetNewestIllust(c *gin.Context) []entity.Illust { return illusts } +func GetMemberIllust(c *gin.Context, id string) []entity.Illust { + URL := "https://hibi.cocomi.cf/api/pixiv/member_illust?id=" + id + var illusts []entity.Illust + + s := Request(URL) + g := GetInnerJSON(s, "illusts") + + err := json.Unmarshal([]byte(g), &illusts) + if err != nil { + panic("Failed to parse JSON") + } + + return illusts +} + func GetRelatedIllust(c *gin.Context) []entity.Illust { id := c.Param("id") URL := "https://hibi.cocomi.cf/api/pixiv/related?id=" + id diff --git a/main.go b/main.go index 162334e..cca89a0 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "html/template" "net/http" "pixivfe/handler" + "strconv" "github.com/gin-gonic/gin" ) @@ -15,7 +16,12 @@ func inc(n int) int { func artwork_page(c *gin.Context) { illust := handler.GetIllustByID(c) related := handler.GetRelatedIllust(c) - c.HTML(http.StatusOK, "artwork.html", gin.H{"Illust": illust, "Related": related}) + recent_by_artist := handler.GetMemberIllust(c, strconv.Itoa(illust.Artist.ID)) + c.HTML(http.StatusOK, "artwork.html", gin.H{ + "Illust": illust, + "Related": related, + "Recent": recent_by_artist, + }) } func index_page(c *gin.Context) { diff --git a/template/artwork.html b/template/artwork.html index 790e307..222fc1c 100644 --- a/template/artwork.html +++ b/template/artwork.html @@ -1,19 +1,34 @@ {{ template "header.html" }} +{{ $parent := . }}
+ {{ with .Illust }}
- - # + {{ if eq .Pages 1 }} + + {{ .Title }} + {{ else }} + {{ range .MultipleImage }} + + {{ .image_urls.original }} + + + {{ end }} + {{ end }}
- {{ with .Illust }}

{{ .Title }}

{{ .Caption }}

-

Tags

-
+ +
+ + {{ range .Tags }} + #{{ .Name }}{{ .TranslatedName + }} + {{ end }} +
{{ .Views }} views | {{ .Bookmarks }} bookmarks
{{ .Date }} @@ -21,12 +36,22 @@ {{ .Artist.Name }} {{ .Artist.Name }} -
...
+
+ {{ range $parent.Recent }} +
+ + {{ .Title }} + +
+ {{ end }} +

Comments

- {{ end }} + To be added :)
+ {{ end }}
+

Related works

{{ range .Related }}
diff --git a/template/css/style.css b/template/css/style.css index 781fd15..7b79838 100644 --- a/template/css/style.css +++ b/template/css/style.css @@ -134,7 +134,7 @@ body { } .artwork-page .artwork-content { margin: 0 20px; - font-size: 0.8rem; + font-size: 0.9rem; } .artwork-page .artwork-content a { color: #3d7699; @@ -153,14 +153,26 @@ body { height: 50px; object-position: center top; } +.artwork-page .artwork-tags { + display: inline-block; +} +.artwork-page .artwork-tags .artwork-tag-name { + margin-right: 5px; + color: #3d7699; + font-weight: bold; +} +.artwork-page .artwork-tags .artwork-tag-altname { + margin-right: 8px; +} .artwork-page .artwork-images { display: flex; - justify-content: center; + align-items: center; + flex-direction: column; width: 100%; } .artwork-page .artwork-images .artwork-image-page { margin: 10px auto; - height: 578px; + max-height: 578px; width: auto; max-width: 100%; } diff --git a/template/css/style.scss b/template/css/style.scss index f7bf63d..58977ae 100644 --- a/template/css/style.scss +++ b/template/css/style.scss @@ -157,7 +157,7 @@ body { .artwork-content { margin: 0 20px; - font-size: 0.8rem; + font-size: 0.9rem; a { color: $blue; @@ -181,14 +181,28 @@ body { } } + .artwork-tags { + display: inline-block; + + .artwork-tag-name { + margin-right: 5px; + color: $blue; + font-weight: bold; + } + .artwork-tag-altname { + margin-right: 8px; + } + } + .artwork-images { display: flex; - justify-content: center; + align-items: center; + flex-direction: column; width: 100%; .artwork-image-page { margin: 10px auto; - height: 578px; + max-height: 578px; width: auto; max-width: 100%; }