Disabled old profile pages
This commit is contained in:
@ -1,18 +1,18 @@
|
||||
package profilequotes
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
// import (
|
||||
// "github.com/aerogo/aero"
|
||||
// "github.com/animenotifier/arn"
|
||||
// )
|
||||
|
||||
// Added shows all quotes added by a particular user.
|
||||
func Added(ctx *aero.Context) string {
|
||||
return render(ctx, addedQuotes)
|
||||
}
|
||||
// // Added shows all quotes added by a particular user.
|
||||
// func Added(ctx *aero.Context) string {
|
||||
// return render(ctx, addedQuotes)
|
||||
// }
|
||||
|
||||
// addedQuotes returns all quotes that the user with the given user ID published.
|
||||
func addedQuotes(userID string) []*arn.Quote {
|
||||
return arn.FilterQuotes(func(quote *arn.Quote) bool {
|
||||
return !quote.IsDraft && len(quote.Text.English) > 0 && quote.CreatedBy == userID
|
||||
})
|
||||
}
|
||||
// // addedQuotes returns all quotes that the user with the given user ID published.
|
||||
// func addedQuotes(userID string) []*arn.Quote {
|
||||
// return arn.FilterQuotes(func(quote *arn.Quote) bool {
|
||||
// return !quote.IsDraft && len(quote.Text.English) > 0 && quote.CreatedBy == userID
|
||||
// })
|
||||
// }
|
||||
|
@ -1,18 +1,18 @@
|
||||
package profilequotes
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
// import (
|
||||
// "github.com/aerogo/aero"
|
||||
// "github.com/animenotifier/arn"
|
||||
// )
|
||||
|
||||
// Liked shows all quotes liked by a particular user.
|
||||
func Liked(ctx *aero.Context) string {
|
||||
return render(ctx, likedQuotes)
|
||||
}
|
||||
// // Liked shows all quotes liked by a particular user.
|
||||
// func Liked(ctx *aero.Context) string {
|
||||
// return render(ctx, likedQuotes)
|
||||
// }
|
||||
|
||||
// likedQuotes returns all quotes that the user with the given user ID liked.
|
||||
func likedQuotes(userID string) []*arn.Quote {
|
||||
return arn.FilterQuotes(func(track *arn.Quote) bool {
|
||||
return !track.IsDraft && len(track.Text.English) > 0 && track.LikedBy(userID)
|
||||
})
|
||||
}
|
||||
// // likedQuotes returns all quotes that the user with the given user ID liked.
|
||||
// func likedQuotes(userID string) []*arn.Quote {
|
||||
// return arn.FilterQuotes(func(track *arn.Quote) bool {
|
||||
// return !track.IsDraft && len(track.Text.English) > 0 && track.LikedBy(userID)
|
||||
// })
|
||||
// }
|
||||
|
@ -1,57 +1,57 @@
|
||||
package profilequotes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
// 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"
|
||||
)
|
||||
// "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
|
||||
)
|
||||
// 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)
|
||||
// // 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)
|
||||
}
|
||||
// if err != nil {
|
||||
// return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||
// }
|
||||
|
||||
// Fetch all eligible quotes
|
||||
allQuotes := fetch(viewUser.ID)
|
||||
// // Fetch all eligible quotes
|
||||
// allQuotes := fetch(viewUser.ID)
|
||||
|
||||
// Sort the quotes by publication date
|
||||
arn.SortQuotesLatestFirst(allQuotes)
|
||||
// // Sort the quotes by publication date
|
||||
// arn.SortQuotesLatestFirst(allQuotes)
|
||||
|
||||
// Slice the part that we need
|
||||
quotes := allQuotes[index:]
|
||||
maxLength := quotesFirstLoad
|
||||
// // Slice the part that we need
|
||||
// quotes := allQuotes[index:]
|
||||
// maxLength := quotesFirstLoad
|
||||
|
||||
if index > 0 {
|
||||
maxLength = quotesPerScroll
|
||||
}
|
||||
// if index > 0 {
|
||||
// maxLength = quotesPerScroll
|
||||
// }
|
||||
|
||||
if len(quotes) > maxLength {
|
||||
quotes = quotes[:maxLength]
|
||||
}
|
||||
// if len(quotes) > maxLength {
|
||||
// quotes = quotes[:maxLength]
|
||||
// }
|
||||
|
||||
// Next index
|
||||
nextIndex := infinitescroll.NextIndex(ctx, len(allQuotes), maxLength, index)
|
||||
// // 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))
|
||||
}
|
||||
// // 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()))
|
||||
}
|
||||
// // Otherwise, send the full page
|
||||
// return ctx.HTML(components.ProfileQuotes(quotes, viewUser, nextIndex, user, ctx.URI()))
|
||||
// }
|
||||
|
Reference in New Issue
Block a user