Anime relations patch
This commit is contained in:
parent
49b887a201
commit
8aaa7898b3
@ -30,12 +30,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sync(data *kitsu.Anime) {
|
func sync(data *kitsu.Anime) *arn.Anime {
|
||||||
anime, err := arn.GetAnime(data.ID)
|
anime, err := arn.GetAnime(data.ID)
|
||||||
|
|
||||||
// This stops overwriting existing data
|
// This stops overwriting existing data
|
||||||
if err == nil || anime != nil {
|
if anime != nil {
|
||||||
return
|
return anime
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -153,6 +153,20 @@ func sync(data *kitsu.Anime) {
|
|||||||
arn.DB.Set("AnimeEpisodes", anime.ID, episodes)
|
arn.DB.Set("AnimeEpisodes", anime.ID, episodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
relations, _ := arn.GetAnimeRelations(anime.ID)
|
||||||
|
|
||||||
|
if relations == nil {
|
||||||
|
relations := &arn.AnimeRelations{
|
||||||
|
AnimeID: anime.ID,
|
||||||
|
Items: []*arn.AnimeRelation{},
|
||||||
|
}
|
||||||
|
|
||||||
|
arn.DB.Set("AnimeRelations", anime.ID, relations)
|
||||||
|
}
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
fmt.Println(color.GreenString("✔"), anime.ID, anime.Title.Canonical)
|
fmt.Println(color.GreenString("✔"), anime.ID, anime.Title.Canonical)
|
||||||
|
|
||||||
|
return anime
|
||||||
}
|
}
|
||||||
|
@ -75,3 +75,27 @@ func Relations(ctx *aero.Context) string {
|
|||||||
|
|
||||||
return ctx.HTML(components.EditAnimeTabs(anime) + editform.Render(animeRelations, "Edit anime relations", user))
|
return ctx.HTML(components.EditAnimeTabs(anime) + editform.Render(animeRelations, "Edit anime relations", user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Episodes anime episodes edit page.
|
||||||
|
func Episodes(ctx *aero.Context) string {
|
||||||
|
id := ctx.Get("id")
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
anime, err := arn.GetAnime(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
animeEpisodes, err := arn.GetAnimeEpisodes(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "Anime episodes not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.EditAnimeTabs(anime) + editform.Render(animeEpisodes, "Edit anime episodes", user))
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ component EditAnimeTabs(anime *arn.Anime)
|
|||||||
Icon("tv")
|
Icon("tv")
|
||||||
span Anime
|
span Anime
|
||||||
|
|
||||||
Tab("Edit anime", "pencil", anime.Link() + "/edit")
|
Tab("Edit", "pencil", anime.Link() + "/edit")
|
||||||
Tab("Edit characters", "pencil", anime.Link() + "/edit/characters")
|
Tab("Characters", "pencil", anime.Link() + "/edit/characters")
|
||||||
Tab("Edit relations", "pencil", anime.Link() + "/edit/relations")
|
Tab("Relations", "pencil", anime.Link() + "/edit/relations")
|
||||||
//- Tab("Edit episodes", "pencil", anime.Link() + "/edit/episodes")
|
Tab("Episodes", "pencil", anime.Link() + "/edit/episodes")
|
@ -106,7 +106,7 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/anime/:id/edit", editanime.Main)
|
l.Page("/anime/:id/edit", editanime.Main)
|
||||||
l.Page("/anime/:id/edit/characters", editanime.Characters)
|
l.Page("/anime/:id/edit/characters", editanime.Characters)
|
||||||
l.Page("/anime/:id/edit/relations", editanime.Relations)
|
l.Page("/anime/:id/edit/relations", editanime.Relations)
|
||||||
// l.Page("/anime/:id/edit/episodes", editanime.Episodes)
|
l.Page("/anime/:id/edit/episodes", editanime.Episodes)
|
||||||
|
|
||||||
// Characters
|
// Characters
|
||||||
l.Page("/character/:id", character.Get)
|
l.Page("/character/:id", character.Get)
|
||||||
|
25
patches/add-anime-relations/add-anime-relations.go
Normal file
25
patches/add-anime-relations/add-anime-relations.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
defer arn.Node.Close()
|
||||||
|
|
||||||
|
for anime := range arn.StreamAnime() {
|
||||||
|
relations, _ := arn.GetAnimeRelations(anime.ID)
|
||||||
|
|
||||||
|
if relations == nil {
|
||||||
|
relations := &arn.AnimeRelations{
|
||||||
|
AnimeID: anime.ID,
|
||||||
|
Items: []*arn.AnimeRelation{},
|
||||||
|
}
|
||||||
|
|
||||||
|
arn.DB.Set("AnimeRelations", anime.ID, relations)
|
||||||
|
fmt.Println(anime.ID, anime.Title.Canonical)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user