Implemented new frontpage

This commit is contained in:
Eduard Urbach 2017-09-22 17:23:22 +02:00
parent 9c900ec01b
commit 4ce0bed52c
7 changed files with 70 additions and 30 deletions

View File

@ -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)

View File

@ -95,4 +95,4 @@
display none !important
.fill-screen
min-height calc(100vh - nav-height - content-padding * 2 - 1rem - 43px - 23px)
min-height calc(100vh - content-padding * 2 - 1rem - 43px - 23px)

39
pages/home/animelist.go Normal file
View File

@ -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))
}

View File

@ -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)
}

View File

@ -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

View File

@ -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

View File

@ -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
// #search
// display none