Started working on Kitsu import
This commit is contained in:
parent
180c5b475b
commit
771e6b026c
19
pages/animeimport/animeimport.go
Normal file
19
pages/animeimport/animeimport.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package animeimport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Kitsu anime import.
|
||||||
|
func Kitsu(ctx *aero.Context) string {
|
||||||
|
// id := ctx.Get("id")
|
||||||
|
// user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if true {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
@ -13,6 +13,7 @@ component NewKitsuAnime(animes []*kitsu.Anime, url string, user *arn.User)
|
|||||||
th Title
|
th Title
|
||||||
th Type
|
th Type
|
||||||
th Year
|
th Year
|
||||||
|
th Actions
|
||||||
tbody
|
tbody
|
||||||
each anime in animes
|
each anime in animes
|
||||||
tr.mountable
|
tr.mountable
|
||||||
@ -26,3 +27,7 @@ component NewKitsuAnime(animes []*kitsu.Anime, url string, user *arn.User)
|
|||||||
td
|
td
|
||||||
if len(anime.Attributes.StartDate) >= 4
|
if len(anime.Attributes.StartDate) >= 4
|
||||||
span= anime.Attributes.StartDate[:4]
|
span= anime.Attributes.StartDate[:4]
|
||||||
|
td
|
||||||
|
button.action(data-action="importKitsuAnime", data-trigger="click", data-id=anime.ID)
|
||||||
|
Icon("download")
|
||||||
|
span Import
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/layout"
|
"github.com/animenotifier/notify.moe/layout"
|
||||||
"github.com/animenotifier/notify.moe/pages/admin"
|
"github.com/animenotifier/notify.moe/pages/admin"
|
||||||
"github.com/animenotifier/notify.moe/pages/anime"
|
"github.com/animenotifier/notify.moe/pages/anime"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/animeimport"
|
||||||
"github.com/animenotifier/notify.moe/pages/animelist"
|
"github.com/animenotifier/notify.moe/pages/animelist"
|
||||||
"github.com/animenotifier/notify.moe/pages/animelistitem"
|
"github.com/animenotifier/notify.moe/pages/animelistitem"
|
||||||
"github.com/animenotifier/notify.moe/pages/apiview"
|
"github.com/animenotifier/notify.moe/pages/apiview"
|
||||||
@ -221,6 +222,9 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/shop/history", shop.PurchaseHistory)
|
l.Page("/shop/history", shop.PurchaseHistory)
|
||||||
app.Post("/api/shop/buy/:item/:quantity", shop.BuyItem)
|
app.Post("/api/shop/buy/:item/:quantity", shop.BuyItem)
|
||||||
|
|
||||||
|
// Import anime
|
||||||
|
app.Post("/api/import/kitsu/anime/:id", animeimport.Kitsu)
|
||||||
|
|
||||||
// Upload
|
// Upload
|
||||||
app.Post("/api/upload/avatar", upload.Avatar)
|
app.Post("/api/upload/avatar", upload.Avatar)
|
||||||
app.Post("/api/upload/cover", upload.Cover)
|
app.Post("/api/upload/cover", upload.Cover)
|
||||||
|
@ -27,3 +27,17 @@ export function malDiffFilterAnime(arn: AnimeNotifier, input: HTMLInputElement)
|
|||||||
|
|
||||||
arn.app.load(`/editor/anime/maldiff/${year.value}/${status.value}/${type.value}`)
|
arn.app.load(`/editor/anime/maldiff/${year.value}/${status.value}/${type.value}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Import Kitsu anime
|
||||||
|
export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||||
|
let response = await fetch(`/api/import/kitsu/anime/${button.dataset.id}`, {
|
||||||
|
method: "POST",
|
||||||
|
credentials: "same-origin"
|
||||||
|
})
|
||||||
|
|
||||||
|
if(response.ok) {
|
||||||
|
arn.reloadContent()
|
||||||
|
} else {
|
||||||
|
arn.statusMessage.showError(await response.text())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user