From 4f6ffd969d7f84788b426f502a561e8e7a62a678 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 3 Jul 2017 17:33:57 +0200 Subject: [PATCH] Improved user profiles --- pages/animelist/animelist.pixy | 2 +- pages/forum/forum.pixy | 3 +-- pages/profile/posts.pixy | 2 +- pages/profile/profile.pixy | 10 +++++----- pages/profile/profile.scarlet | 3 +++ pages/profile/threads.go | 6 ++++++ pages/profile/threads.pixy | 7 +++++-- pages/profile/tracks.pixy | 2 +- pages/search/search.pixy | 4 ++-- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/pages/animelist/animelist.pixy b/pages/animelist/animelist.pixy index e58a792c..bf85ef74 100644 --- a/pages/animelist/animelist.pixy +++ b/pages/animelist/animelist.pixy @@ -4,7 +4,7 @@ component AnimeLists(animeLists map[string]*arn.AnimeList, viewUser *arn.User, u h2.page-title.anime-list-owner= viewUser.Nick + "'s collection" if len(animeLists[arn.AnimeListStatusWatching].Items) == 0 && len(animeLists[arn.AnimeListStatusCompleted].Items) == 0 && len(animeLists[arn.AnimeListStatusPlanned].Items) == 0 && len(animeLists[arn.AnimeListStatusHold].Items) == 0 && len(animeLists[arn.AnimeListStatusDropped].Items) == 0 - p.no-data No anime in the collection. + p.no-data.mountable= viewUser.Nick + " hasn't added any anime yet." else if len(animeLists[arn.AnimeListStatusWatching].Items) > 0 .anime-list-container diff --git a/pages/forum/forum.pixy b/pages/forum/forum.pixy index 97fdff94..1b04acc3 100644 --- a/pages/forum/forum.pixy +++ b/pages/forum/forum.pixy @@ -4,7 +4,6 @@ component Forum(tag string, threads []*arn.Thread, threadsPerPage int) .forum ThreadList(threads) - .buttons button#new-thread.action(data-action="load", data-trigger="click", data-url="/new/thread") Icon("plus") @@ -16,7 +15,7 @@ component Forum(tag string, threads []*arn.Thread, threadsPerPage int) component ThreadList(threads []*arn.Thread) if len(threads) == 0 - p.no-data No threads found. + p.no-data.mountable No threads found. else each thread in threads ThreadLink(thread) \ No newline at end of file diff --git a/pages/profile/posts.pixy b/pages/profile/posts.pixy index 534addb8..e6a4e9de 100644 --- a/pages/profile/posts.pixy +++ b/pages/profile/posts.pixy @@ -5,4 +5,4 @@ component LatestPosts(postables []arn.Postable, viewUser *arn.User, user *arn.Us h2.page-title= len(postables), " latest posts by ", postables[0].Author().Nick PostableList(postables) else - p= viewUser.Nick + " hasn't written any posts yet." \ No newline at end of file + p.no-data.mountable= viewUser.Nick + " hasn't written any posts yet." \ No newline at end of file diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index 457f533e..483c923b 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -54,7 +54,7 @@ component ProfileNavigation(viewUser *arn.User) a.button.tab.action(href="/+" + viewUser.Nick + "/animelist", data-action="diff", data-trigger="click") Icon("list") - span.tab-text List + span.tab-text Collection a.button.tab.action(href="/+" + viewUser.Nick + "/threads", data-action="diff", data-trigger="click") Icon("comment") @@ -71,10 +71,10 @@ component ProfileNavigation(viewUser *arn.User) component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post, tracks []*arn.SoundTrack) ProfileHeader(viewUser, user) - .profile-watching-list.mountable - if len(animeList.Items) == 0 - p.no-data No anime in the collection. - else + if len(animeList.Items) == 0 + p.no-data.mountable= viewUser.Nick + " hasn't added any anime yet." + else + .profile-watching-list.mountable each item in animeList.Items a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")") img.anime-cover-image.profile-watching-list-item-image.lazy(data-src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical) diff --git a/pages/profile/profile.scarlet b/pages/profile/profile.scarlet index e0d74bcb..7ec638c4 100644 --- a/pages/profile/profile.scarlet +++ b/pages/profile/profile.scarlet @@ -86,6 +86,9 @@ profile-boot-duration = 2s #nick margin-bottom 1rem +.no-data + text-align center + // Categories // .profile-category diff --git a/pages/profile/threads.go b/pages/profile/threads.go index 5f267439..b886c6bd 100644 --- a/pages/profile/threads.go +++ b/pages/profile/threads.go @@ -9,6 +9,8 @@ import ( "github.com/animenotifier/notify.moe/utils" ) +const maxThreads = 20 + // GetThreadsByUser shows all forum threads of a particular user. func GetThreadsByUser(ctx *aero.Context) string { nick := ctx.Get("nick") @@ -21,5 +23,9 @@ func GetThreadsByUser(ctx *aero.Context) string { threads := viewUser.Threads() arn.SortThreadsLatestFirst(threads) + if len(threads) > maxThreads { + threads = threads[:maxThreads] + } + return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx))) } diff --git a/pages/profile/threads.pixy b/pages/profile/threads.pixy index 993a7216..daad69f8 100644 --- a/pages/profile/threads.pixy +++ b/pages/profile/threads.pixy @@ -1,5 +1,8 @@ component ProfileThreads(threads []*arn.Thread, viewUser *arn.User, user *arn.User) ProfileHeader(viewUser, user) - .forum - ThreadList(threads) + if len(threads) == 0 + p.no-data.mountable= viewUser.Nick + " hasn't written any threads yet." + else + .forum + ThreadList(threads) diff --git a/pages/profile/tracks.pixy b/pages/profile/tracks.pixy index 13981fdf..3adc47ee 100644 --- a/pages/profile/tracks.pixy +++ b/pages/profile/tracks.pixy @@ -4,7 +4,7 @@ component TrackList(tracks []*arn.SoundTrack, viewUser *arn.User, user *arn.User h2.page-title= "Tracks added by " + viewUser.Nick if len(tracks) == 0 - p.no-data No tracks added. + p.no-data.mountable= viewUser.Nick + " hasn't added any tracks yet." else .sound-tracks each track in tracks diff --git a/pages/search/search.pixy b/pages/search/search.pixy index a7e8b16c..c588f2b5 100644 --- a/pages/search/search.pixy +++ b/pages/search/search.pixy @@ -4,7 +4,7 @@ component SearchResults(users []*arn.User, animeResults []*arn.Anime) h3 Users .user-avatars.user-search if len(users) == 0 - p.no-data No users found. + p.no-data.mountable No users found. else each user in users .mountable(data-mountable-type="user") @@ -15,7 +15,7 @@ component SearchResults(users []*arn.User, animeResults []*arn.Anime) h3 Anime .profile-watching-list.anime-search if len(animeResults) == 0 - p.no-data No anime found. + p.no-data.mountable No anime found. else each anime in animeResults a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")