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 := . }}
+ {{ if eq .Pages 1 }}
+
+ {{ .Caption }}
-Tags
-