Added basic anime list item view
This commit is contained in:
51
pages/animelistitem/animelistitem.go
Normal file
51
pages/animelistitem/animelistitem.go
Normal file
@ -0,0 +1,51 @@
|
||||
package animelistitem
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get anime page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
// user := utils.GetUser(ctx)
|
||||
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "User not found", err)
|
||||
}
|
||||
|
||||
animeList := viewUser.AnimeList()
|
||||
|
||||
if animeList == nil {
|
||||
return ctx.Error(http.StatusNotFound, "Anime list not found", err)
|
||||
}
|
||||
|
||||
animeID := ctx.Get("id")
|
||||
item := animeList.Find(animeID)
|
||||
|
||||
if item == nil {
|
||||
return ctx.Error(http.StatusNotFound, "List item not found", err)
|
||||
}
|
||||
|
||||
anime := item.Anime()
|
||||
|
||||
return ctx.HTML(components.AnimeListItem(item, anime))
|
||||
}
|
||||
|
||||
// t := reflect.TypeOf(item).Elem()
|
||||
// v := reflect.ValueOf(item).Elem()
|
||||
|
||||
// for i := 0; i < t.NumField(); i++ {
|
||||
// fieldInfo := t.Field(i)
|
||||
|
||||
// if fieldInfo.Anonymous || unicode.IsLower([]rune(fieldInfo.Name)[0]) {
|
||||
// continue
|
||||
// }
|
||||
|
||||
// fmt.Println(fieldInfo.Name, v.Field(i).Interface())
|
||||
// }
|
12
pages/animelistitem/animelistitem.pixy
Normal file
12
pages/animelistitem/animelistitem.pixy
Normal file
@ -0,0 +1,12 @@
|
||||
component AnimeListItem(item *arn.AnimeListItem, anime *arn.Anime)
|
||||
.widgets
|
||||
.widget.anime-list-item-view
|
||||
h2
|
||||
a.ajax(href=anime.Link())= anime.Title.Canonical
|
||||
|
||||
if anime.EpisodeCount == 0
|
||||
InputNumber("episodes", item.Episodes, "Episodes", "Number of episodes you watched", 0, 10000)
|
||||
else
|
||||
InputNumber("episodes", item.Episodes, "Episodes", "Number of episodes you watched", 0, anime.EpisodeCount)
|
||||
|
||||
InputTextArea("notes", item.Notes, "Notes", "Notes")
|
7
pages/animelistitem/animelistitem.scarlet
Normal file
7
pages/animelistitem/animelistitem.scarlet
Normal file
@ -0,0 +1,7 @@
|
||||
.anime-list-item-view
|
||||
textarea
|
||||
height 10rem
|
||||
|
||||
.anime-list-item-view-image
|
||||
max-width 55px
|
||||
margin-bottom 1rem
|
Reference in New Issue
Block a user