Upgraded to latest aero version
This commit is contained in:
@ -7,14 +7,14 @@ import (
|
||||
)
|
||||
|
||||
// Global activity page.
|
||||
func Global(ctx *aero.Context) string {
|
||||
func Global(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
activities := fetchActivities(user, false)
|
||||
return render(ctx, activities)
|
||||
}
|
||||
|
||||
// Followed activity page.
|
||||
func Followed(ctx *aero.Context) string {
|
||||
func Followed(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
activities := fetchActivities(user, true)
|
||||
return render(ctx, activities)
|
||||
|
@ -14,7 +14,7 @@ const (
|
||||
)
|
||||
|
||||
// render renders the activities page with the given activities.
|
||||
func render(ctx *aero.Context, allActivities []arn.Activity) string {
|
||||
func render(ctx aero.Context, allActivities []arn.Activity) error {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
@ -14,11 +15,11 @@ import (
|
||||
)
|
||||
|
||||
// Get admin page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||
return ctx.Redirect("/")
|
||||
return ctx.Redirect(http.StatusFound, "/")
|
||||
}
|
||||
|
||||
// // CPU
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
const maxReports = 80
|
||||
|
||||
// ClientErrors shows client-side errors.
|
||||
func ClientErrors(ctx *aero.Context) string {
|
||||
func ClientErrors(ctx aero.Context) error {
|
||||
reports := arn.AllClientErrorReports()
|
||||
|
||||
sort.Slice(reports, func(i, j int) bool {
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// PaymentHistory ...
|
||||
func PaymentHistory(ctx *aero.Context) string {
|
||||
func PaymentHistory(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// PurchaseHistory ...
|
||||
func PurchaseHistory(ctx *aero.Context) string {
|
||||
func PurchaseHistory(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// UserRegistrations ...
|
||||
func UserRegistrations(ctx *aero.Context) string {
|
||||
func UserRegistrations(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -4,6 +4,6 @@ import "github.com/aerogo/aero"
|
||||
import "github.com/animenotifier/notify.moe/components"
|
||||
|
||||
// WebDev ...
|
||||
func WebDev(ctx *aero.Context) string {
|
||||
func WebDev(ctx aero.Context) error {
|
||||
return ctx.HTML(components.WebDev())
|
||||
}
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get a single AMV.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
amv, err := arn.GetAMV(id)
|
||||
user := utils.GetUser(ctx)
|
||||
@ -19,6 +20,7 @@ func Get(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
||||
}
|
||||
|
||||
ctx.Data = getOpenGraph(ctx, amv)
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = getOpenGraph(ctx, amv)
|
||||
return ctx.HTML(components.AMVPage(amv, user))
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Edit track.
|
||||
func Edit(ctx *aero.Context) string {
|
||||
func Edit(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
amv, err := arn.GetAMV(id)
|
||||
user := utils.GetUser(ctx)
|
||||
|
@ -5,14 +5,15 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
)
|
||||
|
||||
func getOpenGraph(ctx *aero.Context, amv *arn.AMV) *arn.OpenGraph {
|
||||
func getOpenGraph(ctx aero.Context, amv *arn.AMV) *arn.OpenGraph {
|
||||
openGraph := &arn.OpenGraph{
|
||||
Tags: map[string]string{
|
||||
"og:title": amv.Title.ByUser(nil) + " (AMV)",
|
||||
"og:url": "https://" + ctx.App.Config.Domain + amv.Link(),
|
||||
"og:site_name": ctx.App.Config.Domain,
|
||||
"og:url": "https://" + assets.Domain + amv.Link(),
|
||||
"og:site_name": assets.Domain,
|
||||
"og:type": "video.other",
|
||||
},
|
||||
Meta: map[string]string{},
|
||||
@ -21,7 +22,7 @@ func getOpenGraph(ctx *aero.Context, amv *arn.AMV) *arn.OpenGraph {
|
||||
openGraph.Tags["og:description"] = strings.Join(amv.Tags, ", ")
|
||||
|
||||
if amv.File != "" {
|
||||
openGraph.Tags["og:video"] = "https://" + ctx.App.Config.Domain + "/videos/amvs/" + amv.File
|
||||
openGraph.Tags["og:video"] = "https://" + assets.Domain + "/videos/amvs/" + amv.File
|
||||
openGraph.Tags["og:video:type"] = "video/webm"
|
||||
openGraph.Tags["og:video:width"] = "640"
|
||||
openGraph.Tags["og:video:height"] = "360"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// Best AMVs.
|
||||
func Best(ctx *aero.Context) string {
|
||||
func Best(ctx aero.Context) error {
|
||||
amvs := fetchAll()
|
||||
|
||||
sort.Slice(amvs, func(i, j int) bool {
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// Latest AMVs.
|
||||
func Latest(ctx *aero.Context) string {
|
||||
func Latest(ctx aero.Context) error {
|
||||
amvs := fetchAll()
|
||||
|
||||
sort.Slice(amvs, func(i, j int) bool {
|
||||
|
@ -14,7 +14,7 @@ const (
|
||||
)
|
||||
|
||||
// render renders the AMVs page with the given AMVs.
|
||||
func render(ctx *aero.Context, allAMVs []*arn.AMV) string {
|
||||
func render(ctx aero.Context, allAMVs []*arn.AMV) error {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
tag := ctx.Get("tag")
|
||||
|
@ -6,7 +6,9 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
@ -18,7 +20,7 @@ const (
|
||||
)
|
||||
|
||||
// Get anime page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
anime, err := arn.GetAnime(id)
|
||||
@ -120,12 +122,13 @@ func Get(ctx *aero.Context) string {
|
||||
})
|
||||
|
||||
// Open Graph
|
||||
ctx.Data = getOpenGraph(ctx, anime)
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = getOpenGraph(ctx, anime)
|
||||
|
||||
return ctx.HTML(components.Anime(anime, animeListItem, tracks, amvs, amvAppearances, episodes, friends, friendsAnimeListItems, episodeToFriends, user))
|
||||
}
|
||||
|
||||
func getOpenGraph(ctx *aero.Context, anime *arn.Anime) *arn.OpenGraph {
|
||||
func getOpenGraph(ctx aero.Context, anime *arn.Anime) *arn.OpenGraph {
|
||||
description := anime.Summary
|
||||
|
||||
if len(description) > maxDescriptionLength {
|
||||
@ -136,7 +139,7 @@ func getOpenGraph(ctx *aero.Context, anime *arn.Anime) *arn.OpenGraph {
|
||||
Tags: map[string]string{
|
||||
"og:title": anime.Title.Canonical,
|
||||
"og:image": "https:" + anime.ImageLink("large"),
|
||||
"og:url": "https://" + ctx.App.Config.Domain + anime.Link(),
|
||||
"og:url": "https://" + assets.Domain + anime.Link(),
|
||||
"og:site_name": "notify.moe",
|
||||
"og:description": description,
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Characters ...
|
||||
func Characters(ctx *aero.Context) string {
|
||||
func Characters(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Comments ...
|
||||
func Comments(ctx *aero.Context) string {
|
||||
func Comments(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Main anime edit page.
|
||||
func Main(ctx *aero.Context) string {
|
||||
func Main(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
@ -29,7 +29,7 @@ func Main(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// Images anime images edit page.
|
||||
func Images(ctx *aero.Context) string {
|
||||
func Images(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
@ -47,7 +47,7 @@ func Images(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// Characters anime characters edit page.
|
||||
func Characters(ctx *aero.Context) string {
|
||||
func Characters(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
@ -71,7 +71,7 @@ func Characters(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// Relations anime relations edit page.
|
||||
func Relations(ctx *aero.Context) string {
|
||||
func Relations(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
@ -95,7 +95,7 @@ func Relations(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// Episodes anime episodes edit page.
|
||||
func Episodes(ctx *aero.Context) string {
|
||||
func Episodes(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Episodes ...
|
||||
func Episodes(ctx *aero.Context) string {
|
||||
func Episodes(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// RedirectByMapping redirects to the anime with the given mapping ID.
|
||||
func RedirectByMapping(mappingName string) func(*aero.Context) string {
|
||||
return func(ctx *aero.Context) string {
|
||||
func RedirectByMapping(mappingName string) func(aero.Context) error {
|
||||
return func(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
finder := arn.NewAnimeFinder(mappingName)
|
||||
anime := finder.GetAnime(id)
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// Relations ...
|
||||
func Relations(ctx *aero.Context) string {
|
||||
func Relations(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Tracks ...
|
||||
func Tracks(ctx *aero.Context) string {
|
||||
func Tracks(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// DeleteKitsu marks an anime for deletion.
|
||||
func DeleteKitsu(ctx *aero.Context) string {
|
||||
func DeleteKitsu(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
|
||||
// Is the user allowed to delete?
|
||||
@ -39,5 +39,5 @@ func DeleteKitsu(ctx *aero.Context) string {
|
||||
// Save in database
|
||||
arn.DB.Set("IDList", "deleted kitsu anime", &deletedKitsuAnime)
|
||||
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// Kitsu anime import.
|
||||
func Kitsu(ctx *aero.Context) string {
|
||||
func Kitsu(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
@ -45,5 +45,5 @@ func Kitsu(ctx *aero.Context) string {
|
||||
// Log
|
||||
fmt.Println(color.GreenString("✔"), anime.ID, anime.Title.Canonical)
|
||||
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||
)
|
||||
@ -17,15 +19,15 @@ const (
|
||||
)
|
||||
|
||||
// FilterByStatus returns a handler for the given anime list item status.
|
||||
func FilterByStatus(status string) aero.Handle {
|
||||
return func(ctx *aero.Context) string {
|
||||
func FilterByStatus(status string) aero.Handler {
|
||||
return func(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
return AnimeList(ctx, user, status)
|
||||
}
|
||||
}
|
||||
|
||||
// AnimeList renders the anime list items.
|
||||
func AnimeList(ctx *aero.Context, user *arn.User, status string) string {
|
||||
func AnimeList(ctx aero.Context, user *arn.User, status string) error {
|
||||
nick := ctx.Get("nick")
|
||||
index, _ := ctx.GetInt("index")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
@ -70,11 +72,12 @@ func AnimeList(ctx *aero.Context, user *arn.User, status string) string {
|
||||
nextIndex := infinitescroll.NextIndex(ctx, len(allItems), maxLength, index)
|
||||
|
||||
// OpenGraph data
|
||||
ctx.Data = &arn.OpenGraph{
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = &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:url": "https://" + assets.Domain + viewUser.Link(),
|
||||
"og:site_name": "notify.moe",
|
||||
"og:description": strconv.Itoa(len(animeList.Items)) + " anime",
|
||||
|
||||
|
@ -8,12 +8,12 @@ import (
|
||||
)
|
||||
|
||||
// Redirect to the full URL including the user nick.
|
||||
func Redirect(ctx *aero.Context) string {
|
||||
func Redirect(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
}
|
||||
|
||||
return ctx.Redirect("/+" + user.Nick + ctx.URI())
|
||||
return ctx.Redirect(http.StatusFound, "/+" + user.Nick + ctx.Path())
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Get anime page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Get api page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
types := []*autodocs.Type{}
|
||||
|
||||
for typeName := range arn.DB.Types() {
|
||||
|
@ -13,8 +13,8 @@ import (
|
||||
)
|
||||
|
||||
// ByType renders the api docs page for the given type.
|
||||
func ByType(typeName string) func(*aero.Context) string {
|
||||
return func(ctx *aero.Context) string {
|
||||
func ByType(typeName string) func(aero.Context) error {
|
||||
return func(ctx aero.Context) error {
|
||||
t := arn.API.Type(typeName)
|
||||
fields := []*utils.APIField{}
|
||||
|
||||
|
@ -22,7 +22,7 @@ var weekdayNames = []string{
|
||||
}
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
oneWeek := 7 * 24 * time.Hour
|
||||
|
||||
|
@ -7,7 +7,9 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
@ -16,7 +18,7 @@ const (
|
||||
)
|
||||
|
||||
// Get character.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
character, err := arn.GetCharacter(id)
|
||||
@ -101,11 +103,12 @@ func Get(ctx *aero.Context) string {
|
||||
// Set OpenGraph attributes
|
||||
description := utils.CutLongDescription(character.Description)
|
||||
|
||||
ctx.Data = &arn.OpenGraph{
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = &arn.OpenGraph{
|
||||
Tags: map[string]string{
|
||||
"og:title": character.Name.Canonical,
|
||||
"og:image": "https:" + character.ImageLink("large"),
|
||||
"og:url": "https://" + ctx.App.Config.Domain + character.Link(),
|
||||
"og:url": "https://" + assets.Domain + character.Link(),
|
||||
"og:site_name": "notify.moe",
|
||||
"og:description": description,
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Edit character.
|
||||
func Edit(ctx *aero.Context) string {
|
||||
func Edit(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
character, err := arn.GetCharacter(id)
|
||||
user := utils.GetUser(ctx)
|
||||
@ -24,7 +24,7 @@ func Edit(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// EditImages renders the form to edit the character images.
|
||||
func EditImages(ctx *aero.Context) string {
|
||||
func EditImages(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
character, err := arn.GetCharacter(id)
|
||||
user := utils.GetUser(ctx)
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// Ranking returns the ranking information for the character via the API.
|
||||
func Ranking(ctx *aero.Context) string {
|
||||
func Ranking(ctx aero.Context) error {
|
||||
// Check character ID
|
||||
id := ctx.Get("id")
|
||||
_, err := arn.GetCharacter(id)
|
||||
@ -35,7 +35,7 @@ func Ranking(ctx *aero.Context) string {
|
||||
arn.SortCharactersByLikes(characters)
|
||||
|
||||
// Allow CORS
|
||||
ctx.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
||||
ctx.Response().SetHeader("Access-Control-Allow-Origin", "*")
|
||||
|
||||
// Return ranking
|
||||
for index, character := range characters {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Best characters.
|
||||
func Best(ctx *aero.Context) string {
|
||||
func Best(ctx aero.Context) error {
|
||||
characters := fetchAll()
|
||||
|
||||
arn.SortCharactersByLikes(characters)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// Latest characters.
|
||||
func Latest(ctx *aero.Context) string {
|
||||
func Latest(ctx aero.Context) error {
|
||||
characters := fetchAll()
|
||||
|
||||
sort.Slice(characters, func(i, j int) bool {
|
||||
|
@ -14,7 +14,7 @@ const (
|
||||
)
|
||||
|
||||
// render renders the characters page with the given characters.
|
||||
func render(ctx *aero.Context, allCharacters []*arn.Character) string {
|
||||
func render(ctx aero.Context, allCharacters []*arn.Character) error {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
tag := ctx.Get("tag")
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// Get charge page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// All renders an index of all companies.
|
||||
func All(ctx *aero.Context) string {
|
||||
func All(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
companies := arn.FilterCompanies(func(company *arn.Company) bool {
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
const maxPopularCompanies = 10
|
||||
|
||||
// Popular renders the best companies.
|
||||
func Popular(ctx *aero.Context) string {
|
||||
func Popular(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
|
||||
|
@ -6,12 +6,14 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get renders a company page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
company, err := arn.GetCompany(id)
|
||||
@ -25,7 +27,7 @@ func Get(ctx *aero.Context) string {
|
||||
openGraph := &arn.OpenGraph{
|
||||
Tags: map[string]string{
|
||||
"og:title": company.Name.English,
|
||||
"og:url": "https://" + ctx.App.Config.Domain + company.Link(),
|
||||
"og:url": "https://" + assets.Domain + company.Link(),
|
||||
"og:site_name": "notify.moe",
|
||||
"og:type": "article",
|
||||
},
|
||||
@ -41,7 +43,8 @@ func Get(ctx *aero.Context) string {
|
||||
openGraph.Tags["og:description"] = company.Name.English + " company information."
|
||||
}
|
||||
|
||||
ctx.Data = openGraph
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = openGraph
|
||||
|
||||
studioAnime, producedAnime, licensedAnime := company.Anime()
|
||||
|
||||
|
@ -5,13 +5,15 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
"github.com/animenotifier/notify.moe/utils/editform"
|
||||
)
|
||||
|
||||
// Edit company.
|
||||
func Edit(ctx *aero.Context) string {
|
||||
func Edit(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
company, err := arn.GetCompany(id)
|
||||
user := utils.GetUser(ctx)
|
||||
@ -20,10 +22,11 @@ func Edit(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "Company not found", err)
|
||||
}
|
||||
|
||||
ctx.Data = &arn.OpenGraph{
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = &arn.OpenGraph{
|
||||
Tags: map[string]string{
|
||||
"og:title": company.Name.English,
|
||||
"og:url": "https://" + ctx.App.Config.Domain + company.Link(),
|
||||
"og:url": "https://" + assets.Domain + company.Link(),
|
||||
"og:site_name": "notify.moe",
|
||||
// "og:image": company.Image,
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// AnimeList ...
|
||||
func AnimeList(ctx *aero.Context) string {
|
||||
func AnimeList(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
nickA := ctx.Get("nick-1")
|
||||
nickB := ctx.Get("nick-2")
|
||||
|
@ -18,7 +18,7 @@ const (
|
||||
)
|
||||
|
||||
// Get edit log.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
nick := ctx.Get("nick")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package editor
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
@ -10,11 +11,11 @@ import (
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||
return ctx.Redirect("/")
|
||||
return ctx.Redirect(http.StatusFound, "/")
|
||||
}
|
||||
|
||||
ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool {
|
||||
@ -43,5 +44,5 @@ func Get(ctx *aero.Context) string {
|
||||
scoreTitle += objectType + ": " + strconv.Itoa(score) + "\n"
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Editor(ctx.URI(), score, scoreTitle, scoreTypes, user))
|
||||
return ctx.HTML(components.Editor(ctx.Path(), score, scoreTitle, scoreTypes, user))
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// All ...
|
||||
func All(ctx *aero.Context) string {
|
||||
func All(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"All anime",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// AniList ...
|
||||
func AniList(ctx *aero.Context) string {
|
||||
func AniList(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without Anilist mappings",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Characters ...
|
||||
func Characters(ctx *aero.Context) string {
|
||||
func Characters(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without characters",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// DuplicateMappings ...
|
||||
func DuplicateMappings(ctx *aero.Context) string {
|
||||
func DuplicateMappings(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime with duplicate mappings",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// EpisodeLength ...
|
||||
func EpisodeLength(ctx *aero.Context) string {
|
||||
func EpisodeLength(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without an episode length",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Genres ...
|
||||
func Genres(ctx *aero.Context) string {
|
||||
func Genres(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without genres",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Licensors ...
|
||||
func Licensors(ctx *aero.Context) string {
|
||||
func Licensors(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without licensors",
|
||||
|
@ -6,16 +6,16 @@ import (
|
||||
)
|
||||
|
||||
// LowResolutionAnimeImages filters anime with low resolution images.
|
||||
func LowResolutionAnimeImages(ctx *aero.Context) string {
|
||||
func LowResolutionAnimeImages(ctx aero.Context) error {
|
||||
return filterAnimeImages(ctx, "Anime with low resolution images", arn.AnimeImageLargeWidth, arn.AnimeImageLargeHeight)
|
||||
}
|
||||
|
||||
// UltraLowResolutionAnimeImages filters anime with ultra low resolution images.
|
||||
func UltraLowResolutionAnimeImages(ctx *aero.Context) string {
|
||||
func UltraLowResolutionAnimeImages(ctx aero.Context) error {
|
||||
return filterAnimeImages(ctx, "Anime with ultra low resolution images", arn.AnimeImageLargeWidth/2, arn.AnimeImageLargeHeight/2)
|
||||
}
|
||||
|
||||
func filterAnimeImages(ctx *aero.Context, title string, minExpectedWidth int, minExpectedHeight int) string {
|
||||
func filterAnimeImages(ctx aero.Context, title string, minExpectedWidth int, minExpectedHeight int) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
title,
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// MAL ...
|
||||
func MAL(ctx *aero.Context) string {
|
||||
func MAL(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without MAL mappings",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Producers ...
|
||||
func Producers(ctx *aero.Context) string {
|
||||
func Producers(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without producers",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Relations ...
|
||||
func Relations(ctx *aero.Context) string {
|
||||
func Relations(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without relations",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Shoboi ...
|
||||
func Shoboi(ctx *aero.Context) string {
|
||||
func Shoboi(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without Shoboi mappings",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Source ...
|
||||
func Source(ctx *aero.Context) string {
|
||||
func Source(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without a source",
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// StartDate ...
|
||||
func StartDate(ctx *aero.Context) string {
|
||||
func StartDate(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without a valid start date",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Studios ...
|
||||
func Studios(ctx *aero.Context) string {
|
||||
func Studios(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without studios",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Synopsis ...
|
||||
func Synopsis(ctx *aero.Context) string {
|
||||
func Synopsis(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without a long synopsis",
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// Trailers ...
|
||||
func Trailers(ctx *aero.Context) string {
|
||||
func Trailers(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without trailers",
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
const maxAnimeEntries = 70
|
||||
|
||||
// editorList renders the anime list with the given title and filter.
|
||||
func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) string {
|
||||
func editorList(ctx aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||
@ -23,7 +23,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, s
|
||||
animes, count := filterAnime(ctx, user, filter)
|
||||
|
||||
// Determine URL
|
||||
url := strings.TrimPrefix(ctx.URI(), "/_")
|
||||
url := strings.TrimPrefix(ctx.Path(), "/_")
|
||||
urlParts := strings.Split(url, "/")
|
||||
urlParts = urlParts[:len(urlParts)-4]
|
||||
url = strings.Join(urlParts, "/")
|
||||
@ -40,7 +40,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, s
|
||||
|
||||
// filterAnime filters anime by the given filter function and
|
||||
// additionally applies year and types filters if specified.
|
||||
func filterAnime(ctx *aero.Context, user *arn.User, filter func(*arn.Anime) bool) ([]*arn.Anime, int) {
|
||||
func filterAnime(ctx aero.Context, user *arn.User, filter func(*arn.Anime) bool) ([]*arn.Anime, int) {
|
||||
year := ctx.Get("year")
|
||||
status := ctx.Get("status")
|
||||
season := ctx.Get("season")
|
||||
|
@ -1,6 +1,8 @@
|
||||
package filtercompanies
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
@ -10,11 +12,11 @@ import (
|
||||
const maxEntries = 70
|
||||
|
||||
// NoDescription ...
|
||||
func NoDescription(ctx *aero.Context) string {
|
||||
func NoDescription(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||
return ctx.Redirect("/")
|
||||
return ctx.Redirect(http.StatusFound, "/")
|
||||
}
|
||||
|
||||
companies := arn.FilterCompanies(func(company *arn.Company) bool {
|
||||
@ -29,5 +31,5 @@ func NoDescription(ctx *aero.Context) string {
|
||||
companies = companies[:maxEntries]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CompaniesEditorList(companies, count, ctx.URI(), user))
|
||||
return ctx.HTML(components.CompaniesEditorList(companies, count, ctx.Path(), user))
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// File shows soundtracks without an audio file.
|
||||
func File(ctx *aero.Context) string {
|
||||
func File(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Soundtracks without an audio file",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Links shows soundtracks without links.
|
||||
func Links(ctx *aero.Context) string {
|
||||
func Links(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Soundtracks without links",
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// MissingLyrics shows soundtracks without lyrics.
|
||||
func MissingLyrics(ctx *aero.Context) string {
|
||||
func MissingLyrics(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Soundtracks without lyrics",
|
||||
@ -26,7 +26,7 @@ func MissingLyrics(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// UnalignedLyrics shows soundtracks with unaligned lyrics.
|
||||
func UnalignedLyrics(ctx *aero.Context) string {
|
||||
func UnalignedLyrics(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Soundtracks with unaligned lyrics",
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Tags shows soundtracks with less than 3 tags.
|
||||
func Tags(ctx *aero.Context) string {
|
||||
func Tags(ctx aero.Context) error {
|
||||
return editorList(
|
||||
ctx,
|
||||
"Soundtracks with less than 3 tags",
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
const maxSoundTrackEntries = 70
|
||||
|
||||
// editorList renders the soundtrack list with the given title and filter.
|
||||
func editorList(ctx *aero.Context, title string, filter func(*arn.SoundTrack) bool, searchLink func(*arn.SoundTrack) string) string {
|
||||
func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) bool, searchLink func(*arn.SoundTrack) string) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||
@ -21,7 +21,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.SoundTrack) bo
|
||||
}
|
||||
|
||||
tracks, count := filterSoundTracks(ctx, user, filter)
|
||||
url := strings.TrimPrefix(ctx.URI(), "/_")
|
||||
url := strings.TrimPrefix(ctx.Path(), "/_")
|
||||
|
||||
return ctx.HTML(components.SoundTracksEditorListFull(
|
||||
title,
|
||||
@ -34,7 +34,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.SoundTrack) bo
|
||||
}
|
||||
|
||||
// filterSoundTracks filters soundtracks by the given filter function.
|
||||
func filterSoundTracks(ctx *aero.Context, user *arn.User, filter func(*arn.SoundTrack) bool) ([]*arn.SoundTrack, int) {
|
||||
func filterSoundTracks(ctx aero.Context, user *arn.User, filter func(*arn.SoundTrack) bool) ([]*arn.SoundTrack, int) {
|
||||
// Filter
|
||||
tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
||||
return !track.IsDraft && filter(track)
|
||||
|
@ -29,7 +29,7 @@ var jobInfo = map[string]*utils.JobInfo{
|
||||
var jobLogs = []string{}
|
||||
|
||||
// Overview shows all background jobs.
|
||||
func Overview(ctx *aero.Context) string {
|
||||
func Overview(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
jobs := []*utils.JobInfo{}
|
||||
|
||||
@ -41,5 +41,5 @@ func Overview(ctx *aero.Context) string {
|
||||
return jobs[i].Name < jobs[j].Name
|
||||
})
|
||||
|
||||
return ctx.HTML(components.EditorJobs(jobs, jobLogs, ctx.URI(), user))
|
||||
return ctx.HTML(components.EditorJobs(jobs, jobLogs, ctx.Path(), user))
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
var jobStartMutex sync.Mutex
|
||||
|
||||
// Start will start the specified background job.
|
||||
func Start(ctx *aero.Context) string {
|
||||
func Start(ctx aero.Context) error {
|
||||
jobStartMutex.Lock()
|
||||
defer jobStartMutex.Unlock()
|
||||
|
||||
@ -38,5 +38,5 @@ func Start(ctx *aero.Context) string {
|
||||
job.Start()
|
||||
jobLogs = append(jobLogs, user.Nick+" started "+job.Name+" job ("+arn.DateTimeUTC()+").")
|
||||
|
||||
return "ok"
|
||||
return nil
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// NewKitsuAnime ...
|
||||
func NewKitsuAnime(ctx *aero.Context) string {
|
||||
func NewKitsuAnime(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
finder := arn.NewAnimeFinder("kitsu/anime")
|
||||
deletedIDs, err := arn.GetIDList("deleted kitsu anime")
|
||||
@ -31,5 +31,5 @@ func NewKitsuAnime(ctx *aero.Context) string {
|
||||
return a.ID > b.ID
|
||||
})
|
||||
|
||||
return ctx.HTML(components.NewKitsuAnime(animes, ctx.URI(), user))
|
||||
return ctx.HTML(components.NewKitsuAnime(animes, ctx.Path(), user))
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ const maxCompareMALEntries = 15
|
||||
type diffFunction func(*arn.Anime, *mal.Anime) []animediff.Difference
|
||||
|
||||
// CompareMAL ...
|
||||
func CompareMAL(ctx *aero.Context) string {
|
||||
func CompareMAL(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
year := ctx.Get("year")
|
||||
status := ctx.Get("status")
|
||||
|
@ -9,21 +9,21 @@ import (
|
||||
)
|
||||
|
||||
// Get anime list in the browser extension.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return utils.AllowEmbed(ctx, ctx.HTML(components.Login("_blank")))
|
||||
return ctx.HTML(components.Login("_blank"))
|
||||
}
|
||||
|
||||
if !user.HasBasicInfo() {
|
||||
return utils.AllowEmbed(ctx, ctx.HTML(components.ExtensionEnterBasicInfo()))
|
||||
return ctx.HTML(components.ExtensionEnterBasicInfo())
|
||||
}
|
||||
|
||||
// Extension is enabled as long as the site isn't finished yet.
|
||||
// ---
|
||||
// if !user.IsPro() && user.TimeSinceRegistered() > 14*24*time.Hour {
|
||||
// return utils.AllowEmbed(ctx, ctx.HTML(components.EmbedProNotice(user)))
|
||||
// return ctx.HTML(components.EmbedProNotice(user))
|
||||
// }
|
||||
|
||||
animeList := user.AnimeList()
|
||||
@ -35,5 +35,5 @@ func Get(ctx *aero.Context) string {
|
||||
watchingList := animeList.Watching()
|
||||
watchingList.Sort()
|
||||
|
||||
return utils.AllowEmbed(ctx, ctx.HTML(components.BrowserExtension(watchingList, animeList.User(), user)))
|
||||
return ctx.HTML(components.BrowserExtension(watchingList, animeList.User(), user))
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func init() {
|
||||
}
|
||||
|
||||
// Get renders the anime episode.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
episodeNumber, err := ctx.GetInt("episode-number")
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// Subtitles returns the subtitles.
|
||||
func Subtitles(ctx *aero.Context) string {
|
||||
func Subtitles(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
language := ctx.Get("language")
|
||||
episodeNumber, err := ctx.GetInt("episode-number")
|
||||
@ -26,8 +26,8 @@ func Subtitles(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||
}
|
||||
|
||||
ctx.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
||||
ctx.Response().Header().Set("Content-Type", "text/vtt; charset=utf-8")
|
||||
ctx.Response().SetHeader("Access-Control-Allow-Origin", "*")
|
||||
ctx.Response().SetHeader("Content-Type", "text/vtt; charset=utf-8")
|
||||
|
||||
obj, err := spaces.GetObject("arn", fmt.Sprintf("videos/anime/%s/%d.%s.vtt", anime.ID, episodeNumber, language), minio.GetObjectOptions{})
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Filter ...
|
||||
func Filter(ctx *aero.Context) string {
|
||||
func Filter(ctx aero.Context) error {
|
||||
year := ctx.Get("year")
|
||||
season := ctx.Get("season")
|
||||
status := ctx.Get("status")
|
||||
|
@ -18,7 +18,7 @@ const (
|
||||
)
|
||||
|
||||
// AnimeByAverageColor returns all anime with an image in the given color.
|
||||
func AnimeByAverageColor(ctx *aero.Context) string {
|
||||
func AnimeByAverageColor(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
color := ctx.Get("color")
|
||||
index, _ := ctx.GetInt("index")
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Sequels ...
|
||||
func Sequels(ctx *aero.Context) string {
|
||||
func Sequels(ctx aero.Context) error {
|
||||
nick := ctx.Get("nick")
|
||||
user := utils.GetUser(ctx)
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
const minYear = 1963
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
maxYear := time.Now().Year() - 1
|
||||
hallOfFameEntries := []*utils.HallOfFameEntry{}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
const ThreadsPerPage = 20
|
||||
|
||||
// Get forum category.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
tag := ctx.Get("tag")
|
||||
threads := arn.GetThreadsByTag(tag)
|
||||
arn.SortThreads(threads)
|
||||
|
@ -3,20 +3,23 @@ package frontpage
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
description := "Anime list, tracker, database and notifier for new anime episodes. Create your own anime list and keep track of your progress as you watch."
|
||||
|
||||
ctx.Data = &arn.OpenGraph{
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = &arn.OpenGraph{
|
||||
Tags: map[string]string{
|
||||
"og:title": ctx.App.Config.Title,
|
||||
"og:title": assets.Manifest.Name,
|
||||
"og:description": description,
|
||||
"og:type": "website",
|
||||
"og:url": "https://" + ctx.App.Config.Domain,
|
||||
"og:image": "https://" + ctx.App.Config.Domain + "/images/brand/220.png",
|
||||
"og:url": "https://" + assets.Domain,
|
||||
"og:image": "https://" + assets.Domain + "/images/brand/220.png",
|
||||
},
|
||||
Meta: map[string]string{
|
||||
"description": description,
|
||||
|
@ -13,7 +13,7 @@ const animePerPage = 100
|
||||
const animeRatingCountThreshold = 5
|
||||
|
||||
// Get renders the genre page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
genreName := ctx.Get("name")
|
||||
animes := []*arn.Anime{}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
genres := []string{}
|
||||
genreToAnime := map[string]*arn.Anime{}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Edit ...
|
||||
func Edit(ctx *aero.Context) string {
|
||||
func Edit(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
group, err := arn.GetGroup(id)
|
||||
user := utils.GetUser(ctx)
|
||||
@ -30,7 +30,7 @@ func Edit(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// EditImage renders the form to edit the group images.
|
||||
func EditImage(ctx *aero.Context) string {
|
||||
func EditImage(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
group, err := arn.GetGroup(id)
|
||||
user := utils.GetUser(ctx)
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Feed shows the group front page.
|
||||
func Feed(ctx *aero.Context) string {
|
||||
func Feed(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
group, err := arn.GetGroup(id)
|
||||
@ -25,6 +26,7 @@ func Feed(ctx *aero.Context) string {
|
||||
member = group.FindMember(user.ID)
|
||||
}
|
||||
|
||||
ctx.Data = getOpenGraph(ctx, group)
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = getOpenGraph(ctx, group)
|
||||
return ctx.HTML(components.GroupFeed(group, member, user))
|
||||
}
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Info shows the group information page.
|
||||
func Info(ctx *aero.Context) string {
|
||||
func Info(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
group, err := arn.GetGroup(id)
|
||||
@ -25,6 +26,7 @@ func Info(ctx *aero.Context) string {
|
||||
member = group.FindMember(user.ID)
|
||||
}
|
||||
|
||||
ctx.Data = getOpenGraph(ctx, group)
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = getOpenGraph(ctx, group)
|
||||
return ctx.HTML(components.GroupInfo(group, member, user))
|
||||
}
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Members shows the group members.
|
||||
func Members(ctx *aero.Context) string {
|
||||
func Members(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
group, err := arn.GetGroup(id)
|
||||
@ -25,6 +26,7 @@ func Members(ctx *aero.Context) string {
|
||||
member = group.FindMember(user.ID)
|
||||
}
|
||||
|
||||
ctx.Data = getOpenGraph(ctx, group)
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = getOpenGraph(ctx, group)
|
||||
return ctx.HTML(components.GroupMembers(group, member, user))
|
||||
}
|
||||
|
@ -3,15 +3,16 @@ package group
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/assets"
|
||||
)
|
||||
|
||||
func getOpenGraph(ctx *aero.Context, group *arn.Group) *arn.OpenGraph {
|
||||
func getOpenGraph(ctx aero.Context, group *arn.Group) *arn.OpenGraph {
|
||||
return &arn.OpenGraph{
|
||||
Tags: map[string]string{
|
||||
"og:title": group.Name,
|
||||
"og:description": group.Tagline,
|
||||
"og:image": "https:" + group.ImageLink("large"),
|
||||
"og:url": "https://" + ctx.App.Config.Domain + group.Link(),
|
||||
"og:url": "https://" + assets.Domain + group.Link(),
|
||||
"og:site_name": "notify.moe",
|
||||
},
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// Joined shows the most popular joined groups.
|
||||
func Joined(ctx *aero.Context) string {
|
||||
func Joined(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// Latest shows the latest groups.
|
||||
func Latest(ctx *aero.Context) string {
|
||||
func Latest(ctx aero.Context) error {
|
||||
groups := fetchGroups("")
|
||||
|
||||
sort.Slice(groups, func(i, j int) bool {
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// Popular shows the most popular groups.
|
||||
func Popular(ctx *aero.Context) string {
|
||||
func Popular(ctx aero.Context) error {
|
||||
groups := fetchGroups("")
|
||||
|
||||
sort.Slice(groups, func(i, j int) bool {
|
||||
|
@ -14,7 +14,7 @@ const (
|
||||
)
|
||||
|
||||
// render renders the groups page with the given groups.
|
||||
func render(ctx *aero.Context, allGroups []*arn.Group) string {
|
||||
func render(ctx aero.Context, allGroups []*arn.Group) error {
|
||||
user := utils.GetUser(ctx)
|
||||
index, _ := ctx.GetInt("index")
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// Get the anime list or the frontpage when logged out.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -18,7 +18,7 @@ func Register(l *layout.Layout) {
|
||||
l.Page("/editor", editor.Get)
|
||||
|
||||
// Editor links can be filtered by year, status and type
|
||||
editorFilterable := func(route string, handler func(ctx *aero.Context) string) {
|
||||
editorFilterable := func(route string, handler func(ctx aero.Context) error) {
|
||||
l.Page(route+"/:year/:season/:status/:type", handler)
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Get inventory page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
viewUser := user
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package listimportanilist
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@ -12,34 +14,34 @@ import (
|
||||
)
|
||||
|
||||
// Preview shows an import preview.
|
||||
func Preview(ctx *aero.Context) string {
|
||||
func Preview(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
}
|
||||
|
||||
matches, response := getMatches(ctx)
|
||||
matches, err := getMatches(ctx)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.ImportAnilist(user, matches))
|
||||
}
|
||||
|
||||
// Finish ...
|
||||
func Finish(ctx *aero.Context) string {
|
||||
func Finish(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
}
|
||||
|
||||
matches, response := getMatches(ctx)
|
||||
matches, err := getMatches(ctx)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
animeList := user.AnimeList()
|
||||
@ -71,31 +73,29 @@ func Finish(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// getMatches finds and returns all matches for the logged in user.
|
||||
func getMatches(ctx *aero.Context) ([]*arn.AniListMatch, string) {
|
||||
func getMatches(ctx aero.Context) ([]*arn.AniListMatch, error) {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
return nil, errors.New("Not logged in")
|
||||
}
|
||||
|
||||
// Get user
|
||||
anilistUser, err := anilist.GetUser(user.Accounts.AniList.Nick)
|
||||
|
||||
if err != nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "User doesn't exist on AniList", err)
|
||||
return nil, fmt.Errorf("User doesn't exist on AniList: %s", err.Error())
|
||||
}
|
||||
|
||||
// Get anime list
|
||||
anilistAnimeList, err := anilist.GetAnimeList(anilistUser.ID)
|
||||
|
||||
if err != nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "Couldn't load your anime list from AniList", err)
|
||||
return nil, fmt.Errorf("Couldn't load your anime list from AniList: %s", err.Error())
|
||||
}
|
||||
|
||||
// Find matches
|
||||
matches := findAllMatches(anilistAnimeList)
|
||||
|
||||
return matches, ""
|
||||
return matches, nil
|
||||
}
|
||||
|
||||
// findAllMatches returns all matches for the anime inside an anilist anime list.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package listimportkitsu
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
@ -11,34 +13,34 @@ import (
|
||||
)
|
||||
|
||||
// Preview shows an import preview.
|
||||
func Preview(ctx *aero.Context) string {
|
||||
func Preview(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
}
|
||||
|
||||
matches, response := getMatches(ctx)
|
||||
matches, err := getMatches(ctx)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.ImportKitsu(user, matches))
|
||||
}
|
||||
|
||||
// Finish ...
|
||||
func Finish(ctx *aero.Context) string {
|
||||
func Finish(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
}
|
||||
|
||||
matches, response := getMatches(ctx)
|
||||
matches, err := getMatches(ctx)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
animeList := user.AnimeList()
|
||||
@ -82,23 +84,23 @@ func Finish(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// getMatches finds and returns all matches for the logged in user.
|
||||
func getMatches(ctx *aero.Context) ([]*arn.KitsuMatch, string) {
|
||||
func getMatches(ctx aero.Context) ([]*arn.KitsuMatch, error) {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
return nil, errors.New("Not logged in")
|
||||
}
|
||||
|
||||
kitsuUser, err := kitsu.GetUser(user.Accounts.Kitsu.Nick)
|
||||
|
||||
if err != nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "Couldn't load your user info from Kitsu", err)
|
||||
return nil, fmt.Errorf("Couldn't load your user info from Kitsu: %s", err.Error())
|
||||
}
|
||||
|
||||
library := kitsuUser.StreamLibraryEntries()
|
||||
matches := findAllMatches(library)
|
||||
|
||||
return matches, ""
|
||||
return matches, nil
|
||||
}
|
||||
|
||||
// findAllMatches returns all matches for the anime inside an anilist anime list.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package listimportmyanimelist
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@ -12,34 +14,34 @@ import (
|
||||
)
|
||||
|
||||
// Preview shows an import preview.
|
||||
func Preview(ctx *aero.Context) string {
|
||||
func Preview(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
}
|
||||
|
||||
matches, response := getMatches(ctx)
|
||||
matches, err := getMatches(ctx)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.ImportMyAnimeList(user, matches))
|
||||
}
|
||||
|
||||
// Finish ...
|
||||
func Finish(ctx *aero.Context) string {
|
||||
func Finish(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
}
|
||||
|
||||
matches, response := getMatches(ctx)
|
||||
matches, err := getMatches(ctx)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
animeList := user.AnimeList()
|
||||
@ -76,22 +78,22 @@ func Finish(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
// getMatches finds and returns all matches for the logged in user.
|
||||
func getMatches(ctx *aero.Context) ([]*arn.MyAnimeListMatch, string) {
|
||||
func getMatches(ctx aero.Context) ([]*arn.MyAnimeListMatch, error) {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||
return nil, errors.New("Not logged in")
|
||||
}
|
||||
|
||||
malAnimeList, err := mal.GetAnimeList(user.Accounts.MyAnimeList.Nick)
|
||||
|
||||
if err != nil {
|
||||
return nil, ctx.Error(http.StatusBadRequest, "Couldn't load your anime list from MyAnimeList", err)
|
||||
return nil, fmt.Errorf("Couldn't load your anime list from MyAnimeList: %s", err.Error())
|
||||
}
|
||||
|
||||
matches := findAllMatches(malAnimeList)
|
||||
|
||||
return matches, ""
|
||||
return matches, nil
|
||||
}
|
||||
|
||||
// findAllMatches returns all matches for the anime inside an anilist anime list.
|
||||
|
@ -6,6 +6,6 @@ import (
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
func Get(ctx aero.Context) error {
|
||||
return ctx.HTML(components.Login(""))
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user