Liked characters are now viewable

This commit is contained in:
Eduard Urbach 2019-03-11 09:37:05 +09:00
parent 452a340fff
commit a37d636d67
6 changed files with 55 additions and 47 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/animenotifier/notify.moe/pages/explore/explorerelations" "github.com/animenotifier/notify.moe/pages/explore/explorerelations"
"github.com/animenotifier/notify.moe/pages/notifications" "github.com/animenotifier/notify.moe/pages/notifications"
"github.com/animenotifier/notify.moe/pages/profile" "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/recommended"
"github.com/animenotifier/notify.moe/pages/user" "github.com/animenotifier/notify.moe/pages/user"
) )
@ -18,7 +19,7 @@ func Register(l *layout.Layout) {
// User profiles // User profiles
l.Page("/user", user.Get) l.Page("/user", user.Get)
l.Page("/user/:nick", profile.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/threads", profile.GetThreadsByUser)
// l.Page("/user/:nick/forum/posts", profile.GetPostsByUser) // l.Page("/user/:nick/forum/posts", profile.GetPostsByUser)
// l.Page("/user/:nick/soundtracks/added", profiletracks.Added) // l.Page("/user/:nick/soundtracks/added", profiletracks.Added)

View File

@ -19,7 +19,8 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
//- Characters //- Characters
.profile-section .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 if len(characters) == 0
p.no-data.mountable(data-mountable-type="favorites") Nothing here yet. 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") img.profile-cover.lazy(data-src=viewUser.CoverLink("large"), data-webp="true", alt="Cover image")
.profile-image-container.mountable.never-unmount .profile-image-container.mountable.never-unmount
a(href=viewUser.Link())
ProfileImage(viewUser) ProfileImage(viewUser)
.profile-info.mountable.never-unmount .profile-info.mountable.never-unmount
h1#nick= viewUser.Nick h1#nick
a(href=viewUser.Link())= viewUser.Nick
.profile-introduction!= markdown.Render(viewUser.Introduction) .profile-introduction!= markdown.Render(viewUser.Introduction)
.profile-tags-container .profile-tags-container

View File

@ -227,6 +227,9 @@ const box-margin = 2px
#nick #nick
margin-bottom 1rem margin-bottom 1rem
> a
color white
.no-data .no-data
width 100% width 100%
text-align center text-align center

View File

@ -1,10 +1,10 @@
//- component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, user *arn.User, uri string) component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, user *arn.User, uri string)
//- ProfileHeader(viewUser, user, uri) ProfileHeader(viewUser, viewUser.AnimeList(), user, uri)
//- if len(characters) == 0 if len(characters) == 0
//- p.no-data.mountable= viewUser.Nick + " hasn't liked any characters yet." p.no-data.mountable= viewUser.Nick + " hasn't liked any characters yet."
//- else else
//- .characters.profile-characters .characters.profile-characters
//- each character in characters each character in characters
//- .mountable .mountable
//- Character(character, user) Character(character, user)

View File

@ -1,2 +1,2 @@
// .profile-characters .profile-characters
// justify-content center justify-content center

View File

@ -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()))
// } }