From c42ec17b84a704612ff23df180efb0682de401a3 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 19 Jun 2017 22:16:01 +0200 Subject: [PATCH] UI improvements --- main.go | 2 ++ pages/anime/anime.pixy | 8 ++++---- pages/animelist/animelist.go | 32 +++++++++++++++++++++++++++++++ pages/animelist/animelist.pixy | 13 +++++++++++++ pages/animelist/animelist.scarlet | 2 ++ pages/profile/anime-list.scarlet | 15 --------------- pages/profile/profile.pixy | 19 +++++++++--------- pages/profile/watching.scarlet | 9 +++++++++ styles/headers.scarlet | 2 +- 9 files changed, 72 insertions(+), 30 deletions(-) create mode 100644 pages/animelist/animelist.go create mode 100644 pages/animelist/animelist.pixy create mode 100644 pages/animelist/animelist.scarlet delete mode 100644 pages/profile/anime-list.scarlet create mode 100644 pages/profile/watching.scarlet diff --git a/main.go b/main.go index 56907ea9..a52f0cd1 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "github.com/animenotifier/notify.moe/pages/admin" "github.com/animenotifier/notify.moe/pages/airing" "github.com/animenotifier/notify.moe/pages/anime" + "github.com/animenotifier/notify.moe/pages/animelist" "github.com/animenotifier/notify.moe/pages/animelistitem" "github.com/animenotifier/notify.moe/pages/awards" "github.com/animenotifier/notify.moe/pages/dashboard" @@ -51,6 +52,7 @@ func main() { app.Ajax("/posts/:id", posts.Get) app.Ajax("/user/:nick", profile.Get) app.Ajax("/user/:nick/threads", profile.GetThreadsByUser) + app.Ajax("/user/:nick/animelist", animelist.Get) app.Ajax("/user/:nick/animelist/:id", animelistitem.Get) app.Ajax("/settings", settings.Get) app.Ajax("/admin", admin.Get) diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 91b96e65..d7b7a83c 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -28,16 +28,16 @@ component Anime(anime *arn.Anime, user *arn.User) h3.anime-section-name Ratings .anime-rating-categories - .anime-rating-category(title=toString(anime.Rating.Overall)) + .anime-rating-category(title=toString(anime.Rating.Overall / 10)) .anime-rating-category-name Overall Rating(anime.Rating.Overall) - .anime-rating-category(title=toString(anime.Rating.Story)) + .anime-rating-category(title=toString(anime.Rating.Story / 10)) .anime-rating-category-name Story Rating(anime.Rating.Story) - .anime-rating-category(title=toString(anime.Rating.Visuals)) + .anime-rating-category(title=toString(anime.Rating.Visuals / 10)) .anime-rating-category-name Visuals Rating(anime.Rating.Visuals) - .anime-rating-category(title=toString(anime.Rating.Music)) + .anime-rating-category(title=toString(anime.Rating.Music / 10)) .anime-rating-category-name Music Rating(anime.Rating.Music) diff --git a/pages/animelist/animelist.go b/pages/animelist/animelist.go new file mode 100644 index 00000000..0982543f --- /dev/null +++ b/pages/animelist/animelist.go @@ -0,0 +1,32 @@ +package animelist + +import ( + "net/http" + "sort" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" +) + +// Get anime list. +func Get(ctx *aero.Context) string { + nick := ctx.Get("nick") + viewUser, err := arn.GetUserByNick(nick) + + if err != nil { + return ctx.Error(http.StatusNotFound, "User not found", err) + } + + animeList := viewUser.AnimeList() + + if animeList == nil { + return ctx.Error(http.StatusNotFound, "Anime list not found", err) + } + + sort.Slice(animeList.Items, func(i, j int) bool { + return animeList.Items[i].FinalRating() < animeList.Items[j].FinalRating() + }) + + return ctx.HTML(components.AnimeList(animeList)) +} diff --git a/pages/animelist/animelist.pixy b/pages/animelist/animelist.pixy new file mode 100644 index 00000000..bf01304a --- /dev/null +++ b/pages/animelist/animelist.pixy @@ -0,0 +1,13 @@ +component AnimeList(animeList *arn.AnimeList) + table.anime-list + thead + tr + th Anime + th Progress + th Rating + tbody + each item in animeList.Items + tr.anime-list-item + td= item.Anime().Title.Canonical + td= toString(item.Episodes) + " / " + item.Anime().EpisodeCountString() + td= item.FinalRating() \ No newline at end of file diff --git a/pages/animelist/animelist.scarlet b/pages/animelist/animelist.scarlet new file mode 100644 index 00000000..9c77fd1d --- /dev/null +++ b/pages/animelist/animelist.scarlet @@ -0,0 +1,2 @@ +.anime-list + // \ No newline at end of file diff --git a/pages/profile/anime-list.scarlet b/pages/profile/anime-list.scarlet deleted file mode 100644 index 28c58800..00000000 --- a/pages/profile/anime-list.scarlet +++ /dev/null @@ -1,15 +0,0 @@ -.anime-list - horizontal-wrap - -.anime-list-item - margin 0.25rem - // padding calc(content-padding / 4) calc(content-padding / 2) - // margin 0.25rem 0 - // position relative - -.anime-list-item-image - width 55px !important - border-radius 2px - // position absolute - // left 0 - // top 0 \ No newline at end of file diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index 77848934..b1a6a4f1 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -50,25 +50,24 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, //- a.light-button(href="#") Forum .profile-category - h3 Anime + h3 + a.ajax(href="/+" + viewUser.Nick + "/animelist", title="View all anime") Anime - .anime-list + .profile-watching-list if len(animeList.Items) == 0 p No anime in the collection. else each item in animeList.Items - a.anime-list-item.ajax(href="/+" + viewUser.Nick + "/animelist/" + item.Anime().ID, title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")") - img.anime-cover-image.anime-list-item-image(src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical) + a.profile-watching-list-item.ajax(href="/+" + viewUser.Nick + "/animelist/" + item.Anime().ID, title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")") + img.anime-cover-image.profile-watching-list-item-image(src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical) .profile-category - h3 Forum + h3 + a.ajax(href="/+" + viewUser.Nick + "/threads", title="View all threads") Threads - if len(animeList.Items) == 0 - p No activity on the forum. + if len(threads) == 0 + p No threads on the forum. else 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/watching.scarlet b/pages/profile/watching.scarlet new file mode 100644 index 00000000..29699c9d --- /dev/null +++ b/pages/profile/watching.scarlet @@ -0,0 +1,9 @@ +.profile-watching-list + horizontal-wrap + +.profile-watching-list-item + margin 0.25rem + +.profile-watching-list-item-image + width 55px !important + border-radius 2px \ No newline at end of file diff --git a/styles/headers.scarlet b/styles/headers.scarlet index 1a2d55c4..e16bfae9 100644 --- a/styles/headers.scarlet +++ b/styles/headers.scarlet @@ -13,7 +13,7 @@ h3 text-align left margin-top 0.6em -h2 +h2, h3 a color text-color