Add user to albums

This commit is contained in:
video-prize-ranch 2022-02-02 10:46:47 -05:00
parent 41012edf9e
commit 6e5b0ee127
No known key found for this signature in database
GPG Key ID: D8EAA4C5B12A7281
4 changed files with 34 additions and 15 deletions

View File

@ -78,7 +78,7 @@ func ParseAlbum(data gjson.Result) (types.Album, error) {
return types.Album{}, err return types.Album{}, err
} }
return types.Album{ album := types.Album{
Id: data.Get("id").String(), Id: data.Get("id").String(),
Title: data.Get("title").String(), Title: data.Get("title").String(),
SharedWithCommunity: data.Get("shared_with_community").Bool(), SharedWithCommunity: data.Get("shared_with_community").Bool(),
@ -88,5 +88,16 @@ func ParseAlbum(data gjson.Result) (types.Album, error) {
Comments: data.Get("comment_count").Int(), Comments: data.Get("comment_count").Int(),
CreatedAt: createdAt, CreatedAt: createdAt,
Media: media, Media: media,
}, nil }
account := data.Get("account")
if account.Raw != "" {
album.User = types.User{
Id: account.Get("id").Int(),
Username: account.Get("username").String(),
Avatar: strings.ReplaceAll(account.Get("avatar_url").String(), "https://i.imgur.com", ""),
}
}
return album, nil
} }

View File

@ -28,5 +28,12 @@ img {
} }
.imageMeta__wrapper { .imageMeta__wrapper {
gap: 2rem; gap: 1rem;
}
.user {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
} }

View File

@ -10,5 +10,6 @@ type Album struct {
CreatedAt string CreatedAt string
UpdatedAt string UpdatedAt string
Comments int64 Comments int64
User User
Media []Media Media []Media
} }

View File

@ -21,6 +21,18 @@
<p>{{album.CreatedAt}}</p> <p>{{album.CreatedAt}}</p>
<div class="imageMeta__wrapper"> <div class="imageMeta__wrapper">
{{#if album.User}}
<div class="user">
<a href="/user/{{album.User.Username}}">
<img src="{{album.User.Avatar}}" class="pfp" width="36" height="36" loading="lazy" />
</a>
<a href="/user/{{album.User.Username}}">
<p>
<b>{{album.User.Username}}</b>
</p>
</a>
</div>
{{/if}}
<div class="imageMeta"> <div class="imageMeta">
<div class="imageMeta__item"> <div class="imageMeta__item">
<span class="material-icons-outlined" title="Views">visibility</span> <span class="material-icons-outlined" title="Views">visibility</span>
@ -31,18 +43,6 @@
<p><span class="material-icons-outlined" title="Dislilkes">thumb_down</span> {{album.Downvotes}}</p> <p><span class="material-icons-outlined" title="Dislilkes">thumb_down</span> {{album.Downvotes}}</p>
{{/if}} {{/if}}
</div> </div>
<!--<div class="videoDesc__channel">
<a href="{{claim.Channel.RelUrl}}">
{{#if claim.Channel.Thumbnail}}
<img src="{{claim.Channel.Thumbnail}}&w=56&h=56" class="pfp" width="56" height="56" loading="lazy" />
{{/if}}
</a>
<a href="{{claim.Channel.RelUrl}}">
<p>
<b>{{claim.Channel.Title}}</b>
</p>
</a>
</div>-->
</div> </div>
<br> <br>