From 6e5b0ee127c0fb75cee9293ecbafd069c1fb006c Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Wed, 2 Feb 2022 10:46:47 -0500 Subject: [PATCH] Add user to albums --- api/album.go | 15 +++++++++++++-- static/css/album.css | 9 ++++++++- types/Album.go | 1 + views/gallery.hbs | 24 ++++++++++++------------ 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/api/album.go b/api/album.go index 9d808a9..4060e29 100644 --- a/api/album.go +++ b/api/album.go @@ -78,7 +78,7 @@ func ParseAlbum(data gjson.Result) (types.Album, error) { return types.Album{}, err } - return types.Album{ + album := types.Album{ Id: data.Get("id").String(), Title: data.Get("title").String(), 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(), CreatedAt: createdAt, 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 } diff --git a/static/css/album.css b/static/css/album.css index 96d028a..1563b06 100644 --- a/static/css/album.css +++ b/static/css/album.css @@ -28,5 +28,12 @@ img { } .imageMeta__wrapper { - gap: 2rem; + gap: 1rem; +} + +.user { + display: flex; + flex-direction: row; + align-items: center; + gap: 5px; } \ No newline at end of file diff --git a/types/Album.go b/types/Album.go index b85e8b8..eae7ef5 100644 --- a/types/Album.go +++ b/types/Album.go @@ -10,5 +10,6 @@ type Album struct { CreatedAt string UpdatedAt string Comments int64 + User User Media []Media } diff --git a/views/gallery.hbs b/views/gallery.hbs index afa0a53..8067774 100644 --- a/views/gallery.hbs +++ b/views/gallery.hbs @@ -21,6 +21,18 @@

{{album.CreatedAt}}

+ {{#if album.User}} + + {{/if}}
visibility @@ -31,18 +43,6 @@

thumb_down {{album.Downvotes}}

{{/if}}
-