Upgraded to latest aero version

This commit is contained in:
2019-06-01 13:55:49 +09:00
parent ae591e5e7e
commit 28db818c37
196 changed files with 645 additions and 593 deletions

View File

@ -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))
}

View File

@ -6,7 +6,7 @@ import (
)
// All ...
func All(ctx *aero.Context) string {
func All(ctx aero.Context) error {
return editorList(
ctx,
"All anime",

View File

@ -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",

View File

@ -6,7 +6,7 @@ import (
)
// Characters ...
func Characters(ctx *aero.Context) string {
func Characters(ctx aero.Context) error {
return editorList(
ctx,
"Anime without characters",

View File

@ -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",

View File

@ -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",

View File

@ -6,7 +6,7 @@ import (
)
// Genres ...
func Genres(ctx *aero.Context) string {
func Genres(ctx aero.Context) error {
return editorList(
ctx,
"Anime without genres",

View File

@ -6,7 +6,7 @@ import (
)
// Licensors ...
func Licensors(ctx *aero.Context) string {
func Licensors(ctx aero.Context) error {
return editorList(
ctx,
"Anime without licensors",

View File

@ -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,

View File

@ -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",

View File

@ -6,7 +6,7 @@ import (
)
// Producers ...
func Producers(ctx *aero.Context) string {
func Producers(ctx aero.Context) error {
return editorList(
ctx,
"Anime without producers",

View File

@ -6,7 +6,7 @@ import (
)
// Relations ...
func Relations(ctx *aero.Context) string {
func Relations(ctx aero.Context) error {
return editorList(
ctx,
"Anime without relations",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -6,7 +6,7 @@ import (
)
// Studios ...
func Studios(ctx *aero.Context) string {
func Studios(ctx aero.Context) error {
return editorList(
ctx,
"Anime without studios",

View File

@ -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",

View File

@ -8,7 +8,7 @@ import (
)
// Trailers ...
func Trailers(ctx *aero.Context) string {
func Trailers(ctx aero.Context) error {
return editorList(
ctx,
"Anime without trailers",

View File

@ -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")

View File

@ -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))
}

View File

@ -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",

View 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",

View File

@ -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",

View File

@ -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",

View File

@ -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)

View File

@ -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))
}

View File

@ -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
}

View File

@ -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))
}

View File

@ -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")