Disabled old profile pages

This commit is contained in:
2018-12-05 08:49:21 +09:00
parent 99e7ded4c4
commit ba57870cc9
7 changed files with 174 additions and 174 deletions
pages/profile
profilecharacters
profilequotes
profiletracks

@ -1,18 +1,18 @@
package profiletracks
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// import (
// "github.com/aerogo/aero"
// "github.com/animenotifier/arn"
// )
// Added shows all soundtracks added by a particular user.
func Added(ctx *aero.Context) string {
return render(ctx, addedTracks)
}
// // Added shows all soundtracks added by a particular user.
// func Added(ctx *aero.Context) string {
// return render(ctx, addedTracks)
// }
// addedTracks returns all soundtracks that the user with the given user ID published.
func addedTracks(userID string) []*arn.SoundTrack {
return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && len(track.Media) > 0 && track.CreatedBy == userID
})
}
// // addedTracks returns all soundtracks that the user with the given user ID published.
// func addedTracks(userID string) []*arn.SoundTrack {
// return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
// return !track.IsDraft && len(track.Media) > 0 && track.CreatedBy == userID
// })
// }

@ -1,18 +1,18 @@
package profiletracks
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// import (
// "github.com/aerogo/aero"
// "github.com/animenotifier/arn"
// )
// Liked shows all soundtracks liked by a particular user.
func Liked(ctx *aero.Context) string {
return render(ctx, likedTracks)
}
// // Liked shows all soundtracks liked by a particular user.
// func Liked(ctx *aero.Context) string {
// return render(ctx, likedTracks)
// }
// likedTracks returns all soundtracks that the user with the given user ID liked.
func likedTracks(userID string) []*arn.SoundTrack {
return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && len(track.Media) > 0 && track.LikedBy(userID)
})
}
// // likedTracks returns all soundtracks that the user with the given user ID liked.
// func likedTracks(userID string) []*arn.SoundTrack {
// return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
// return !track.IsDraft && len(track.Media) > 0 && track.LikedBy(userID)
// })
// }

@ -1,57 +1,57 @@
package profiletracks
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 (
tracksFirstLoad = 12
tracksPerScroll = 9
)
// const (
// tracksFirstLoad = 12
// tracksPerScroll = 9
// )
// render renders the soundtracks on user profiles.
func render(ctx *aero.Context, fetch func(userID string) []*arn.SoundTrack) string {
nick := ctx.Get("nick")
index, _ := ctx.GetInt("index")
user := utils.GetUser(ctx)
viewUser, err := arn.GetUserByNick(nick)
// // render renders the soundtracks on user profiles.
// func render(ctx *aero.Context, fetch func(userID string) []*arn.SoundTrack) 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 tracks
allTracks := fetch(viewUser.ID)
// // Fetch all eligible tracks
// allTracks := fetch(viewUser.ID)
// Sort the tracks by publication date
arn.SortSoundTracksLatestFirst(allTracks)
// // Sort the tracks by publication date
// arn.SortSoundTracksLatestFirst(allTracks)
// Slice the part that we need
tracks := allTracks[index:]
maxLength := tracksFirstLoad
// // Slice the part that we need
// tracks := allTracks[index:]
// maxLength := tracksFirstLoad
if index > 0 {
maxLength = tracksPerScroll
}
// if index > 0 {
// maxLength = tracksPerScroll
// }
if len(tracks) > maxLength {
tracks = tracks[:maxLength]
}
// if len(tracks) > maxLength {
// tracks = tracks[:maxLength]
// }
// Next index
nextIndex := infinitescroll.NextIndex(ctx, len(allTracks), maxLength, index)
// // Next index
// nextIndex := infinitescroll.NextIndex(ctx, len(allTracks), maxLength, index)
// In case we're scrolling, send soundtracks only (without the page frame)
if index > 0 {
return ctx.HTML(components.SoundTracksScrollable(tracks, user))
}
// // In case we're scrolling, send soundtracks only (without the page frame)
// if index > 0 {
// return ctx.HTML(components.SoundTracksScrollable(tracks, user))
// }
// Otherwise, send the full page
return ctx.HTML(components.ProfileSoundTracks(tracks, viewUser, nextIndex, user, ctx.URI()))
}
// // Otherwise, send the full page
// return ctx.HTML(components.ProfileSoundTracks(tracks, viewUser, nextIndex, user, ctx.URI()))
// }