Implemented anime list basics
This commit is contained in:
parent
4f7ef694c8
commit
cacb804a19
34
api.go
34
api.go
@ -1,8 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -52,4 +56,34 @@ func init() {
|
|||||||
|
|
||||||
return ctx.JSON(thread)
|
return ctx.JSON(thread)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.Get("/api/anime/:id/add", func(ctx *aero.Context) string {
|
||||||
|
animeID := ctx.Get("id")
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
return ctx.Error(http.StatusBadRequest, "Not logged in", errors.New("User not logged in"))
|
||||||
|
}
|
||||||
|
|
||||||
|
animeList := user.AnimeList()
|
||||||
|
|
||||||
|
if animeList.Contains(animeID) {
|
||||||
|
return ctx.Error(http.StatusBadRequest, "Anime already added", errors.New("Anime has already been added"))
|
||||||
|
}
|
||||||
|
|
||||||
|
newItem := arn.AnimeListItem{
|
||||||
|
AnimeID: animeID,
|
||||||
|
Status: arn.AnimeListStatusPlanned,
|
||||||
|
}
|
||||||
|
|
||||||
|
animeList.Items = append(animeList.Items, newItem)
|
||||||
|
|
||||||
|
saveError := animeList.Save()
|
||||||
|
|
||||||
|
if saveError != nil {
|
||||||
|
return ctx.Error(http.StatusInternalServerError, "Could not save anime list in database", saveError)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.JSON(animeList)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ component Anime(anime *arn.Anime)
|
|||||||
//- h3.anime-section-name.anime-summary-header Summary
|
//- h3.anime-section-name.anime-summary-header Summary
|
||||||
p.anime-summary= anime.Summary
|
p.anime-summary= anime.Summary
|
||||||
|
|
||||||
|
.anime-actions
|
||||||
|
a.light-button.action-button(href="#") Add to collection
|
||||||
|
|
||||||
h3.anime-section-name Ratings
|
h3.anime-section-name Ratings
|
||||||
.anime-rating-categories
|
.anime-rating-categories
|
||||||
.anime-rating-category(title=toString(anime.Rating.Overall))
|
.anime-rating-category(title=toString(anime.Rating.Overall))
|
||||||
|
@ -41,6 +41,17 @@
|
|||||||
margin-bottom 0.5rem
|
margin-bottom 0.5rem
|
||||||
color rgba(60, 60, 60, 0.5) !important
|
color rgba(60, 60, 60, 0.5) !important
|
||||||
|
|
||||||
|
.anime-actions
|
||||||
|
horizontal
|
||||||
|
justify-content center
|
||||||
|
margin content-padding 0
|
||||||
|
|
||||||
|
> 900px
|
||||||
|
.anime-actions
|
||||||
|
position absolute
|
||||||
|
top 0
|
||||||
|
right content-padding
|
||||||
|
|
||||||
.anime-rating-categories
|
.anime-rating-categories
|
||||||
horizontal
|
horizontal
|
||||||
width 100%
|
width 100%
|
||||||
|
@ -29,5 +29,5 @@ func Get(ctx *aero.Context) string {
|
|||||||
return ctx.HTML(components.Dashboard(posts))
|
return ctx.HTML(components.Dashboard(posts))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML("ARN 4.0 is currently under construction.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a>")
|
return ctx.HTML("ARN 4.0 is currently under construction.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a><br><a href='/auth/google'>Login via Google</a>")
|
||||||
}
|
}
|
||||||
|
15
pages/profile/anime-list.scarlet
Normal file
15
pages/profile/anime-list.scarlet
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
.anime-list
|
||||||
|
horizontal
|
||||||
|
|
||||||
|
.anime-list-item
|
||||||
|
padding 0.25rem
|
||||||
|
// padding calc(content-padding / 4) calc(content-padding / 2)
|
||||||
|
// margin 0.25rem 0
|
||||||
|
// position relative
|
||||||
|
|
||||||
|
.anime-list-item-image
|
||||||
|
width 55px !important
|
||||||
|
border-radius 2px
|
||||||
|
// position absolute
|
||||||
|
// left 0
|
||||||
|
// top 0
|
@ -27,5 +27,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
threads = threads[:maxPosts]
|
threads = threads[:maxPosts]
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.Profile(viewUser, user, threads))
|
animeList := viewUser.AnimeList()
|
||||||
|
|
||||||
|
return ctx.HTML(components.Profile(viewUser, user, animeList, threads))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
component Profile(viewUser *arn.User, user *arn.User, threads []*arn.Thread)
|
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread)
|
||||||
.profile
|
.profile
|
||||||
img.profile-cover(src=viewUser.CoverImageURL())
|
img.profile-cover(src=viewUser.CoverImageURL())
|
||||||
|
|
||||||
@ -49,6 +49,14 @@ component Profile(viewUser *arn.User, user *arn.User, threads []*arn.Thread)
|
|||||||
//- a.light-button(href="#") Anime
|
//- a.light-button(href="#") Anime
|
||||||
//- a.light-button(href="#") Forum
|
//- a.light-button(href="#") Forum
|
||||||
|
|
||||||
|
.profile-category
|
||||||
|
h3 Anime
|
||||||
|
|
||||||
|
.anime-list
|
||||||
|
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) + ")")
|
||||||
|
img.anime-cover-image.anime-list-item-image(src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical)
|
||||||
|
|
||||||
.profile-category
|
.profile-category
|
||||||
h3 Forum
|
h3 Forum
|
||||||
|
|
||||||
|
@ -80,4 +80,4 @@ animation cover-animation
|
|||||||
// Categories
|
// Categories
|
||||||
|
|
||||||
.profile-category
|
.profile-category
|
||||||
// padding content-padding
|
margin-bottom content-padding
|
@ -2,4 +2,5 @@
|
|||||||
vertical
|
vertical
|
||||||
padding content-padding
|
padding content-padding
|
||||||
padding-top content-padding-top
|
padding-top content-padding-top
|
||||||
line-height 1.7em
|
line-height 1.7em
|
||||||
|
position relative
|
@ -1,13 +1,18 @@
|
|||||||
.light-button-group
|
.light-button-group
|
||||||
horizontal-wrap
|
horizontal-wrap
|
||||||
justify-content flex-start
|
justify-content flex-start
|
||||||
font-size 0.9rem
|
|
||||||
|
|
||||||
.light-button
|
.light-button
|
||||||
display inline-block
|
display inline-block
|
||||||
padding 0.5rem 1rem
|
padding 0.5rem 1rem
|
||||||
border-radius 3px
|
border-radius 3px
|
||||||
|
font-size 0.9rem
|
||||||
|
|
||||||
:hover
|
:hover
|
||||||
color white !important
|
color white !important
|
||||||
background-color link-hover-color
|
background-color link-hover-color
|
||||||
|
|
||||||
|
.action-button
|
||||||
|
ui-element
|
||||||
|
font-size 1rem
|
||||||
|
text-align center
|
Loading…
Reference in New Issue
Block a user