Implemented group image upload
This commit is contained in:
43
pages/groups/render.go
Normal file
43
pages/groups/render.go
Normal file
@ -0,0 +1,43 @@
|
||||
package groups
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||
)
|
||||
|
||||
const (
|
||||
groupsFirstLoad = 12
|
||||
groupsPerScroll = 9
|
||||
)
|
||||
|
||||
// render renders the groups page with the given groups.
|
||||
func render(ctx *aero.Context, allGroups []*arn.Group) string {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
|
||||
// Slice the part that we need
|
||||
groups := allGroups[index:]
|
||||
maxLength := groupsFirstLoad
|
||||
|
||||
if index > 0 {
|
||||
maxLength = groupsPerScroll
|
||||
}
|
||||
|
||||
if len(groups) > maxLength {
|
||||
groups = groups[:maxLength]
|
||||
}
|
||||
|
||||
// Next index
|
||||
nextIndex := infinitescroll.NextIndex(ctx, len(allGroups), maxLength, index)
|
||||
|
||||
// In case we're scrolling, send groups only (without the page frame)
|
||||
if index > 0 {
|
||||
return ctx.HTML(components.GroupsScrollable(groups, user))
|
||||
}
|
||||
|
||||
// Otherwise, send the full page
|
||||
return ctx.HTML(components.Groups(groups, nextIndex, user))
|
||||
}
|
Reference in New Issue
Block a user