From 4f7ef694c860f6ac82c3c258869a245ce66cc1d2 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 8 Jun 2017 14:46:38 +0200 Subject: [PATCH] Forum activity shown in user profiles --- main.go | 1 + mixins/AnimeGrid.pixy | 2 +- mixins/PostableList.pixy | 3 +++ pages/anime/anime.pixy | 3 +++ pages/anime/anime.scarlet | 3 ++- pages/forum/forum.pixy | 8 ++++--- pages/forums/forums.pixy | 10 ++------- pages/posts/posts.pixy | 2 +- pages/posts/posts.scarlet | 2 +- pages/profile/profile.go | 16 +++++++++++-- pages/profile/profile.pixy | 41 ++++++++++++++++------------------ pages/profile/profile.scarlet | 29 +++++++++++++++++++----- pages/threads/threadsByUser.go | 24 ++++++++++++++++++++ 13 files changed, 100 insertions(+), 44 deletions(-) create mode 100644 mixins/PostableList.pixy create mode 100644 pages/threads/threadsByUser.go diff --git a/main.go b/main.go index 27b96372..de2bd706 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,7 @@ func main() { app.Ajax("/threads/:id", threads.Get) app.Ajax("/posts/:id", posts.Get) app.Ajax("/user/:nick", profile.Get) + app.Ajax("/user/:nick/threads", threads.GetByUser) app.Ajax("/airing", airing.Get) app.Ajax("/users", users.Get) app.Ajax("/awards", awards.Get) diff --git a/mixins/AnimeGrid.pixy b/mixins/AnimeGrid.pixy index 5f776d6d..1581023c 100644 --- a/mixins/AnimeGrid.pixy +++ b/mixins/AnimeGrid.pixy @@ -2,4 +2,4 @@ component AnimeGrid(animeList []*arn.Anime) .anime-grid each anime in animeList a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID)) - img.anime-grid-image(src=anime.Image.Small, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching()) + ")") \ No newline at end of file + img.anime-grid-image(src=anime.Image.Small, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Rating.Overall) + ")") \ No newline at end of file diff --git a/mixins/PostableList.pixy b/mixins/PostableList.pixy new file mode 100644 index 00000000..d7f6af2e --- /dev/null +++ b/mixins/PostableList.pixy @@ -0,0 +1,3 @@ +component PostableList(postables []arn.Postable) + each post in postables + a.ajax(href=post.Link())= post.Title() \ No newline at end of file diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index c6718b16..98e403bf 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -121,6 +121,9 @@ component Anime(anime *arn.Anime) //- if providers.Nyaa && providers.Nyaa.episodes !== undefined //- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps" + h3.anime-section-name Reviews + p Coming soon. + h3.anime-section-name Links .light-button-group //- if anime.Links != nil diff --git a/pages/anime/anime.scarlet b/pages/anime/anime.scarlet index a83c2bfa..94fdbd7c 100644 --- a/pages/anime/anime.scarlet +++ b/pages/anime/anime.scarlet @@ -66,8 +66,9 @@ vertical .sources - font-size 0.8em + font-size 0.8rem opacity 0.5 + margin-top 0.5rem .relations horizontal-wrap diff --git a/pages/forum/forum.pixy b/pages/forum/forum.pixy index 44dd9829..93483807 100644 --- a/pages/forum/forum.pixy +++ b/pages/forum/forum.pixy @@ -1,12 +1,14 @@ component Forum(tag string, threads []*arn.Thread) h2.page-title Forum ForumTags - - each thread in threads - ThreadLink(thread) + ThreadList(threads) button#load-more-threads Load more +component ThreadList(threads []*arn.Thread) + each thread in threads + ThreadLink(thread) + component ThreadLink(thread *arn.Thread) .thread-link(data-sticky=thread.Sticky) .post-author.thread-author diff --git a/pages/forums/forums.pixy b/pages/forums/forums.pixy index 5cb0cdc9..60e70e27 100644 --- a/pages/forums/forums.pixy +++ b/pages/forums/forums.pixy @@ -3,23 +3,17 @@ component Forums ForumTags component ForumTags - .forum-tags + .forum-tags.light-button-group ForumCategory("All", "") - span | ForumCategory("General", "/general") - span | ForumCategory("News", "/news") - span | ForumCategory("Anime", "/anime") - span | ForumCategory("Updates", "/update") - span | ForumCategory("Suggestions", "/suggestion") - span | ForumCategory("Bugs", "/bug") component ForumCategory(title string, suffix string) - a.ajax(href="/forum" + suffix)= title + a.light-button.ajax(href="/forum" + suffix)= title //- a.grid-cell.ajax(href="/forum/" + category) //- .grid-text //- GridIcon(arn.GetForumIcon(category)) diff --git a/pages/posts/posts.pixy b/pages/posts/posts.pixy index 92ac48f4..56b23d6d 100644 --- a/pages/posts/posts.pixy +++ b/pages/posts/posts.pixy @@ -1,5 +1,5 @@ component Post(post *arn.Post) Postable(post.ToPostable(), nil, "") - .thread-source + .side-note a.ajax(href=post.Thread().Link())= post.Thread().Title \ No newline at end of file diff --git a/pages/posts/posts.scarlet b/pages/posts/posts.scarlet index 757dce43..14b7721e 100644 --- a/pages/posts/posts.scarlet +++ b/pages/posts/posts.scarlet @@ -1,3 +1,3 @@ -.thread-source +.side-note font-size 0.9rem text-align right !important \ No newline at end of file diff --git a/pages/profile/profile.go b/pages/profile/profile.go index 5d196cad..19d0c4b4 100644 --- a/pages/profile/profile.go +++ b/pages/profile/profile.go @@ -4,16 +4,28 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" ) +const maxPosts = 5 + // Get ... func Get(ctx *aero.Context) string { nick := ctx.Get("nick") - user, err := arn.GetUserByNick(nick) + viewUser, err := arn.GetUserByNick(nick) + user := utils.GetUser(ctx) if err != nil { return ctx.Error(404, "User not found", err) } - return ctx.HTML(components.Profile(user, nil)) + threads := viewUser.Threads() + + arn.SortThreadsByDate(threads) + + if len(threads) > maxPosts { + threads = threads[:maxPosts] + } + + return ctx.HTML(components.Profile(viewUser, user, threads)) } diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index 92bcf07c..2ed5a69e 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -1,4 +1,4 @@ -component Profile(viewUser *arn.User, user *arn.User) +component Profile(viewUser *arn.User, user *arn.User, threads []*arn.Thread) .profile img.profile-cover(src=viewUser.CoverImageURL()) @@ -22,10 +22,10 @@ component Profile(viewUser *arn.User, user *arn.User) //- Icon("home") //- a(href=viewUser.website.startsWith('http') ? viewUser.website : 'http://' + viewUser.website, target='_blank', rel='nofollow')= viewUser.website.replace('http://', '').replace('https://', '') - //- if user != nil && (user.osu || user.osuDetails) && viewUser.osuDetails && viewUser.osuDetails.pp >= 1000 - //- p.profile-field.osu(title='osu! performance points') - //- i.fa.fa-trophy - //- span= parseInt(viewUser.osuDetails.pp) + ' pp' + if viewUser.Accounts.Osu.Nick != "" && viewUser.Accounts.Osu.PP >= 1000 + p.profile-field.osu(title="osu! performance points") + Icon("trophy") + span= toString(int(viewUser.Accounts.Osu.PP)) + " pp" //- if viewUser.dataEditCount //- p.profile-field.editor-contribution(title="Anime data modifications") @@ -44,20 +44,17 @@ component Profile(viewUser *arn.User, user *arn.User) Icon("rocket") span= arn.Capitalize(viewUser.Role) - //- .a - //- h3 Category - - //- .a - //- h3 Category - - //- .a - //- h3 Category - - //- .a - //- h3 Category - - //- .a - //- h3 Category - - //- .a - //- h3 Category \ No newline at end of file + //- nav.light-button-group + //- a.light-button(href="#") Bio + //- a.light-button(href="#") Anime + //- a.light-button(href="#") Forum + + .profile-category + h3 Forum + + each thread in threads + ThreadLink(thread) + + .side-note + a.ajax(href="/+" + viewUser.Nick + "/threads") View all threads + \ No newline at end of file diff --git a/pages/profile/profile.scarlet b/pages/profile/profile.scarlet index 98cb1756..dc3c550f 100644 --- a/pages/profile/profile.scarlet +++ b/pages/profile/profile.scarlet @@ -17,6 +17,19 @@ profile-boot-duration = 2s overflow hidden +.profile-field + text-align center + +< 600px + .profile + vertical + align-items center + + .intro-container + align-items center + margin-top calc(content-padding * 1.5) + padding-left content-padding + animation appear 0% transform rotateX(90deg) @@ -48,17 +61,23 @@ animation cover-animation .profile-image border-radius 3px - width 320px !important - height 320px !important object-fit cover + width 100% + height auto .image-container - // ... + flex 1 + max-width 320px .intro-container vertical align-items flex-start padding content-padding padding-top 0 - padding-left content-padding * 2 - max-width 900px \ No newline at end of file + padding-left calc(content-padding * 2) + max-width 900px + +// Categories + +.profile-category + // padding content-padding \ No newline at end of file diff --git a/pages/threads/threadsByUser.go b/pages/threads/threadsByUser.go new file mode 100644 index 00000000..7fe5b5f1 --- /dev/null +++ b/pages/threads/threadsByUser.go @@ -0,0 +1,24 @@ +package threads + +import ( + "net/http" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" +) + +// GetByUser ... +func GetByUser(ctx *aero.Context) string { + nick := ctx.Get("nick") + user, err := arn.GetUserByNick(nick) + + if err != nil { + return ctx.Error(http.StatusNotFound, "User not found", err) + } + + threads := user.Threads() + arn.SortThreadsByDate(threads) + + return ctx.HTML(components.ThreadList(threads)) +}