Disabled old profile pages
This commit is contained in:
parent
99e7ded4c4
commit
ba57870cc9
@ -1,44 +1,44 @@
|
|||||||
package profilecharacters
|
package profilecharacters
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"net/http"
|
// "net/http"
|
||||||
"sort"
|
// "sort"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
// "github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
// "github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Liked shows all liked characters of a particular user.
|
// // Liked shows all liked characters of a particular user.
|
||||||
func Liked(ctx *aero.Context) string {
|
// func Liked(ctx *aero.Context) string {
|
||||||
nick := ctx.Get("nick")
|
// nick := ctx.Get("nick")
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
// viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "User not found", err)
|
// return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
characters := []*arn.Character{}
|
// characters := []*arn.Character{}
|
||||||
|
|
||||||
for character := range arn.StreamCharacters() {
|
// for character := range arn.StreamCharacters() {
|
||||||
if arn.Contains(character.Likes, viewUser.ID) {
|
// if arn.Contains(character.Likes, viewUser.ID) {
|
||||||
characters = append(characters, character)
|
// characters = append(characters, character)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
sort.Slice(characters, func(i, j int) bool {
|
// sort.Slice(characters, func(i, j int) bool {
|
||||||
return characters[i].Name.Canonical < characters[j].Name.Canonical
|
// return characters[i].Name.Canonical < characters[j].Name.Canonical
|
||||||
|
|
||||||
// aLikes := len(characters[i].Likes)
|
// // aLikes := len(characters[i].Likes)
|
||||||
// bLikes := len(characters[j].Likes)
|
// // bLikes := len(characters[j].Likes)
|
||||||
|
|
||||||
// if aLikes == bLikes {
|
// // if aLikes == bLikes {
|
||||||
// return characters[i].Name.Canonical < characters[j].Name.Canonical
|
// // return characters[i].Name.Canonical < characters[j].Name.Canonical
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// return aLikes > bLikes
|
// // return aLikes > bLikes
|
||||||
})
|
// })
|
||||||
|
|
||||||
return ctx.HTML(components.ProfileCharacters(characters, viewUser, utils.GetUser(ctx), ctx.URI()))
|
// return ctx.HTML(components.ProfileCharacters(characters, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||||
}
|
// }
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package profilequotes
|
package profilequotes
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Added shows all quotes added by a particular user.
|
// // Added shows all quotes added by a particular user.
|
||||||
func Added(ctx *aero.Context) string {
|
// func Added(ctx *aero.Context) string {
|
||||||
return render(ctx, addedQuotes)
|
// return render(ctx, addedQuotes)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// addedQuotes returns all quotes that the user with the given user ID published.
|
// // addedQuotes returns all quotes that the user with the given user ID published.
|
||||||
func addedQuotes(userID string) []*arn.Quote {
|
// func addedQuotes(userID string) []*arn.Quote {
|
||||||
return arn.FilterQuotes(func(quote *arn.Quote) bool {
|
// return arn.FilterQuotes(func(quote *arn.Quote) bool {
|
||||||
return !quote.IsDraft && len(quote.Text.English) > 0 && quote.CreatedBy == userID
|
// return !quote.IsDraft && len(quote.Text.English) > 0 && quote.CreatedBy == userID
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package profilequotes
|
package profilequotes
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Liked shows all quotes liked by a particular user.
|
// // Liked shows all quotes liked by a particular user.
|
||||||
func Liked(ctx *aero.Context) string {
|
// func Liked(ctx *aero.Context) string {
|
||||||
return render(ctx, likedQuotes)
|
// return render(ctx, likedQuotes)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// likedQuotes returns all quotes that the user with the given user ID liked.
|
// // likedQuotes returns all quotes that the user with the given user ID liked.
|
||||||
func likedQuotes(userID string) []*arn.Quote {
|
// func likedQuotes(userID string) []*arn.Quote {
|
||||||
return arn.FilterQuotes(func(track *arn.Quote) bool {
|
// return arn.FilterQuotes(func(track *arn.Quote) bool {
|
||||||
return !track.IsDraft && len(track.Text.English) > 0 && track.LikedBy(userID)
|
// return !track.IsDraft && len(track.Text.English) > 0 && track.LikedBy(userID)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
@ -1,57 +1,57 @@
|
|||||||
package profilequotes
|
package profilequotes
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"net/http"
|
// "net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
// "github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
// "github.com/animenotifier/notify.moe/utils"
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
// "github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
// )
|
||||||
|
|
||||||
const (
|
// const (
|
||||||
quotesFirstLoad = 12
|
// quotesFirstLoad = 12
|
||||||
quotesPerScroll = 9
|
// quotesPerScroll = 9
|
||||||
)
|
// )
|
||||||
|
|
||||||
// render renders the quotes on user profiles.
|
// // render renders the quotes on user profiles.
|
||||||
func render(ctx *aero.Context, fetch func(userID string) []*arn.Quote) string {
|
// func render(ctx *aero.Context, fetch func(userID string) []*arn.Quote) string {
|
||||||
nick := ctx.Get("nick")
|
// nick := ctx.Get("nick")
|
||||||
index, _ := ctx.GetInt("index")
|
// index, _ := ctx.GetInt("index")
|
||||||
user := utils.GetUser(ctx)
|
// user := utils.GetUser(ctx)
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
// viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "User not found", err)
|
// return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Fetch all eligible quotes
|
// // Fetch all eligible quotes
|
||||||
allQuotes := fetch(viewUser.ID)
|
// allQuotes := fetch(viewUser.ID)
|
||||||
|
|
||||||
// Sort the quotes by publication date
|
// // Sort the quotes by publication date
|
||||||
arn.SortQuotesLatestFirst(allQuotes)
|
// arn.SortQuotesLatestFirst(allQuotes)
|
||||||
|
|
||||||
// Slice the part that we need
|
// // Slice the part that we need
|
||||||
quotes := allQuotes[index:]
|
// quotes := allQuotes[index:]
|
||||||
maxLength := quotesFirstLoad
|
// maxLength := quotesFirstLoad
|
||||||
|
|
||||||
if index > 0 {
|
// if index > 0 {
|
||||||
maxLength = quotesPerScroll
|
// maxLength = quotesPerScroll
|
||||||
}
|
// }
|
||||||
|
|
||||||
if len(quotes) > maxLength {
|
// if len(quotes) > maxLength {
|
||||||
quotes = quotes[:maxLength]
|
// quotes = quotes[:maxLength]
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Next index
|
// // Next index
|
||||||
nextIndex := infinitescroll.NextIndex(ctx, len(allQuotes), maxLength, index)
|
// nextIndex := infinitescroll.NextIndex(ctx, len(allQuotes), maxLength, index)
|
||||||
|
|
||||||
// In case we're scrolling, send quotes only (without the page frame)
|
// // In case we're scrolling, send quotes only (without the page frame)
|
||||||
if index > 0 {
|
// if index > 0 {
|
||||||
return ctx.HTML(components.QuotesScrollable(quotes, user))
|
// return ctx.HTML(components.QuotesScrollable(quotes, user))
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Otherwise, send the full page
|
// // Otherwise, send the full page
|
||||||
return ctx.HTML(components.ProfileQuotes(quotes, viewUser, nextIndex, user, ctx.URI()))
|
// return ctx.HTML(components.ProfileQuotes(quotes, viewUser, nextIndex, user, ctx.URI()))
|
||||||
}
|
// }
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package profiletracks
|
package profiletracks
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Added shows all soundtracks added by a particular user.
|
// // Added shows all soundtracks added by a particular user.
|
||||||
func Added(ctx *aero.Context) string {
|
// func Added(ctx *aero.Context) string {
|
||||||
return render(ctx, addedTracks)
|
// return render(ctx, addedTracks)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// addedTracks returns all soundtracks that the user with the given user ID published.
|
// // addedTracks returns all soundtracks that the user with the given user ID published.
|
||||||
func addedTracks(userID string) []*arn.SoundTrack {
|
// func addedTracks(userID string) []*arn.SoundTrack {
|
||||||
return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
// return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
||||||
return !track.IsDraft && len(track.Media) > 0 && track.CreatedBy == userID
|
// return !track.IsDraft && len(track.Media) > 0 && track.CreatedBy == userID
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package profiletracks
|
package profiletracks
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Liked shows all soundtracks liked by a particular user.
|
// // Liked shows all soundtracks liked by a particular user.
|
||||||
func Liked(ctx *aero.Context) string {
|
// func Liked(ctx *aero.Context) string {
|
||||||
return render(ctx, likedTracks)
|
// return render(ctx, likedTracks)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// likedTracks returns all soundtracks that the user with the given user ID liked.
|
// // likedTracks returns all soundtracks that the user with the given user ID liked.
|
||||||
func likedTracks(userID string) []*arn.SoundTrack {
|
// func likedTracks(userID string) []*arn.SoundTrack {
|
||||||
return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
// return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
||||||
return !track.IsDraft && len(track.Media) > 0 && track.LikedBy(userID)
|
// return !track.IsDraft && len(track.Media) > 0 && track.LikedBy(userID)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
@ -1,57 +1,57 @@
|
|||||||
package profiletracks
|
package profiletracks
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"net/http"
|
// "net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
// "github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
// "github.com/animenotifier/notify.moe/utils"
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
// "github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
// )
|
||||||
|
|
||||||
const (
|
// const (
|
||||||
tracksFirstLoad = 12
|
// tracksFirstLoad = 12
|
||||||
tracksPerScroll = 9
|
// tracksPerScroll = 9
|
||||||
)
|
// )
|
||||||
|
|
||||||
// render renders the soundtracks on user profiles.
|
// // render renders the soundtracks on user profiles.
|
||||||
func render(ctx *aero.Context, fetch func(userID string) []*arn.SoundTrack) string {
|
// func render(ctx *aero.Context, fetch func(userID string) []*arn.SoundTrack) string {
|
||||||
nick := ctx.Get("nick")
|
// nick := ctx.Get("nick")
|
||||||
index, _ := ctx.GetInt("index")
|
// index, _ := ctx.GetInt("index")
|
||||||
user := utils.GetUser(ctx)
|
// user := utils.GetUser(ctx)
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
// viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "User not found", err)
|
// return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Fetch all eligible tracks
|
// // Fetch all eligible tracks
|
||||||
allTracks := fetch(viewUser.ID)
|
// allTracks := fetch(viewUser.ID)
|
||||||
|
|
||||||
// Sort the tracks by publication date
|
// // Sort the tracks by publication date
|
||||||
arn.SortSoundTracksLatestFirst(allTracks)
|
// arn.SortSoundTracksLatestFirst(allTracks)
|
||||||
|
|
||||||
// Slice the part that we need
|
// // Slice the part that we need
|
||||||
tracks := allTracks[index:]
|
// tracks := allTracks[index:]
|
||||||
maxLength := tracksFirstLoad
|
// maxLength := tracksFirstLoad
|
||||||
|
|
||||||
if index > 0 {
|
// if index > 0 {
|
||||||
maxLength = tracksPerScroll
|
// maxLength = tracksPerScroll
|
||||||
}
|
// }
|
||||||
|
|
||||||
if len(tracks) > maxLength {
|
// if len(tracks) > maxLength {
|
||||||
tracks = tracks[:maxLength]
|
// tracks = tracks[:maxLength]
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Next index
|
// // Next index
|
||||||
nextIndex := infinitescroll.NextIndex(ctx, len(allTracks), maxLength, index)
|
// nextIndex := infinitescroll.NextIndex(ctx, len(allTracks), maxLength, index)
|
||||||
|
|
||||||
// In case we're scrolling, send soundtracks only (without the page frame)
|
// // In case we're scrolling, send soundtracks only (without the page frame)
|
||||||
if index > 0 {
|
// if index > 0 {
|
||||||
return ctx.HTML(components.SoundTracksScrollable(tracks, user))
|
// return ctx.HTML(components.SoundTracksScrollable(tracks, user))
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Otherwise, send the full page
|
// // Otherwise, send the full page
|
||||||
return ctx.HTML(components.ProfileSoundTracks(tracks, viewUser, nextIndex, user, ctx.URI()))
|
// return ctx.HTML(components.ProfileSoundTracks(tracks, viewUser, nextIndex, user, ctx.URI()))
|
||||||
}
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user