diff --git a/pages/index/userroutes/userroutes.go b/pages/index/userroutes/userroutes.go index 476e849b..5f565ef1 100644 --- a/pages/index/userroutes/userroutes.go +++ b/pages/index/userroutes/userroutes.go @@ -9,6 +9,7 @@ import ( "github.com/animenotifier/notify.moe/pages/explore/explorerelations" "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/recommended" "github.com/animenotifier/notify.moe/pages/user" ) @@ -18,7 +19,7 @@ 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/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) diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index e2e6e132..e8cb6e1e 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -19,7 +19,8 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, //- Characters .profile-section - h3.profile-column-header.mountable(data-mountable-type="favorites") Characters + h3.profile-column-header.mountable(data-mountable-type="favorites") + a(href=viewUser.Link() + "/characters/liked") Characters if len(characters) == 0 p.no-data.mountable(data-mountable-type="favorites") Nothing here yet. @@ -101,10 +102,13 @@ component ProfileHead(viewUser *arn.User, animeList *arn.AnimeList, user *arn.Us img.profile-cover.lazy(data-src=viewUser.CoverLink("large"), data-webp="true", alt="Cover image") .profile-image-container.mountable.never-unmount - ProfileImage(viewUser) + a(href=viewUser.Link()) + ProfileImage(viewUser) .profile-info.mountable.never-unmount - h1#nick= viewUser.Nick + h1#nick + a(href=viewUser.Link())= viewUser.Nick + .profile-introduction!= markdown.Render(viewUser.Introduction) .profile-tags-container diff --git a/pages/profile/profile.scarlet b/pages/profile/profile.scarlet index 0983c557..465fd64c 100644 --- a/pages/profile/profile.scarlet +++ b/pages/profile/profile.scarlet @@ -227,6 +227,9 @@ const box-margin = 2px #nick margin-bottom 1rem + > a + color white + .no-data width 100% text-align center \ No newline at end of file diff --git a/pages/profile/profilecharacters/characters.pixy b/pages/profile/profilecharacters/characters.pixy index 16221826..663042c1 100644 --- a/pages/profile/profilecharacters/characters.pixy +++ b/pages/profile/profilecharacters/characters.pixy @@ -1,10 +1,10 @@ -//- component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, user *arn.User, uri string) -//- ProfileHeader(viewUser, user, uri) +component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, user *arn.User, uri string) + ProfileHeader(viewUser, viewUser.AnimeList(), 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) + 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) diff --git a/pages/profile/profilecharacters/characters.scarlet b/pages/profile/profilecharacters/characters.scarlet index dfff787b..a0ee7eb8 100644 --- a/pages/profile/profilecharacters/characters.scarlet +++ b/pages/profile/profilecharacters/characters.scarlet @@ -1,2 +1,2 @@ -// .profile-characters -// justify-content center \ No newline at end of file +.profile-characters + justify-content center \ No newline at end of file diff --git a/pages/profile/profilecharacters/liked.go b/pages/profile/profilecharacters/liked.go index 34bd3fc5..e99bb11b 100644 --- a/pages/profile/profilecharacters/liked.go +++ b/pages/profile/profilecharacters/liked.go @@ -1,44 +1,44 @@ package profilecharacters -// import ( -// "net/http" -// "sort" +import ( + "net/http" + "sort" -// "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" +) -// // Liked shows all liked characters of a particular user. -// func Liked(ctx *aero.Context) string { -// nick := ctx.Get("nick") -// viewUser, err := arn.GetUserByNick(nick) +// Liked shows all liked characters of a particular user. +func Liked(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) + } -// characters := []*arn.Character{} + characters := []*arn.Character{} -// for character := range arn.StreamCharacters() { -// if arn.Contains(character.Likes, viewUser.ID) { -// characters = append(characters, character) -// } -// } + for character := range arn.StreamCharacters() { + if arn.Contains(character.Likes, viewUser.ID) { + characters = append(characters, character) + } + } -// sort.Slice(characters, func(i, j int) bool { -// return characters[i].Name.Canonical < characters[j].Name.Canonical + sort.Slice(characters, func(i, j int) bool { + return characters[i].Name.Canonical < characters[j].Name.Canonical -// // aLikes := len(characters[i].Likes) -// // bLikes := len(characters[j].Likes) + // aLikes := len(characters[i].Likes) + // bLikes := len(characters[j].Likes) -// // if aLikes == bLikes { -// // return characters[i].Name.Canonical < characters[j].Name.Canonical -// // } + // if aLikes == bLikes { + // 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())) +}