From 15db0a7e80414bffd0a0414f18cd0240282431c2 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 23 Mar 2018 01:43:45 +0100 Subject: [PATCH] Implemented editor filters --- mixins/AnimeEditorList.pixy | 6 +- pages/database/database.pixy | 37 ----------- pages/{ => editor}/database/database.go | 0 pages/editor/database/database.pixy | 37 +++++++++++ pages/{ => editor}/database/database.scarlet | 0 pages/{ => editor}/database/select.go | 0 pages/editor/editor.go | 10 ++- pages/editor/editor.pixy | 63 ++++++++++--------- pages/editor/filteranime/utils.go | 54 +++++++++++++--- .../editor/filtercompanies/filtercompanies.go | 9 ++- .../filtercompanies/filtercompanies.pixy | 4 +- pages/editor/kitsu.pixy | 2 +- pages/editor/mal.go | 35 ++++++++--- pages/editor/mal.pixy | 56 +++++++++-------- pages/explore/explore.pixy | 20 ++++-- pages/index.go | 62 ++++++++++++------ scripts/Actions/Editor.ts | 9 --- scripts/Actions/Explore.ts | 14 +++-- styles/corner-buttons.scarlet | 3 + tests.go | 6 ++ 20 files changed, 273 insertions(+), 154 deletions(-) delete mode 100644 pages/database/database.pixy rename pages/{ => editor}/database/database.go (100%) create mode 100644 pages/editor/database/database.pixy rename pages/{ => editor}/database/database.scarlet (100%) rename pages/{ => editor}/database/select.go (100%) diff --git a/mixins/AnimeEditorList.pixy b/mixins/AnimeEditorList.pixy index 7e992238..87ca2b38 100644 --- a/mixins/AnimeEditorList.pixy +++ b/mixins/AnimeEditorList.pixy @@ -1,5 +1,5 @@ -component AnimeEditorListFull(title string, missing []*arn.Anime, count int, pageURI string, generateSearchLink func(*arn.Anime) string) - EditorTabs(pageURI) +component AnimeEditorListFull(title string, missing []*arn.Anime, count int, pageURI string, generateSearchLink func(*arn.Anime) string, user *arn.User) + EditorTabs(pageURI, user) h1.editor-list-page-title.mountable= title .footer.editor-list-entry-count.mountable= strconv.Itoa(count) + " anime" AnimeEditorList(missing, pageURI, generateSearchLink) @@ -26,7 +26,7 @@ component AnimeEditorList(animes []*arn.Anime, pageURI string, generateSearchLin td= anime.Type td if len(anime.StartDate) >= 4 - a.ajax(href=strings.TrimPrefix(pageURI, "/_") + "/" + anime.StartDate[:4])= anime.StartDate[:4] + span= anime.StartDate[:4] if generateSearchLink != nil td diff --git a/pages/database/database.pixy b/pages/database/database.pixy deleted file mode 100644 index c3a16638..00000000 --- a/pages/database/database.pixy +++ /dev/null @@ -1,37 +0,0 @@ -component Database(url string) - EditorTabs(url) - - .widget-form - .widget - h1.mountable Database search - - .widget-section.mountable - label(for="data-type") Search - select#data-type.widget-ui-element(value="Anime") - option(value="Analytics") Analytics - option(value="Anime") Anime - option(value="AnimeList") AnimeList - option(value="Character") Character - option(value="Group") Group - option(value="Post") Post - option(value="Settings") Settings - option(value="SoundTrack") SoundTrack - option(value="Thread") Thread - option(value="User") User - option(value="Quote") Quote - - .widget-section.mountable - label(for="field") where - input#field.widget-ui-element(type="text", placeholder="Field name (e.g. Title or Title.Canonical)") - - .widget-section.mountable - label(for="field-value") is - input#field-value.widget-ui-element(type="text") - - .buttons.mountable - button.action(data-action="searchDB", data-trigger="click") - Icon("search") - span Search - - h3.text-center Results - #records \ No newline at end of file diff --git a/pages/database/database.go b/pages/editor/database/database.go similarity index 100% rename from pages/database/database.go rename to pages/editor/database/database.go diff --git a/pages/editor/database/database.pixy b/pages/editor/database/database.pixy new file mode 100644 index 00000000..67dd6f27 --- /dev/null +++ b/pages/editor/database/database.pixy @@ -0,0 +1,37 @@ +component Database(url string) + //- EditorTabs(url) + + //- .widget-form + //- .widget + //- h1.mountable Database search + + //- .widget-section.mountable + //- label(for="data-type") Search + //- select#data-type.widget-ui-element(value="Anime") + //- option(value="Analytics") Analytics + //- option(value="Anime") Anime + //- option(value="AnimeList") AnimeList + //- option(value="Character") Character + //- option(value="Group") Group + //- option(value="Post") Post + //- option(value="Settings") Settings + //- option(value="SoundTrack") SoundTrack + //- option(value="Thread") Thread + //- option(value="User") User + //- option(value="Quote") Quote + + //- .widget-section.mountable + //- label(for="field") where + //- input#field.widget-ui-element(type="text", placeholder="Field name (e.g. Title or Title.Canonical)") + + //- .widget-section.mountable + //- label(for="field-value") is + //- input#field-value.widget-ui-element(type="text") + + //- .buttons.mountable + //- button.action(data-action="searchDB", data-trigger="click") + //- Icon("search") + //- span Search + + //- h3.text-center Results + //- #records \ No newline at end of file diff --git a/pages/database/database.scarlet b/pages/editor/database/database.scarlet similarity index 100% rename from pages/database/database.scarlet rename to pages/editor/database/database.scarlet diff --git a/pages/database/select.go b/pages/editor/database/select.go similarity index 100% rename from pages/database/select.go rename to pages/editor/database/select.go diff --git a/pages/editor/editor.go b/pages/editor/editor.go index 851f0c9c..058593cc 100644 --- a/pages/editor/editor.go +++ b/pages/editor/editor.go @@ -1,6 +1,8 @@ package editor import ( + "strconv" + "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" @@ -35,5 +37,11 @@ func Get(ctx *aero.Context) string { } } - return ctx.HTML(components.Editor(ctx.URI(), score, scoreTypes, user)) + scoreTitle := "" + + for objectType, score := range scoreTypes { + scoreTitle += objectType + ": " + strconv.Itoa(score) + "\n" + } + + return ctx.HTML(components.Editor(ctx.URI(), score, scoreTitle, scoreTypes, user)) } diff --git a/pages/editor/editor.pixy b/pages/editor/editor.pixy index f3ca80c8..fa2e0264 100644 --- a/pages/editor/editor.pixy +++ b/pages/editor/editor.pixy @@ -1,46 +1,53 @@ -component Editor(url string, score int, scoreTypes map[string]int, user *arn.User) - EditorTabs(url) +component Editor(url string, score int, scoreTitle string, scoreTypes map[string]int, user *arn.User) + EditorTabs(url, user) h1.mountable= "Welcome to the Editor Panel, " + user.Nick + "!" .feature-cards - .feature-card.mountable + .feature-card.mountable(title=scoreTitle) .feature-card-icon.editor-score= score p.feature-card-text Your contribution score. - .feature-cards.feature-cards-alternative-color - for objectType, score := range scoreTypes - .feature-card.mountable - .feature-card-icon.editor-score= score - p.feature-card-text= objectType + //- .footer + //- for objectType, score := range scoreTypes + //- .mountable + //- span= objectType + ": " + //- span= score + + //- .feature-cards.feature-cards-alternative-color + //- for objectType, score := range scoreTypes + //- .feature-card.mountable + //- .feature-card-icon.editor-score= score + //- p.feature-card-text= objectType -component EditorTabs(url string) +component EditorTabs(url string, user *arn.User) .tabs Tab("Editor", "pencil", "/editor") - Tab("MAL", "exchange", "/editor/maldiff/anime") - Tab("Kitsu", "exchange", "/editor/kitsu/new/anime") - Tab("Anime", "tv", "/editor/anime/mapping/mal") + 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("Companies", "building", "/editor/companies/description") - Tab("Search", "search", "/database") - + Tab("Kitsu", "download", "/editor/kitsu/new/anime") + if strings.Contains(url, "/editor/anime/") .tabs - Tab("Mappings", "arrows-h", "/editor/anime/mapping/mal") - Tab("Synopsis", "align-left", "/editor/anime/synopsis") - Tab("Genres", "clone", "/editor/anime/genres") - Tab("Start date", "calendar", "/editor/anime/startdate") - Tab("Images", "image", "/editor/anime/image/lowres") + Tab("Mappings", "arrows-h", "/editor/anime/mapping/mal" + user.Settings().Editor.Filter.Suffix()) + Tab("Synopsis", "align-left", "/editor/anime/synopsis" + user.Settings().Editor.Filter.Suffix()) + Tab("Genres", "clone", "/editor/anime/genres" + user.Settings().Editor.Filter.Suffix()) + Tab("Start date", "calendar", "/editor/anime/startdate" + user.Settings().Editor.Filter.Suffix()) + Tab("Images", "image", "/editor/anime/image/lowres" + user.Settings().Editor.Filter.Suffix()) if strings.Contains(url, "/editor/anime/mapping/") .tabs - Tab("MAL", "arrows-h", "/editor/anime/mapping/mal") - Tab("Shoboi", "arrows-h", "/editor/anime/mapping/shoboi") - Tab("AniList", "arrows-h", "/editor/anime/mapping/anilist") + Tab("MAL", "arrows-h", "/editor/anime/mapping/mal" + user.Settings().Editor.Filter.Suffix()) + Tab("Shoboi", "arrows-h", "/editor/anime/mapping/shoboi" + user.Settings().Editor.Filter.Suffix()) + Tab("AniList", "arrows-h", "/editor/anime/mapping/anilist" + user.Settings().Editor.Filter.Suffix()) if strings.Contains(url, "/editor/anime/image/") .tabs - Tab("Low-Res", "image", "/editor/anime/image/lowres") - Tab("Ultra Low-Res", "image", "/editor/anime/image/ultralowres") - - //- a.tab.ajax(href="/admin", aria-label="Admin") - //- Icon("wrench") - //- span.tab-text Admin \ No newline at end of file + Tab("Low-Res", "image", "/editor/anime/image/lowres" + user.Settings().Editor.Filter.Suffix()) + Tab("Ultra Low-Res", "image", "/editor/anime/image/ultralowres" + user.Settings().Editor.Filter.Suffix()) + + if strings.Contains(url, "/editor/anime/") || strings.Contains(url, "/editor/mal/diff/anime") + .corner-buttons.fixed + #filter-root(data-url=url) + ExploreFilters(user.Settings().Editor.Filter.Year, user.Settings().Editor.Filter.Status, user.Settings().Editor.Filter.Type, true) + \ No newline at end of file diff --git a/pages/editor/filteranime/utils.go b/pages/editor/filteranime/utils.go index 05a91e0a..5d51f43f 100644 --- a/pages/editor/filteranime/utils.go +++ b/pages/editor/filteranime/utils.go @@ -1,39 +1,79 @@ package filteranime import ( + "net/http" + "strings" + "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" ) 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 { - animes, count := filterAnime(ctx, filter) + user := utils.GetUser(ctx) + + if user == nil || (user.Role != "admin" && user.Role != "editor") { + return ctx.Error(http.StatusUnauthorized, "Not authorized", nil) + } + + animes, count := filterAnime(ctx, user, filter) + + // Determine URL + url := strings.TrimPrefix(ctx.URI(), "/_") + urlParts := strings.Split(url, "/") + urlParts = urlParts[:len(urlParts)-3] + url = strings.Join(urlParts, "/") return ctx.HTML(components.AnimeEditorListFull( title, animes, count, - ctx.URI(), + url, searchLink, + user, )) } // filterAnime filters anime by the given filter function and // additionally applies year and types filters if specified. -func filterAnime(ctx *aero.Context, filter func(*arn.Anime) bool) ([]*arn.Anime, int) { - year, _ := ctx.GetInt("year") - animeType := ctx.Get("type") +func filterAnime(ctx *aero.Context, user *arn.User, filter func(*arn.Anime) bool) ([]*arn.Anime, int) { + year := ctx.Get("year") + status := ctx.Get("status") + typ := ctx.Get("type") + + if year == "any" { + year = "" + } + + if status == "any" { + status = "" + } + + if typ == "any" { + typ = "" + } + + settings := user.Settings() + settings.Editor.Filter.Year = year + settings.Editor.Filter.Status = status + settings.Editor.Filter.Type = typ + settings.Save() // Filter animes := arn.FilterAnime(func(anime *arn.Anime) bool { - if year != 0 && year != anime.StartDateTime().Year() { + if year != "" && (len(anime.StartDate) < 4 || anime.StartDate[:4] != year) { return false } - if animeType != "" && anime.Type != animeType { + if status != "" && anime.Status != status { + return false + } + + if typ != "" && anime.Type != typ { return false } diff --git a/pages/editor/filtercompanies/filtercompanies.go b/pages/editor/filtercompanies/filtercompanies.go index 805aaff5..dd4eb34d 100644 --- a/pages/editor/filtercompanies/filtercompanies.go +++ b/pages/editor/filtercompanies/filtercompanies.go @@ -4,12 +4,19 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" ) const maxEntries = 70 // NoDescription ... func NoDescription(ctx *aero.Context) string { + user := utils.GetUser(ctx) + + if user == nil || (user.Role != "admin" && user.Role != "editor") { + return ctx.Redirect("/") + } + companies := arn.FilterCompanies(func(company *arn.Company) bool { return !company.IsDraft && len(company.Description) < 5 }) @@ -22,5 +29,5 @@ func NoDescription(ctx *aero.Context) string { companies = companies[:maxEntries] } - return ctx.HTML(components.CompaniesEditorList(companies, count, ctx.URI())) + return ctx.HTML(components.CompaniesEditorList(companies, count, ctx.URI(), user)) } diff --git a/pages/editor/filtercompanies/filtercompanies.pixy b/pages/editor/filtercompanies/filtercompanies.pixy index 2489c8c0..af6894ee 100644 --- a/pages/editor/filtercompanies/filtercompanies.pixy +++ b/pages/editor/filtercompanies/filtercompanies.pixy @@ -1,5 +1,5 @@ -component CompaniesEditorList(companies []*arn.Company, count int, url string) - EditorTabs(url) +component CompaniesEditorList(companies []*arn.Company, count int, url string, user *arn.User) + EditorTabs(url, user) h1.editor-list-page-title.mountable Companies without a description .footer.editor-list-entry-count.mountable= strconv.Itoa(count) + " companies" diff --git a/pages/editor/kitsu.pixy b/pages/editor/kitsu.pixy index 774a1add..59c3d069 100644 --- a/pages/editor/kitsu.pixy +++ b/pages/editor/kitsu.pixy @@ -1,5 +1,5 @@ component NewKitsuAnime(animes []*kitsu.Anime, url string, user *arn.User) - EditorTabs(url) + EditorTabs(url, user) h1.mountable New anime on Kitsu if len(animes) == 0 diff --git a/pages/editor/mal.go b/pages/editor/mal.go index 96533194..bcc644e8 100644 --- a/pages/editor/mal.go +++ b/pages/editor/mal.go @@ -2,7 +2,6 @@ package editor import ( "sort" - "strconv" "github.com/animenotifier/notify.moe/utils/animediff" @@ -18,20 +17,38 @@ const maxCompareMALEntries = 15 // CompareMAL ... func CompareMAL(ctx *aero.Context) string { user := utils.GetUser(ctx) - year, _ := ctx.GetInt("year") + year := ctx.Get("year") status := ctx.Get("status") - animeType := ctx.Get("type") + typ := ctx.Get("type") + + if year == "any" { + year = "" + } + + if status == "any" { + status = "" + } + + if typ == "any" { + typ = "" + } + + settings := user.Settings() + settings.Editor.Filter.Year = year + settings.Editor.Filter.Status = status + settings.Editor.Filter.Type = typ + settings.Save() animes := arn.FilterAnime(func(anime *arn.Anime) bool { + if year != "" && (len(anime.StartDate) < 4 || anime.StartDate[:4] != year) { + return false + } + if status != "" && anime.Status != status { return false } - if year != 0 && year != anime.StartDateTime().Year() { - return false - } - - if animeType != "" && anime.Type != animeType { + if typ != "" && anime.Type != typ { return false } @@ -198,5 +215,5 @@ func CompareMAL(ctx *aero.Context) string { } } - return ctx.HTML(components.CompareMAL(comparisons, strconv.Itoa(year), status, animeType, ctx.URI(), user)) + return ctx.HTML(components.CompareMAL(comparisons, year, status, typ, "/editor/mal/diff/anime", user)) } diff --git a/pages/editor/mal.pixy b/pages/editor/mal.pixy index 9d5d3363..90e735df 100644 --- a/pages/editor/mal.pixy +++ b/pages/editor/mal.pixy @@ -1,35 +1,37 @@ component CompareMAL(comparisons []*utils.MALComparison, year string, status string, typ string, url string, user *arn.User) - EditorTabs(url) + EditorTabs(url, user) h1.mountable MAL comparison - ExploreFilters(year, status, typ, "malDiffFilterAnime") .data-comparisons - each comparison in comparisons - .data-comparison.mountable - .data-comparison-header - a.data-comparison-image-container(href=comparison.Anime.Link(), target="_blank") - img.data-comparison-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", data-color=comparison.Anime.AverageColor(), alt=comparison.Anime.Title.ByUser(user)) - - .data-comparison-title - a(href=comparison.Anime.Link(), target="_blank")= comparison.Anime.Title.Canonical - - .spacer - - a.data-comparison-tool(href=comparison.Anime.Link() + "/edit", target="_blank") - RawIcon("pencil") + if len(comparisons) == 0 + p.no-data.mountable No differences found. + else + each comparison in comparisons + .data-comparison.mountable + .data-comparison-header + a.data-comparison-image-container(href=comparison.Anime.Link(), target="_blank") + img.data-comparison-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", data-color=comparison.Anime.AverageColor(), alt=comparison.Anime.Title.ByUser(user)) - a.data-comparison-tool(href=comparison.MALAnime.URL, target="_blank") - RawIcon("external-link") + .data-comparison-title + a(href=comparison.Anime.Link(), target="_blank")= comparison.Anime.Title.Canonical - .data-comparison-differences - each difference in comparison.Differences - .data-comparison-difference - .data-comparison-difference-title - span= difference.Explanation() + .spacer - .data-comparison-difference-details - .data-comparison-difference-detail= difference.DetailsA() - .data-comparison-difference-detail= difference.DetailsB() + a.data-comparison-tool(href=comparison.Anime.Link() + "/edit", target="_blank") + RawIcon("pencil") - button.data-comparison-difference-ignore.action(data-action="newAnimeDiffIgnore", data-trigger="click", data-id=arn.CreateDifferenceID(comparison.Anime.ID, "mal", comparison.MALAnime.ID, difference.Type()), data-hash=difference.Hash()) - RawIcon("trash") + a.data-comparison-tool(href=comparison.MALAnime.URL, target="_blank") + RawIcon("external-link") + + .data-comparison-differences + each difference in comparison.Differences + .data-comparison-difference + .data-comparison-difference-title + span= difference.Explanation() + + .data-comparison-difference-details + .data-comparison-difference-detail= difference.DetailsA() + .data-comparison-difference-detail= difference.DetailsB() + + button.data-comparison-difference-ignore.action(data-action="newAnimeDiffIgnore", data-trigger="click", data-id=arn.CreateDifferenceID(comparison.Anime.ID, "mal", comparison.MALAnime.ID, difference.Type()), data-hash=difference.Hash()) + RawIcon("trash") diff --git a/pages/explore/explore.pixy b/pages/explore/explore.pixy index 390c90cd..3067c426 100644 --- a/pages/explore/explore.pixy +++ b/pages/explore/explore.pixy @@ -1,5 +1,6 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ string, user *arn.User) - ExploreFilters(year, status, typ, "filterAnime") + #filter-root(data-url="/explore/anime") + ExploreFilters(year, status, typ, false) .corner-buttons-hide-on-mobile if user != nil @@ -20,18 +21,27 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s else AnimeGrid(animeList, user) -component ExploreFilters(year string, status string, typ string, action string) +component ExploreFilters(year string, status string, typ string, allowAny bool) .explore-filters - select#filter-year.action(value=year, data-action=action, data-trigger="change") + select#filter-year.action(value=year, data-action="filterAnime", data-trigger="change") + if allowAny + option(value="") + for year := time.Now().Year()+1; year >= 1951; year-- option(value=year)= year - select#filter-status.action(value=status, data-action=action, data-trigger="change") + select#filter-status.action(value=status, data-action="filterAnime", data-trigger="change") + if allowAny + option(value="") + option(value="current") Current option(value="upcoming") Upcoming option(value="finished") Finished - select#filter-type.action(value=typ, data-action=action, data-trigger="change") + select#filter-type.action(value=typ, data-action="filterAnime", data-trigger="change") + if allowAny + option(value="") + option(value="tv") TV option(value="movie") Movie option(value="ova") OVA diff --git a/pages/index.go b/pages/index.go index 7cc16112..b58bb903 100644 --- a/pages/index.go +++ b/pages/index.go @@ -18,7 +18,6 @@ import ( "github.com/animenotifier/notify.moe/pages/companies" "github.com/animenotifier/notify.moe/pages/company" "github.com/animenotifier/notify.moe/pages/compare" - "github.com/animenotifier/notify.moe/pages/database" "github.com/animenotifier/notify.moe/pages/editanime" "github.com/animenotifier/notify.moe/pages/editlog" "github.com/animenotifier/notify.moe/pages/editor" @@ -248,27 +247,50 @@ func Configure(app *aero.Application) { // Editor l.Page("/editor", editor.Get) - // Editor - Anime - editorList := func(route string, handler func(ctx *aero.Context) string) { - l.Page(route, handler) - l.Page(route+"/:year", handler) - l.Page(route+"/:year/:type", handler) + // Editor links can be filtered by year, status and type + editorFilterable := func(route string, handler func(ctx *aero.Context) string) { + // l.Page(route, func(ctx *aero.Context) string { + // user := utils.GetUser(ctx) + + // if user == nil { + // return ctx.Error(http.StatusUnauthorized, "Not logged in", nil) + // } + + // settings := user.Settings().Editor + + // year := settings.Filter.Year + // status := settings.Filter.Status + // typ := settings.Filter.Type + + // if year == "" { + // year = "any" + // } + + // if status == "" { + // status = "any" + // } + + // if typ == "" { + // typ = "any" + // } + + // return ctx.Redirect(fmt.Sprintf("%s/%s/%s/%s", ctx.URI(), year, status, typ)) + // }) + l.Page(route+"/:year/:status/:type", handler) } - editorList("/editor/anime/synopsis", filteranime.Synopsis) - editorList("/editor/anime/genres", filteranime.Genres) - editorList("/editor/anime/startdate", filteranime.StartDate) - editorList("/editor/anime/mapping/shoboi", filteranime.Shoboi) - editorList("/editor/anime/mapping/anilist", filteranime.AniList) - editorList("/editor/anime/mapping/mal", filteranime.MAL) - editorList("/editor/anime/image/lowres", filteranime.LowResolutionAnimeImages) - editorList("/editor/anime/image/ultralowres", filteranime.UltraLowResolutionAnimeImages) + // Editor - Anime + editorFilterable("/editor/anime/synopsis", filteranime.Synopsis) + editorFilterable("/editor/anime/genres", filteranime.Genres) + editorFilterable("/editor/anime/startdate", filteranime.StartDate) + editorFilterable("/editor/anime/mapping/shoboi", filteranime.Shoboi) + editorFilterable("/editor/anime/mapping/anilist", filteranime.AniList) + editorFilterable("/editor/anime/mapping/mal", filteranime.MAL) + editorFilterable("/editor/anime/image/lowres", filteranime.LowResolutionAnimeImages) + editorFilterable("/editor/anime/image/ultralowres", filteranime.UltraLowResolutionAnimeImages) // Editor - MALdiff - l.Page("/editor/maldiff/anime", editor.CompareMAL) - l.Page("/editor/maldiff/anime/:year", editor.CompareMAL) - l.Page("/editor/maldiff/anime/:year/:status", editor.CompareMAL) - l.Page("/editor/maldiff/anime/:year/:status/:type", editor.CompareMAL) + editorFilterable("/editor/mal/diff/anime", editor.CompareMAL) // Editor - Kitsu l.Page("/editor/kitsu/new/anime", editor.NewKitsuAnime) @@ -280,8 +302,8 @@ func Configure(app *aero.Application) { l.Page("/log", editlog.Get) // Mixed - l.Page("/database", database.Get) - app.Get("/api/select/:data-type/where/:field/is/:field-value", database.Select) + // l.Page("/database", database.Get) + // app.Get("/api/select/:data-type/where/:field/is/:field-value", database.Select) // Import l.Page("/import", listimport.Get) diff --git a/scripts/Actions/Editor.ts b/scripts/Actions/Editor.ts index 195b237d..f40455c9 100644 --- a/scripts/Actions/Editor.ts +++ b/scripts/Actions/Editor.ts @@ -19,15 +19,6 @@ export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement .catch(err => arn.statusMessage.showError(err)) } -// Filter anime on maldiff page -export function malDiffFilterAnime(arn: AnimeNotifier, input: HTMLInputElement) { - let year = arn.app.find("filter-year") as HTMLSelectElement - let status = arn.app.find("filter-status") as HTMLSelectElement - let type = arn.app.find("filter-type") as HTMLSelectElement - - arn.app.load(`/editor/anime/maldiff/${year.value}/${status.value}/${type.value}`) -} - // Import Kitsu anime export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) { let newTab = window.open() diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index 3c4ebb5f..477289de 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -3,9 +3,11 @@ import { findAll } from "scripts/Utils"; // Filter anime on explore page export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { - let year = arn.app.find("filter-year") as HTMLSelectElement - let status = arn.app.find("filter-status") as HTMLSelectElement - let type = arn.app.find("filter-type") as HTMLSelectElement + let root = arn.app.find("filter-root") + + let elementYear = arn.app.find("filter-year") as HTMLSelectElement + let elementStatus = arn.app.find("filter-status") as HTMLSelectElement + let elementType = arn.app.find("filter-type") as HTMLSelectElement for(let element of findAll("anime-grid-image")) { let img = element as HTMLImageElement @@ -14,7 +16,11 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { img.classList.remove("element-color-preview") } - arn.diff(`/explore/anime/${year.value}/${status.value}/${type.value}`) + let year = elementYear.value || "any" + let status = elementStatus.value || "any" + let type = elementType.value || "any" + + arn.diff(`${root.dataset.url}/${year}/${status}/${type}`) } // Hides anime that are already in your list. diff --git a/styles/corner-buttons.scarlet b/styles/corner-buttons.scarlet index 80fd270b..7cd88262 100644 --- a/styles/corner-buttons.scarlet +++ b/styles/corner-buttons.scarlet @@ -19,6 +19,9 @@ .button margin-left 0.5rem +.fixed + position fixed + < 600px .corner-buttons-hide-on-mobile display none diff --git a/tests.go b/tests.go index 9a5364a8..d1076e9a 100644 --- a/tests.go +++ b/tests.go @@ -291,6 +291,11 @@ var routeTests = map[string][]string{ "/import/myanimelist/animelist/finish": nil, "/import/kitsu/animelist": nil, "/import/kitsu/animelist/finish": nil, + "/animelist/watching": nil, + "/animelist/completed": nil, + "/animelist/planned": nil, + "/animelist/hold": nil, + "/animelist/dropped": nil, "/notifications": nil, "/user/:nick/notifications": nil, "/api/test/notification": nil, @@ -301,6 +306,7 @@ var routeTests = map[string][]string{ "/api/pushsubscriptions/:id/get/:item/:property": nil, "/api/count/notifications/unseen": nil, "/api/mark/notifications/seen": nil, + "/editor/kitsu/new/anime": nil, "/paypal/success": nil, "/paypal/cancel": nil, "/anime/:id/edit": nil,