Added unaligned lyrics filter for soundtracks

This commit is contained in:
Eduard Urbach 2018-04-25 16:13:03 +02:00
parent 220f2e2eba
commit 9c68ecb4bb
3 changed files with 24 additions and 4 deletions

View File

@ -86,10 +86,15 @@ component EditorTabs(url string, user *arn.User)
if strings.Contains(url, "/editor/soundtracks/")
.tabs
Tab("Links", "external-link", "/editor/soundtracks/links")
Tab("Lyrics", "font", "/editor/soundtracks/lyrics")
Tab("Lyrics", "font", "/editor/soundtracks/lyrics/missing")
Tab("Tags", "tag", "/editor/soundtracks/tags")
Tab("File", "volume-off", "/editor/soundtracks/file")
if strings.Contains(url, "/editor/soundtracks/lyrics/")
.tabs
Tab("Missing", "times", "/editor/soundtracks/lyrics/missing")
Tab("Unaligned", "align-left", "/editor/soundtracks/lyrics/unaligned")
if strings.Contains(url, "/editor/anime/") || strings.Contains(url, "/editor/mal/diff/anime")
.editor-filters
#filter-root(data-url=url)

View File

@ -1,12 +1,14 @@
package filtersoundtracks
import (
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// Lyrics shows soundtracks without lyrics.
func Lyrics(ctx *aero.Context) string {
// MissingLyrics shows soundtracks without lyrics.
func MissingLyrics(ctx *aero.Context) string {
return editorList(
ctx,
"Soundtracks without lyrics",
@ -18,3 +20,15 @@ func Lyrics(ctx *aero.Context) string {
},
)
}
// UnalignedLyrics shows soundtracks with unaligned lyrics.
func UnalignedLyrics(ctx *aero.Context) string {
return editorList(
ctx,
"Soundtracks with unaligned lyrics",
func(track *arn.SoundTrack) bool {
return track.Lyrics.Native != "" && track.Lyrics.Romaji != "" && strings.Count(track.Lyrics.Native, "\n") != strings.Count(track.Lyrics.Romaji, "\n")
},
nil,
)
}

View File

@ -338,7 +338,8 @@ func Configure(app *aero.Application) {
// Editor - Soundtracks
l.Page("/editor/soundtracks/links", filtersoundtracks.Links)
l.Page("/editor/soundtracks/lyrics", filtersoundtracks.Lyrics)
l.Page("/editor/soundtracks/lyrics/missing", filtersoundtracks.MissingLyrics)
l.Page("/editor/soundtracks/lyrics/unaligned", filtersoundtracks.UnalignedLyrics)
l.Page("/editor/soundtracks/tags", filtersoundtracks.Tags)
l.Page("/editor/soundtracks/file", filtersoundtracks.File)