Disable old profile pages
This commit is contained in:
parent
5668c66b31
commit
cfb481df52
@ -8,9 +8,6 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/compare"
|
||||
"github.com/animenotifier/notify.moe/pages/notifications"
|
||||
"github.com/animenotifier/notify.moe/pages/profile"
|
||||
"github.com/animenotifier/notify.moe/pages/profile/profilecharacters"
|
||||
"github.com/animenotifier/notify.moe/pages/profile/profilequotes"
|
||||
"github.com/animenotifier/notify.moe/pages/profile/profiletracks"
|
||||
"github.com/animenotifier/notify.moe/pages/recommended"
|
||||
"github.com/animenotifier/notify.moe/pages/user"
|
||||
)
|
||||
@ -20,19 +17,19 @@ func Register(l *layout.Layout) {
|
||||
// User profiles
|
||||
l.Page("/user", user.Get)
|
||||
l.Page("/user/:nick", profile.Get)
|
||||
l.Page("/user/:nick/characters/liked", profilecharacters.Liked)
|
||||
l.Page("/user/:nick/forum/threads", profile.GetThreadsByUser)
|
||||
l.Page("/user/:nick/forum/posts", profile.GetPostsByUser)
|
||||
l.Page("/user/:nick/soundtracks/added", profiletracks.Added)
|
||||
l.Page("/user/:nick/soundtracks/added/from/:index", profiletracks.Added)
|
||||
l.Page("/user/:nick/soundtracks/liked", profiletracks.Liked)
|
||||
l.Page("/user/:nick/soundtracks/liked/from/:index", profiletracks.Liked)
|
||||
l.Page("/user/:nick/quotes/added", profilequotes.Added)
|
||||
l.Page("/user/:nick/quotes/added/from/:index", profilequotes.Added)
|
||||
l.Page("/user/:nick/quotes/liked", profilequotes.Liked)
|
||||
l.Page("/user/:nick/quotes/liked/from/:index", profilequotes.Liked)
|
||||
l.Page("/user/:nick/stats", profile.GetStatsByUser)
|
||||
l.Page("/user/:nick/followers", profile.GetFollowers)
|
||||
// l.Page("/user/:nick/characters/liked", profilecharacters.Liked)
|
||||
// l.Page("/user/:nick/forum/threads", profile.GetThreadsByUser)
|
||||
// l.Page("/user/:nick/forum/posts", profile.GetPostsByUser)
|
||||
// l.Page("/user/:nick/soundtracks/added", profiletracks.Added)
|
||||
// l.Page("/user/:nick/soundtracks/added/from/:index", profiletracks.Added)
|
||||
// l.Page("/user/:nick/soundtracks/liked", profiletracks.Liked)
|
||||
// l.Page("/user/:nick/soundtracks/liked/from/:index", profiletracks.Liked)
|
||||
// l.Page("/user/:nick/quotes/added", profilequotes.Added)
|
||||
// l.Page("/user/:nick/quotes/added/from/:index", profilequotes.Added)
|
||||
// l.Page("/user/:nick/quotes/liked", profilequotes.Liked)
|
||||
// l.Page("/user/:nick/quotes/liked/from/:index", profilequotes.Liked)
|
||||
// l.Page("/user/:nick/stats", profile.GetStatsByUser)
|
||||
// l.Page("/user/:nick/followers", profile.GetFollowers)
|
||||
l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get)
|
||||
l.Page("/user/:nick/recommended/anime", recommended.Anime)
|
||||
l.Page("/user/:nick/notifications", notifications.ByUser)
|
||||
|
@ -1,26 +1,26 @@
|
||||
package profile
|
||||
|
||||
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/aerogo/aero"
|
||||
// "github.com/animenotifier/arn"
|
||||
// "github.com/animenotifier/notify.moe/components"
|
||||
// "github.com/animenotifier/notify.moe/utils"
|
||||
// )
|
||||
|
||||
// GetFollowers shows the followers of a particular user.
|
||||
func GetFollowers(ctx *aero.Context) string {
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
// // GetFollowers shows the followers of a particular user.
|
||||
// func GetFollowers(ctx *aero.Context) string {
|
||||
// nick := ctx.Get("nick")
|
||||
// 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)
|
||||
// }
|
||||
|
||||
followers := viewUser.Followers()
|
||||
arn.SortUsersLastSeenFirst(followers)
|
||||
// followers := viewUser.Followers()
|
||||
// arn.SortUsersLastSeenFirst(followers)
|
||||
|
||||
return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
// return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
|
||||
}
|
||||
// }
|
||||
|
@ -1,19 +1,19 @@
|
||||
component ProfileFollowers(followers []*arn.User, viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
//- component ProfileFollowers(followers []*arn.User, viewUser *arn.User, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
|
||||
if len(followers) > 0
|
||||
UserGrid(followers)
|
||||
else
|
||||
p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet."
|
||||
//- if len(followers) > 0
|
||||
//- UserGrid(followers)
|
||||
//- else
|
||||
//- p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet."
|
||||
|
||||
component UserGrid(users []*arn.User)
|
||||
.user-avatars
|
||||
each user in users
|
||||
if user.Nick != ""
|
||||
if user.IsActive()
|
||||
.mountable
|
||||
Avatar(user)
|
||||
else
|
||||
.mountable
|
||||
.inactive-user
|
||||
Avatar(user)
|
||||
//- component UserGrid(users []*arn.User)
|
||||
//- .user-avatars
|
||||
//- each user in users
|
||||
//- if user.Nick != ""
|
||||
//- if user.IsActive()
|
||||
//- .mountable
|
||||
//- Avatar(user)
|
||||
//- else
|
||||
//- .mountable
|
||||
//- .inactive-user
|
||||
//- Avatar(user)
|
@ -1,2 +1,2 @@
|
||||
.inactive-user
|
||||
// opacity 0.25
|
||||
// .inactive-user
|
||||
// // opacity 0.25
|
@ -1,32 +1,32 @@
|
||||
package profile
|
||||
|
||||
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/aerogo/aero"
|
||||
// "github.com/animenotifier/arn"
|
||||
// "github.com/animenotifier/notify.moe/components"
|
||||
// "github.com/animenotifier/notify.moe/utils"
|
||||
// )
|
||||
|
||||
const postLimit = 10
|
||||
// const postLimit = 10
|
||||
|
||||
// GetPostsByUser shows all forum posts of a particular user.
|
||||
func GetPostsByUser(ctx *aero.Context) string {
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
// // GetPostsByUser shows all forum posts of a particular user.
|
||||
// func GetPostsByUser(ctx *aero.Context) string {
|
||||
// nick := ctx.Get("nick")
|
||||
// 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)
|
||||
// }
|
||||
|
||||
posts := viewUser.Posts()
|
||||
arn.SortPostsLatestFirst(posts)
|
||||
// posts := viewUser.Posts()
|
||||
// arn.SortPostsLatestFirst(posts)
|
||||
|
||||
if len(posts) >= postLimit {
|
||||
posts = posts[:postLimit]
|
||||
}
|
||||
// if len(posts) >= postLimit {
|
||||
// posts = posts[:postLimit]
|
||||
// }
|
||||
|
||||
return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
// return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
|
||||
}
|
||||
// }
|
||||
|
@ -1,14 +1,14 @@
|
||||
component ProfileForumTabs(viewUser *arn.User)
|
||||
.tabs
|
||||
Tab("Threads", "list", "/+" + viewUser.Nick + "/forum/threads")
|
||||
Tab("Posts", "comments", "/+" + viewUser.Nick + "/forum/posts")
|
||||
//- component ProfileForumTabs(viewUser *arn.User)
|
||||
//- .tabs
|
||||
//- Tab("Threads", "list", "/+" + viewUser.Nick + "/forum/threads")
|
||||
//- Tab("Posts", "comments", "/+" + viewUser.Nick + "/forum/posts")
|
||||
|
||||
component LatestPosts(postables []arn.Postable, viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
ProfileForumTabs(viewUser)
|
||||
//- component LatestPosts(postables []arn.Postable, viewUser *arn.User, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
//- ProfileForumTabs(viewUser)
|
||||
|
||||
if len(postables) > 0
|
||||
h1.page-title= len(postables), " latest posts by ", postables[0].Creator().Nick
|
||||
PostableList(postables, user)
|
||||
else
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't written any posts yet."
|
||||
//- if len(postables) > 0
|
||||
//- h1.page-title= len(postables), " latest posts by ", postables[0].Creator().Nick
|
||||
//- PostableList(postables, user)
|
||||
//- else
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't written any posts yet."
|
@ -38,7 +38,8 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
|
||||
animeList = animeList.WithoutPrivateItems()
|
||||
}
|
||||
|
||||
animeList.SortByRating()
|
||||
completedList := animeList.FilterStatus(arn.AnimeListStatusCompleted)
|
||||
completedList.SortByRating()
|
||||
|
||||
// Genres
|
||||
topGenres := animeList.TopGenres(5)
|
||||
@ -127,5 +128,5 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
|
||||
}
|
||||
|
||||
ctx.Data = openGraph
|
||||
return ctx.HTML(components.Profile(viewUser, user, animeList, characters, friends, topGenres, dayToActivityCount, ctx.URI()))
|
||||
return ctx.HTML(components.Profile(viewUser, user, animeList, completedList, characters, friends, topGenres, dayToActivityCount, ctx.URI()))
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, characters []*arn.Character, friends []*arn.User, topGenres []string, dayToActivityCount map[int]int, uri string)
|
||||
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, completedList *arn.AnimeList, characters []*arn.Character, friends []*arn.User, topGenres []string, dayToActivityCount map[int]int, uri string)
|
||||
.profile
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
ProfileHeader(viewUser, animeList, user, uri)
|
||||
|
||||
.profile-columns
|
||||
//- Favorites
|
||||
@ -9,11 +9,11 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
.profile-section
|
||||
h3.profile-column-header.mountable(data-mountable-type="favorites") Anime
|
||||
|
||||
if len(animeList.Items) == 0
|
||||
if len(completedList.Items) == 0
|
||||
p.no-data.mountable(data-mountable-type="favorites") Nothing here yet.
|
||||
else
|
||||
.profile-favorite-anime-container.mountable(data-mountable-type="favorites")
|
||||
each item in animeList.Top(6)
|
||||
each item in completedList.Top(6)
|
||||
a.profile-favorite-anime.tip.mountable(href=item.Anime().Link(), aria-label=item.Anime().Title.ByUser(user), data-mountable-type="anime")
|
||||
img.profile-favorite-anime-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp=true, alt=item.Anime().Title.ByUser(user))
|
||||
|
||||
@ -77,10 +77,10 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
if day == 2
|
||||
.spacer-box
|
||||
|
||||
component ProfileHeader(viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHead(viewUser, user, uri)
|
||||
component ProfileHeader(viewUser *arn.User, animeList *arn.AnimeList, user *arn.User, uri string)
|
||||
ProfileHead(viewUser, animeList, user, uri)
|
||||
|
||||
component ProfileHead(viewUser *arn.User, user *arn.User, uri string)
|
||||
component ProfileHead(viewUser *arn.User, animeList *arn.AnimeList, user *arn.User, uri string)
|
||||
.profile-head
|
||||
img.profile-cover.lazy(data-src=viewUser.CoverLink("large"), data-webp="true", alt="Cover image")
|
||||
|
||||
@ -95,7 +95,7 @@ component ProfileHead(viewUser *arn.User, user *arn.User, uri string)
|
||||
.profile-tags
|
||||
a.profile-tag.mountable.never-unmount(href="/+" + viewUser.Nick + "/animelist/watching", data-mountable-type="header")
|
||||
Icon("list")
|
||||
span= fmt.Sprintf("%d anime", len(viewUser.AnimeList().Items))
|
||||
span= fmt.Sprintf("%d anime", len(animeList.Items))
|
||||
|
||||
if user != nil && viewUser.Settings().Privacy.ShowAge && viewUser.Settings().Privacy.ShowGender && viewUser.AgeInYears() != 0
|
||||
.profile-tag.mountable.never-unmount(data-mountable-type="header")
|
||||
|
@ -1,11 +1,10 @@
|
||||
component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
|
||||
if len(characters) == 0
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't liked any characters yet."
|
||||
else
|
||||
.characters.profile-characters
|
||||
each character in characters
|
||||
.mountable
|
||||
Character(character, user)
|
||||
//- component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
|
||||
//- if len(characters) == 0
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't liked any characters yet."
|
||||
//- else
|
||||
//- .characters.profile-characters
|
||||
//- each character in characters
|
||||
//- .mountable
|
||||
//- Character(character, user)
|
||||
|
@ -1,2 +1,2 @@
|
||||
.profile-characters
|
||||
justify-content center
|
||||
// .profile-characters
|
||||
// justify-content center
|
@ -1,21 +1,21 @@
|
||||
component ProfileQuotes(quotes []*arn.Quote, viewUser *arn.User, nextIndex int, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
//- component ProfileQuotes(quotes []*arn.Quote, viewUser *arn.User, nextIndex int, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
|
||||
if strings.Contains(uri, "/added")
|
||||
h1.page-title= "Quotes added by " + viewUser.Nick
|
||||
else
|
||||
h1.page-title= "Quotes liked by " + viewUser.Nick
|
||||
//- if strings.Contains(uri, "/added")
|
||||
//- h1.page-title= "Quotes added by " + viewUser.Nick
|
||||
//- else
|
||||
//- h1.page-title= "Quotes liked by " + viewUser.Nick
|
||||
|
||||
if len(quotes) == 0
|
||||
if strings.Contains(uri, "/added")
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't added any quotes yet."
|
||||
else
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't liked any quotes yet."
|
||||
else
|
||||
#load-more-target.quotes
|
||||
QuotesScrollable(quotes, user)
|
||||
//- if len(quotes) == 0
|
||||
//- if strings.Contains(uri, "/added")
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't added any quotes yet."
|
||||
//- else
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't liked any quotes yet."
|
||||
//- else
|
||||
//- #load-more-target.quotes
|
||||
//- QuotesScrollable(quotes, user)
|
||||
|
||||
if nextIndex != -1
|
||||
.buttons
|
||||
LoadMore(nextIndex)
|
||||
//- if nextIndex != -1
|
||||
//- .buttons
|
||||
//- LoadMore(nextIndex)
|
||||
|
@ -1,21 +1,21 @@
|
||||
component ProfileSoundTracks(tracks []*arn.SoundTrack, viewUser *arn.User, nextIndex int, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
//- component ProfileSoundTracks(tracks []*arn.SoundTrack, viewUser *arn.User, nextIndex int, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
|
||||
if strings.Contains(uri, "/added")
|
||||
h1.page-title= "Tracks added by " + viewUser.Nick
|
||||
else
|
||||
h1.page-title= "Tracks liked by " + viewUser.Nick
|
||||
//- if strings.Contains(uri, "/added")
|
||||
//- h1.page-title= "Tracks added by " + viewUser.Nick
|
||||
//- else
|
||||
//- h1.page-title= "Tracks liked by " + viewUser.Nick
|
||||
|
||||
if len(tracks) == 0
|
||||
if strings.Contains(uri, "/added")
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't added any tracks yet."
|
||||
else
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't liked any tracks yet."
|
||||
else
|
||||
#load-more-target.soundtracks
|
||||
SoundTracksScrollable(tracks, user)
|
||||
//- if len(tracks) == 0
|
||||
//- if strings.Contains(uri, "/added")
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't added any tracks yet."
|
||||
//- else
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't liked any tracks yet."
|
||||
//- else
|
||||
//- #load-more-target.soundtracks
|
||||
//- SoundTracksScrollable(tracks, user)
|
||||
|
||||
if nextIndex != -1
|
||||
.buttons
|
||||
LoadMore(nextIndex)
|
||||
//- if nextIndex != -1
|
||||
//- .buttons
|
||||
//- LoadMore(nextIndex)
|
||||
|
@ -1,102 +1,102 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
// import (
|
||||
// "net/http"
|
||||
// "strconv"
|
||||
// "strings"
|
||||
// "time"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
// "github.com/aerogo/aero"
|
||||
// "github.com/animenotifier/arn"
|
||||
// "github.com/animenotifier/notify.moe/components"
|
||||
// "github.com/animenotifier/notify.moe/utils"
|
||||
// )
|
||||
|
||||
type stats map[string]float64
|
||||
// type stats map[string]float64
|
||||
|
||||
// GetStatsByUser shows statistics for a given user.
|
||||
func GetStatsByUser(ctx *aero.Context) string {
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
userStats := utils.UserStats{}
|
||||
ratings := stats{}
|
||||
status := stats{}
|
||||
types := stats{}
|
||||
years := stats{}
|
||||
studios := stats{}
|
||||
genres := stats{}
|
||||
trackTags := stats{}
|
||||
// // GetStatsByUser shows statistics for a given user.
|
||||
// func GetStatsByUser(ctx *aero.Context) string {
|
||||
// nick := ctx.Get("nick")
|
||||
// viewUser, err := arn.GetUserByNick(nick)
|
||||
// userStats := utils.UserStats{}
|
||||
// ratings := stats{}
|
||||
// status := stats{}
|
||||
// types := stats{}
|
||||
// years := stats{}
|
||||
// studios := stats{}
|
||||
// genres := stats{}
|
||||
// trackTags := stats{}
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||
}
|
||||
// if err != nil {
|
||||
// return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||
// }
|
||||
|
||||
animeList, err := arn.GetAnimeList(viewUser.ID)
|
||||
// animeList, err := arn.GetAnimeList(viewUser.ID)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Anime list not found", err)
|
||||
}
|
||||
// if err != nil {
|
||||
// return ctx.Error(http.StatusInternalServerError, "Anime list not found", err)
|
||||
// }
|
||||
|
||||
animeList.Lock()
|
||||
defer animeList.Unlock()
|
||||
// animeList.Lock()
|
||||
// defer animeList.Unlock()
|
||||
|
||||
for _, item := range animeList.Items {
|
||||
status[item.Status]++
|
||||
// for _, item := range animeList.Items {
|
||||
// status[item.Status]++
|
||||
|
||||
if item.Status == arn.AnimeListStatusPlanned {
|
||||
continue
|
||||
}
|
||||
// if item.Status == arn.AnimeListStatusPlanned {
|
||||
// continue
|
||||
// }
|
||||
|
||||
currentWatch := item.Episodes * item.Anime().EpisodeLength
|
||||
reWatch := item.RewatchCount * item.Anime().EpisodeCount * item.Anime().EpisodeLength
|
||||
duration := time.Duration(currentWatch + reWatch)
|
||||
userStats.AnimeWatchingTime += duration * time.Minute
|
||||
// currentWatch := item.Episodes * item.Anime().EpisodeLength
|
||||
// reWatch := item.RewatchCount * item.Anime().EpisodeCount * item.Anime().EpisodeLength
|
||||
// duration := time.Duration(currentWatch + reWatch)
|
||||
// userStats.AnimeWatchingTime += duration * time.Minute
|
||||
|
||||
ratings[strconv.Itoa(int(item.Rating.Overall+0.5))]++
|
||||
types[item.Anime().Type]++
|
||||
// ratings[strconv.Itoa(int(item.Rating.Overall+0.5))]++
|
||||
// types[item.Anime().Type]++
|
||||
|
||||
for _, studio := range item.Anime().Studios() {
|
||||
studios[studio.Name.English]++
|
||||
}
|
||||
// for _, studio := range item.Anime().Studios() {
|
||||
// studios[studio.Name.English]++
|
||||
// }
|
||||
|
||||
for _, genre := range item.Anime().Genres {
|
||||
genres[genre]++
|
||||
}
|
||||
// for _, genre := range item.Anime().Genres {
|
||||
// genres[genre]++
|
||||
// }
|
||||
|
||||
if item.Anime().StartDate != "" {
|
||||
year := item.Anime().StartDate[:4]
|
||||
// if item.Anime().StartDate != "" {
|
||||
// year := item.Anime().StartDate[:4]
|
||||
|
||||
if year < "2000" {
|
||||
year = "Before 2000"
|
||||
}
|
||||
// if year < "2000" {
|
||||
// year = "Before 2000"
|
||||
// }
|
||||
|
||||
years[year]++
|
||||
}
|
||||
}
|
||||
// years[year]++
|
||||
// }
|
||||
// }
|
||||
|
||||
for track := range arn.StreamSoundTracks() {
|
||||
if !track.LikedBy(viewUser.ID) {
|
||||
continue
|
||||
}
|
||||
// for track := range arn.StreamSoundTracks() {
|
||||
// if !track.LikedBy(viewUser.ID) {
|
||||
// continue
|
||||
// }
|
||||
|
||||
for _, tag := range track.Tags {
|
||||
if strings.Contains(tag, ":") {
|
||||
continue
|
||||
}
|
||||
// for _, tag := range track.Tags {
|
||||
// if strings.Contains(tag, ":") {
|
||||
// continue
|
||||
// }
|
||||
|
||||
trackTags[tag]++
|
||||
}
|
||||
}
|
||||
// trackTags[tag]++
|
||||
// }
|
||||
// }
|
||||
|
||||
userStats.PieCharts = []*arn.PieChart{
|
||||
arn.NewPieChart("Genres", genres),
|
||||
arn.NewPieChart("Studios", studios),
|
||||
arn.NewPieChart("Years", years),
|
||||
arn.NewPieChart("Ratings", ratings),
|
||||
arn.NewPieChart("Types", types),
|
||||
arn.NewPieChart("Status", status),
|
||||
arn.NewPieChart("Soundtracks", trackTags),
|
||||
}
|
||||
// userStats.PieCharts = []*arn.PieChart{
|
||||
// arn.NewPieChart("Genres", genres),
|
||||
// arn.NewPieChart("Studios", studios),
|
||||
// arn.NewPieChart("Years", years),
|
||||
// arn.NewPieChart("Ratings", ratings),
|
||||
// arn.NewPieChart("Types", types),
|
||||
// arn.NewPieChart("Status", status),
|
||||
// arn.NewPieChart("Soundtracks", trackTags),
|
||||
// }
|
||||
|
||||
return ctx.HTML(components.ProfileStats(&userStats, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
}
|
||||
// return ctx.HTML(components.ProfileStats(&userStats, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
// }
|
||||
|
@ -1,15 +1,15 @@
|
||||
component ProfileStats(stats *utils.UserStats, viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
//- component ProfileStats(stats *utils.UserStats, viewUser *arn.User, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
|
||||
.stats
|
||||
each pie in stats.PieCharts
|
||||
.widget.mountable
|
||||
h3.widget-title
|
||||
Icon("pie-chart")
|
||||
span= pie.Title
|
||||
PieChart(pie.Slices)
|
||||
//- .stats
|
||||
//- each pie in stats.PieCharts
|
||||
//- .widget.mountable
|
||||
//- h3.widget-title
|
||||
//- Icon("pie-chart")
|
||||
//- span= pie.Title
|
||||
//- PieChart(pie.Slices)
|
||||
|
||||
.footer.mountable
|
||||
span= viewUser.Nick + " spent "
|
||||
span= int(stats.AnimeWatchingTime / time.Hour / 24)
|
||||
span days watching anime.
|
||||
//- .footer.mountable
|
||||
//- span= viewUser.Nick + " spent "
|
||||
//- span= int(stats.AnimeWatchingTime / time.Hour / 24)
|
||||
//- span days watching anime.
|
@ -1,7 +1,7 @@
|
||||
.stats
|
||||
horizontal-wrap
|
||||
justify-content space-around
|
||||
// .stats
|
||||
// horizontal-wrap
|
||||
// justify-content space-around
|
||||
|
||||
.widget
|
||||
min-width 200px
|
||||
max-width 300px
|
||||
// .widget
|
||||
// min-width 200px
|
||||
// max-width 300px
|
@ -1,31 +1,31 @@
|
||||
package profile
|
||||
|
||||
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/aerogo/aero"
|
||||
// "github.com/animenotifier/arn"
|
||||
// "github.com/animenotifier/notify.moe/components"
|
||||
// "github.com/animenotifier/notify.moe/utils"
|
||||
// )
|
||||
|
||||
const maxThreads = 20
|
||||
// const maxThreads = 20
|
||||
|
||||
// GetThreadsByUser shows all forum threads of a particular user.
|
||||
func GetThreadsByUser(ctx *aero.Context) string {
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
// // GetThreadsByUser shows all forum threads of a particular user.
|
||||
// func GetThreadsByUser(ctx *aero.Context) string {
|
||||
// nick := ctx.Get("nick")
|
||||
// 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)
|
||||
// }
|
||||
|
||||
threads := viewUser.Threads()
|
||||
arn.SortThreadsLatestFirst(threads)
|
||||
// threads := viewUser.Threads()
|
||||
// arn.SortThreadsLatestFirst(threads)
|
||||
|
||||
if len(threads) > maxThreads {
|
||||
threads = threads[:maxThreads]
|
||||
}
|
||||
// if len(threads) > maxThreads {
|
||||
// threads = threads[:maxThreads]
|
||||
// }
|
||||
|
||||
return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
}
|
||||
// return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
// }
|
||||
|
@ -1,9 +1,9 @@
|
||||
component ProfileThreads(threads []*arn.Thread, viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
ProfileForumTabs(viewUser)
|
||||
//- component ProfileThreads(threads []*arn.Thread, viewUser *arn.User, user *arn.User, uri string)
|
||||
//- ProfileHeader(viewUser, user, uri)
|
||||
//- ProfileForumTabs(viewUser)
|
||||
|
||||
if len(threads) == 0
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't written any threads yet."
|
||||
else
|
||||
.forum
|
||||
ThreadList(threads)
|
||||
//- if len(threads) == 0
|
||||
//- p.no-data.mountable= viewUser.Nick + " hasn't written any threads yet."
|
||||
//- else
|
||||
//- .forum
|
||||
//- ThreadList(threads)
|
||||
|
@ -1,15 +1,15 @@
|
||||
.profile-watching-list
|
||||
horizontal-wrap
|
||||
justify-content center
|
||||
|
||||
// CSS grid variant:
|
||||
// display grid
|
||||
// grid-gap 0.5rem
|
||||
// grid-template-columns repeat(auto-fill, 55px)
|
||||
// .profile-watching-list
|
||||
// horizontal-wrap
|
||||
// justify-content center
|
||||
|
||||
.profile-watching-list-item
|
||||
anime-mini-item
|
||||
// // CSS grid variant:
|
||||
// // display grid
|
||||
// // grid-gap 0.5rem
|
||||
// // grid-template-columns repeat(auto-fill, 55px)
|
||||
// // justify-content center
|
||||
|
||||
.profile-watching-list-item-image
|
||||
anime-mini-item-image
|
||||
// .profile-watching-list-item
|
||||
// anime-mini-item
|
||||
|
||||
// .profile-watching-list-item-image
|
||||
// anime-mini-item-image
|
Loading…
Reference in New Issue
Block a user