diff --git a/mixins/AnimeList.pixy b/mixins/AnimeList.pixy index 17828fb0..53cc205f 100644 --- a/mixins/AnimeList.pixy +++ b/mixins/AnimeList.pixy @@ -36,7 +36,7 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn .anime-list-item-episodes-watched .action(contenteditable=utils.SameUser(user, viewUser), data-field="Episodes", data-type="number", data-trigger="focusout", data-action="save")= item.Episodes - if item.Status == arn.AnimeListStatusWatching + if item.Status == arn.AnimeListStatusWatching && user != nil && user.ID == viewUser.ID .plus-episode.action(data-action="increaseEpisode", data-trigger="click") + else .plus-episode-dummy + diff --git a/pages/animelist/animelist.go b/pages/animelist/animelist.go index 9fe0b6af..7812317b 100644 --- a/pages/animelist/animelist.go +++ b/pages/animelist/animelist.go @@ -2,6 +2,7 @@ package animelist import ( "net/http" + "strconv" "github.com/aerogo/aero" "github.com/animenotifier/arn" @@ -46,13 +47,13 @@ func AnimeList(ctx *aero.Context, user *arn.User, status string) string { return ctx.Error(http.StatusNotFound, "Anime list not found", nil) } - animeList = animeList.FilterStatus(status) + statusList := animeList.FilterStatus(status) // Sort the items - animeList.Sort() + statusList.Sort() // These are all animer list items for the given status - allItems := animeList.Items + allItems := statusList.Items // Slice the part that we need items := allItems[index:] @@ -69,11 +70,30 @@ func AnimeList(ctx *aero.Context, user *arn.User, status string) string { // Next index nextIndex := infinitescroll.NextIndex(ctx, len(allItems), maxLength, index) + // OpenGraph data + ctx.Data = &arn.OpenGraph{ + Tags: map[string]string{ + "og:title": viewUser.Nick + "'s anime list", + "og:image": "https:" + viewUser.AvatarLink("large"), + "og:url": "https://" + ctx.App.Config.Domain + viewUser.Link(), + "og:site_name": "notify.moe", + "og:description": strconv.Itoa(len(animeList.Items)) + " anime", + + // The OpenGraph type "profile" is meant for real-life persons but I think it's okay in this context. + // An alternative would be to use "article" which is mostly used for blog posts and news. + "og:type": "profile", + }, + Meta: map[string]string{ + "description": viewUser.Nick + "'s anime list", + "keywords": "anime list", + }, + } + // In case we're scrolling, send items only (without the page frame) if index > 0 { return ctx.HTML(components.AnimeListScrollable(items, viewUser, user)) } // Otherwise, send the full page - return ctx.HTML(components.HomeAnimeList(items, nextIndex, viewUser, user, status)) + return ctx.HTML(components.AnimeListPage(items, nextIndex, viewUser, user, status)) } diff --git a/pages/animelist/animelist.pixy b/pages/animelist/animelist.pixy index 8df90a7f..83499b1b 100644 --- a/pages/animelist/animelist.pixy +++ b/pages/animelist/animelist.pixy @@ -1,4 +1,4 @@ -component HomeAnimeList(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User, status string) +component AnimeListPage(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User, status string) h1.page-title= viewUser.Nick + "'s anime list" if user.ID != viewUser.ID