Added soundtrack filter for missing links

This commit is contained in:
Eduard Urbach 2018-03-25 01:54:01 +01:00
parent db64a86981
commit ee4dc577d0
4 changed files with 58 additions and 0 deletions

View File

@ -24,6 +24,7 @@ component EditorTabs(url string, user *arn.User)
Tab("Editor", "pencil", "/editor")
Tab("MAL", "exchange", "/editor/mal/diff/anime" + user.Settings().Editor.Filter.Suffix())
Tab("Anime", "tv", "/editor/anime/mapping/mal" + user.Settings().Editor.Filter.Suffix())
Tab("Tracks", "music", "/editor/soundtracks/links")
Tab("Companies", "building", "/editor/companies/description")
Tab("Kitsu", "download", "/editor/kitsu/new/anime")

View File

@ -0,0 +1,33 @@
package filtersoundtracks
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxEntries = 70
// NoLinks ...
func NoLinks(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect("/")
}
soundTracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && len(track.Links) == 0
})
arn.SortSoundTracksPopularFirst(soundTracks)
count := len(soundTracks)
if count > maxEntries {
soundTracks = soundTracks[:maxEntries]
}
return ctx.HTML(components.SoundTracksEditorList(soundTracks, count, ctx.URI(), user))
}

View File

@ -0,0 +1,20 @@
component SoundTracksEditorList(tracks []*arn.SoundTrack, count int, url string, user *arn.User)
EditorTabs(url, user)
h1.editor-list-page-title.mountable Soundtracks without links
.footer.editor-list-entry-count.mountable= strconv.Itoa(count) + " soundtracks"
table.editor-list
thead
tr.mountable
th Likes
th Title
tbody
each track in tracks
tr.mountable
td= len(track.Likes)
td
a(href=track.Link(), target="_blank", rel="noopener")= track.Title
td
each media in track.Media
if media.Service == "Youtube"
a(href="https://song.link/https://youtu.be/" + media.ServiceID, target="_blank", rel="noopener") 🔍

View File

@ -23,6 +23,7 @@ import (
"github.com/animenotifier/notify.moe/pages/editor"
"github.com/animenotifier/notify.moe/pages/editor/filteranime"
"github.com/animenotifier/notify.moe/pages/editor/filtercompanies"
"github.com/animenotifier/notify.moe/pages/editor/filtersoundtracks"
"github.com/animenotifier/notify.moe/pages/embed"
"github.com/animenotifier/notify.moe/pages/episode"
"github.com/animenotifier/notify.moe/pages/explore"
@ -272,6 +273,9 @@ func Configure(app *aero.Application) {
// Editor - Companies
l.Page("/editor/companies/description", filtercompanies.NoDescription)
// Editor - Soundtracks
l.Page("/editor/soundtracks/links", filtersoundtracks.NoLinks)
// Log
l.Page("/log", editlog.Get)