This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
render.go
57 lines (44 loc) · 1.47 KB
/
render.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package profilequotes
// import (
// "net/http"
// "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 (
// quotesFirstLoad = 12
// quotesPerScroll = 9
// )
// // render renders the quotes on user profiles.
// func render(ctx *aero.Context, fetch func(userID string) []*arn.Quote) string {
// nick := ctx.Get("nick")
// index, _ := ctx.GetInt("index")
// user := utils.GetUser(ctx)
// viewUser, err := arn.GetUserByNick(nick)
// if err != nil {
// return ctx.Error(http.StatusNotFound, "User not found", err)
// }
// // Fetch all eligible quotes
// allQuotes := fetch(viewUser.ID)
// // Sort the quotes by publication date
// arn.SortQuotesLatestFirst(allQuotes)
// // Slice the part that we need
// quotes := allQuotes[index:]
// maxLength := quotesFirstLoad
// if index > 0 {
// maxLength = quotesPerScroll
// }
// if len(quotes) > maxLength {
// quotes = quotes[:maxLength]
// }
// // Next index
// nextIndex := infinitescroll.NextIndex(ctx, len(allQuotes), maxLength, index)
// // In case we're scrolling, send quotes only (without the page frame)
// if index > 0 {
// return ctx.HTML(components.QuotesScrollable(quotes, user))
// }
// // Otherwise, send the full page
// return ctx.HTML(components.ProfileQuotes(quotes, viewUser, nextIndex, user, ctx.URI()))
// }