Feature: check if the creator turned comments off and fix related works
This commit is contained in:
parent
59689ab87e
commit
5a0c188b0f
4 changed files with 29 additions and 24 deletions
|
@ -151,7 +151,7 @@ func (p *PixivClient) GetRelatedArtworks(id string) ([]models.IllustShort, error
|
|||
Illusts []models.IllustShort `json:"illusts"`
|
||||
}
|
||||
|
||||
URL := fmt.Sprintf(ArtworkCommentsURL, id)
|
||||
URL := fmt.Sprintf(ArtworkRelatedURL, id, 96)
|
||||
|
||||
response, err := p.PixivRequest(URL)
|
||||
if err != nil {
|
||||
|
|
|
@ -93,24 +93,25 @@ type FrequentTag struct {
|
|||
}
|
||||
|
||||
type Illust struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description template.HTML `json:"description"`
|
||||
UserID string `json:"userId"`
|
||||
UserName string `json:"userName"`
|
||||
UserAccount string `json:"userAccount"`
|
||||
Date time.Time `json:"uploadDate"`
|
||||
Images []Image `json:"images"`
|
||||
Tags []Tag `json:"tags"`
|
||||
Pages int `json:"pageCount"`
|
||||
Bookmarks int `json:"bookmarkCount"`
|
||||
Likes int `json:"likeCount"`
|
||||
Comments int `json:"commentCount"`
|
||||
Views int `json:"viewCount"`
|
||||
XRestrict xRestrict `json:"xRestrict"`
|
||||
AiType aiType `json:"aiType"`
|
||||
User UserShort
|
||||
RecentWorks []IllustShort
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description template.HTML `json:"description"`
|
||||
UserID string `json:"userId"`
|
||||
UserName string `json:"userName"`
|
||||
UserAccount string `json:"userAccount"`
|
||||
Date time.Time `json:"uploadDate"`
|
||||
Images []Image `json:"images"`
|
||||
Tags []Tag `json:"tags"`
|
||||
Pages int `json:"pageCount"`
|
||||
Bookmarks int `json:"bookmarkCount"`
|
||||
Likes int `json:"likeCount"`
|
||||
Comments int `json:"commentCount"`
|
||||
Views int `json:"viewCount"`
|
||||
CommentDisabled int `json:"commentOff"`
|
||||
XRestrict xRestrict `json:"xRestrict"`
|
||||
AiType aiType `json:"aiType"`
|
||||
User UserShort
|
||||
RecentWorks []IllustShort
|
||||
}
|
||||
|
||||
type IllustShort struct {
|
||||
|
|
|
@ -50,7 +50,11 @@
|
|||
</div>
|
||||
<hr />
|
||||
<h2>Comments</h2>
|
||||
{{ range Comments }}
|
||||
{{ if Illust.CommentDisabled == 1 }}
|
||||
<p>The creator turned comments off</p>
|
||||
{{ else if Illust.Comments == 0 }}
|
||||
<p>There is no comment yet</p>
|
||||
{{ else }} {{ range Comments }}
|
||||
<div class="comment">
|
||||
<img
|
||||
class="comment-avatar"
|
||||
|
@ -72,7 +76,7 @@
|
|||
<small>{{ .Date }}</small>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }} {{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<h2>Related works</h2>
|
||||
|
|
|
@ -25,13 +25,13 @@ func artwork_page(c *fiber.Ctx) error {
|
|||
return err
|
||||
}
|
||||
|
||||
related, _ := PC.GetRelatedArtworks(id)
|
||||
comments, _ := PC.GetArtworkComments(id)
|
||||
|
||||
related, err := PC.GetRelatedArtworks(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
comments, _ := PC.GetArtworkComments(id)
|
||||
|
||||
// Optimize this
|
||||
return c.Render("artwork", fiber.Map{
|
||||
"Illust": illust,
|
||||
|
|
Loading…
Reference in a new issue