From 4ce0bed52c8c64d6bf1636538cc3198040765fda Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 22 Sep 2017 17:23:22 +0200 Subject: [PATCH] Implemented new frontpage --- main.go | 7 ++++++ pages/animelist/animelist.scarlet | 2 +- pages/home/animelist.go | 39 +++++++++++++++++++++++++++++++ pages/home/home.go | 15 ++---------- scripts/AnimeNotifier.ts | 5 ++++ styles/include/config.scarlet | 4 ++-- styles/navigation.scarlet | 28 +++++++++++----------- 7 files changed, 70 insertions(+), 30 deletions(-) create mode 100644 pages/home/animelist.go diff --git a/main.go b/main.go index 4cdb14ed..f0dd2d35 100644 --- a/main.go +++ b/main.go @@ -110,6 +110,13 @@ func configure(app *aero.Application) *aero.Application { app.Ajax("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped)) app.Ajax("/user/:nick/animelist/anime/:id", animelistitem.Get) + // Anime list + app.Ajax("/animelist/watching", home.FilterByStatus(arn.AnimeListStatusWatching)) + app.Ajax("/animelist/completed", home.FilterByStatus(arn.AnimeListStatusCompleted)) + app.Ajax("/animelist/planned", home.FilterByStatus(arn.AnimeListStatusPlanned)) + app.Ajax("/animelist/hold", home.FilterByStatus(arn.AnimeListStatusHold)) + app.Ajax("/animelist/dropped", home.FilterByStatus(arn.AnimeListStatusDropped)) + // Search app.Ajax("/search", search.Get) app.Ajax("/search/:term", search.Get) diff --git a/pages/animelist/animelist.scarlet b/pages/animelist/animelist.scarlet index 475afdc5..73104afe 100644 --- a/pages/animelist/animelist.scarlet +++ b/pages/animelist/animelist.scarlet @@ -95,4 +95,4 @@ display none !important .fill-screen - min-height calc(100vh - nav-height - content-padding * 2 - 1rem - 43px - 23px) \ No newline at end of file + min-height calc(100vh - content-padding * 2 - 1rem - 43px - 23px) \ No newline at end of file diff --git a/pages/home/animelist.go b/pages/home/animelist.go new file mode 100644 index 00000000..8cff7a18 --- /dev/null +++ b/pages/home/animelist.go @@ -0,0 +1,39 @@ +package home + +import ( + "net/http" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/pages/frontpage" + "github.com/animenotifier/notify.moe/utils" +) + +// FilterByStatus returns a handler for the given anime list item status. +func FilterByStatus(status string) aero.Handle { + return func(ctx *aero.Context) string { + user := utils.GetUser(ctx) + + if user == nil { + return frontpage.Get(ctx) + } + + return AnimeList(ctx, user, status) + } +} + +// AnimeList sends the anime list with the given status for given user. +func AnimeList(ctx *aero.Context, user *arn.User, status string) string { + viewUser := user + animeList := viewUser.AnimeList() + + if animeList == nil { + return ctx.Error(http.StatusNotFound, "Anime list not found", nil) + } + + animeList.PrefetchAnime() + animeList.Sort() + + return ctx.HTML(components.Home(animeList.FilterStatus(status), viewUser, user, status)) +} diff --git a/pages/home/home.go b/pages/home/home.go index 411c8d98..1766a40d 100644 --- a/pages/home/home.go +++ b/pages/home/home.go @@ -1,10 +1,9 @@ package home import ( - "net/http" + "github.com/animenotifier/arn" "github.com/aerogo/aero" - "github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/pages/frontpage" "github.com/animenotifier/notify.moe/utils" ) @@ -17,15 +16,5 @@ func Get(ctx *aero.Context) string { return frontpage.Get(ctx) } - viewUser := user - animeList := viewUser.AnimeList() - - if animeList == nil { - return ctx.Error(http.StatusNotFound, "Anime list not found", nil) - } - - animeList.PrefetchAnime() - animeList.Sort() - - return ctx.HTML(components.Home(animeList.Watching(), animeList.User(), user, "watching")) + return AnimeList(ctx, user, arn.AnimeListStatusWatching) } diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 33769de5..e1693928 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -619,6 +619,11 @@ export class AnimeNotifier { let newScroll = 0 let finalScroll = Math.max(target.offsetTop - contentPadding, 0) let scrollDistance = finalScroll - oldScroll + + if(scrollDistance > 0 && scrollDistance < 4) { + return + } + let timeStart = Date.now() let timeEnd = timeStart + duration diff --git a/styles/include/config.scarlet b/styles/include/config.scarlet index 7b18e37c..a7c21a28 100644 --- a/styles/include/config.scarlet +++ b/styles/include/config.scarlet @@ -66,6 +66,6 @@ nav-height = 3.11rem typography-margin = 0.4rem // Timings -fade-speed = 300ms +fade-speed = 250ms transition-speed = 200ms -mountable-transition-speed = 300ms +mountable-transition-speed = 250ms diff --git a/styles/navigation.scarlet b/styles/navigation.scarlet index bbfde471..fedf1a17 100644 --- a/styles/navigation.scarlet +++ b/styles/navigation.scarlet @@ -82,21 +82,21 @@ .extra-navigation display block -@media screen and (max-device-height: 500px) - #navigation - vertical - height 100% - padding content-padding 0 +// @media screen and (max-device-height: 500px) +// #navigation +// vertical +// height 100% +// padding content-padding 0 - #container - horizontal +// #container +// horizontal - .extra-navigation - display block +// .extra-navigation +// display block - #sidebar-toggle, - .hide-landscape - display none !important +// #sidebar-toggle, +// .hide-landscape +// display none !important - #search - display none \ No newline at end of file +// #search +// display none \ No newline at end of file