From a5fbd84b090610564dc2611355ce67b272f7546f Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 19 Mar 2018 22:28:44 +0100 Subject: [PATCH] Added view for companies without description --- pages/editor/editor.pixy | 3 ++- .../editor/filtercompanies/filtercompanies.go | 26 +++++++++++++++++++ .../filtercompanies/filtercompanies.pixy | 17 ++++++++++++ pages/index.go | 6 +++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 pages/editor/filtercompanies/filtercompanies.go create mode 100644 pages/editor/filtercompanies/filtercompanies.pixy diff --git a/pages/editor/editor.pixy b/pages/editor/editor.pixy index de5bb054..35e87d2e 100644 --- a/pages/editor/editor.pixy +++ b/pages/editor/editor.pixy @@ -13,7 +13,8 @@ component EditorTabs(url string) Tab("Editor", "pencil", "/editor") Tab("MAL", "exchange", "/editor/anime/maldiff") Tab("Kitsu", "exchange", "/editor/anime/kitsu/new") - Tab("Missing", "list", "/editor/anime/missing/shoboi") + Tab("Anime", "tv", "/editor/anime/missing/shoboi") + Tab("Companies", "building", "/editor/companies/missing/description") Tab("Search", "search", "/database") if strings.Contains(url, "/editor/anime/missing/") diff --git a/pages/editor/filtercompanies/filtercompanies.go b/pages/editor/filtercompanies/filtercompanies.go new file mode 100644 index 00000000..805aaff5 --- /dev/null +++ b/pages/editor/filtercompanies/filtercompanies.go @@ -0,0 +1,26 @@ +package filtercompanies + +import ( + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" +) + +const maxEntries = 70 + +// NoDescription ... +func NoDescription(ctx *aero.Context) string { + companies := arn.FilterCompanies(func(company *arn.Company) bool { + return !company.IsDraft && len(company.Description) < 5 + }) + + arn.SortCompaniesPopularFirst(companies) + + count := len(companies) + + if count > maxEntries { + companies = companies[:maxEntries] + } + + return ctx.HTML(components.CompaniesEditorList(companies, count, ctx.URI())) +} diff --git a/pages/editor/filtercompanies/filtercompanies.pixy b/pages/editor/filtercompanies/filtercompanies.pixy new file mode 100644 index 00000000..b1f455d1 --- /dev/null +++ b/pages/editor/filtercompanies/filtercompanies.pixy @@ -0,0 +1,17 @@ +component CompaniesEditorList(companies []*arn.Company, count int, url string) + EditorTabs(url) + h1.editor-list-title.mountable Companies without a description + .footer.editor-list-entry-count.mountable= strconv.Itoa(count) + " companies" + + table + thead + tr.mountable + th Name + th Search + tbody + each company in companies + tr.mountable + td + a(href=company.Link(), target="_blank", rel="noopener")= company.Name.English + td + a(href="https://en.wikipedia.org/w/index.php?search=" + company.Name.English, target="_blank", rel="noopener") 🔍 \ No newline at end of file diff --git a/pages/index.go b/pages/index.go index 99f1bd03..8bf20439 100644 --- a/pages/index.go +++ b/pages/index.go @@ -22,6 +22,7 @@ import ( "github.com/animenotifier/notify.moe/pages/editanime" "github.com/animenotifier/notify.moe/pages/editlog" "github.com/animenotifier/notify.moe/pages/editor" + "github.com/animenotifier/notify.moe/pages/editor/filtercompanies" "github.com/animenotifier/notify.moe/pages/embed" "github.com/animenotifier/notify.moe/pages/episode" "github.com/animenotifier/notify.moe/pages/explore" @@ -242,6 +243,8 @@ func Configure(app *aero.Application) { // Editor l.Page("/editor", editor.Get) + + // Editor - Anime l.Page("/editor/anime/missing/anilist", editor.AniList) l.Page("/editor/anime/missing/anilist/:year", editor.AniList) l.Page("/editor/anime/missing/anilist/:year/:type", editor.AniList) @@ -257,6 +260,9 @@ func Configure(app *aero.Application) { l.Page("/editor/anime/maldiff/:year/:status/:type", editor.CompareMAL) l.Page("/editor/anime/kitsu/new", editor.NewKitsuAnime) + // Editor - Companies + l.Page("/editor/companies/missing/description", filtercompanies.NoDescription) + // Log l.Page("/log", editlog.Get)