Added basic anime list item view
This commit is contained in:
@ -1,19 +1,23 @@
|
||||
package anime
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get anime page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(404, "Anime not found", err)
|
||||
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Anime(anime))
|
||||
return ctx.HTML(components.Anime(anime, user))
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
component Anime(anime *arn.Anime)
|
||||
component Anime(anime *arn.Anime, user *arn.User)
|
||||
.anime-header(data-id=anime.ID)
|
||||
if anime.Image.Small != ""
|
||||
.anime-image-container
|
||||
img.anime-cover-image(src=anime.Image.Small, alt=anime.Title.Romaji)
|
||||
img.anime-cover-image(src=anime.Image.Small, alt=anime.Title.Canonical)
|
||||
|
||||
.space
|
||||
|
||||
@ -13,13 +13,18 @@ component Anime(anime *arn.Anime)
|
||||
//- span.second-title(title=anime.Title.English !== anime.Title.Romaji ? anime.Title.English : null)= anime.Title.Romaji
|
||||
//- else
|
||||
if anime.Title.Japanese != anime.Title.Canonical
|
||||
a.anime-alternative-title(href="http://jisho.org/search/" + anime.Title.Japanese, target="_blank", title="Look up reading on jisho.org", rel="nofollow")= anime.Title.Japanese
|
||||
.anime-alternative-title
|
||||
a(href="http://jisho.org/search/" + anime.Title.Japanese, target="_blank", title="Look up reading on jisho.org", rel="nofollow")= anime.Title.Japanese
|
||||
|
||||
//- h3.anime-section-name.anime-summary-header Summary
|
||||
p.anime-summary= anime.Summary
|
||||
|
||||
.anime-actions
|
||||
a.light-button.action-button(href="#") Add to collection
|
||||
if user != nil
|
||||
.anime-actions
|
||||
if user.AnimeList().Contains(anime.ID)
|
||||
a.button.ajax(href="/+" + user.Nick + "/animelist/" + anime.ID) View in collection
|
||||
else
|
||||
button Add to collection
|
||||
|
||||
h3.anime-section-name Ratings
|
||||
.anime-rating-categories
|
||||
|
@ -39,12 +39,14 @@
|
||||
.anime-alternative-title
|
||||
font-size 0.9em
|
||||
margin-bottom 0.5rem
|
||||
color rgba(60, 60, 60, 0.5) !important
|
||||
a
|
||||
color rgba(60, 60, 60, 0.5) !important
|
||||
|
||||
.anime-actions
|
||||
horizontal
|
||||
justify-content center
|
||||
margin content-padding 0
|
||||
z-index 10
|
||||
|
||||
> 900px
|
||||
.anime-actions
|
||||
|
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
|
@ -57,7 +57,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
p No anime in the collection.
|
||||
else
|
||||
each item in animeList.Items
|
||||
a.anime-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.Canonical + " (" + toString(item.Episode) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
||||
a.anime-list-item.ajax(href="/+" + viewUser.Nick + "/animelist/" + item.Anime().ID, title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
||||
img.anime-cover-image.anime-list-item-image(src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical)
|
||||
|
||||
.profile-category
|
||||
|
@ -17,9 +17,4 @@ component Settings(user *arn.User)
|
||||
|
||||
InputText("accounts.anilist.nick", user.Accounts.AniList.Nick, "AniList", "Your username on anilist.co")
|
||||
InputText("accounts.myanimelist.nick", user.Accounts.MyAnimeList.Nick, "MyAnimeList", "Your username on myanimelist.net")
|
||||
InputText("accounts.kitsu.nick", user.Accounts.Kitsu.Nick, "Kitsu", "Your username on kitsu.io")
|
||||
|
||||
component InputText(id string, value string, label string, placeholder string)
|
||||
.widget-input
|
||||
label(for=id)= label + ":"
|
||||
input.widget-element(id=id, type="text", value=value, placeholder=placeholder)
|
||||
InputText("accounts.kitsu.nick", user.Accounts.Kitsu.Nick, "Kitsu", "Your username on kitsu.io")
|
Reference in New Issue
Block a user