Added company search
This commit is contained in:
parent
4da0e19443
commit
ab9d18cdbc
@ -2,8 +2,9 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s
|
||||
ExploreFilters(year, status, typ, "filterAnime")
|
||||
|
||||
.corner-buttons-hide-on-mobile
|
||||
button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection")
|
||||
RawIcon("eye-slash")
|
||||
if user != nil
|
||||
button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection")
|
||||
RawIcon("eye-slash")
|
||||
|
||||
a.button.ajax(href="/genres", title="View genres")
|
||||
RawIcon("clone")
|
||||
|
@ -2,8 +2,9 @@ component Genre(genre string, animes []*arn.Anime, user *arn.User)
|
||||
h1(title=toString(len(animes)) + " anime")= strings.Title(genre)
|
||||
|
||||
.corner-buttons-hide-on-mobile
|
||||
button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection")
|
||||
RawIcon("eye-slash")
|
||||
if user != nil
|
||||
button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection")
|
||||
RawIcon("eye-slash")
|
||||
|
||||
a.button.ajax(href="/genres", title="View genres")
|
||||
RawIcon("clone")
|
||||
|
@ -211,6 +211,7 @@ func Configure(app *aero.Application) {
|
||||
l.Page("/forum-search/*term", search.Forum)
|
||||
l.Page("/soundtrack-search/*term", search.SoundTracks)
|
||||
l.Page("/user-search/*term", search.Users)
|
||||
l.Page("/company-search/*term", search.Companies)
|
||||
|
||||
// Shop
|
||||
l.Page("/support", support.Get)
|
||||
|
@ -10,25 +10,38 @@ import (
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
const maxUsers = 25
|
||||
const maxAnime = 25
|
||||
const maxPosts = 2
|
||||
const maxThreads = 2
|
||||
const maxSoundTracks = 4
|
||||
const maxCharacters = 22
|
||||
const (
|
||||
maxUsers = 25
|
||||
maxAnime = 25
|
||||
maxPosts = 2
|
||||
maxThreads = 2
|
||||
maxSoundTracks = 3
|
||||
maxCharacters = 22
|
||||
maxCompanies = 3
|
||||
)
|
||||
|
||||
// Get search page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
term := ctx.Get("term")
|
||||
term = strings.TrimPrefix(term, "/")
|
||||
|
||||
users, animes, posts, threads, tracks, characters := arn.Search(term, maxUsers, maxAnime, maxPosts, maxThreads, maxSoundTracks, maxCharacters)
|
||||
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters))
|
||||
users, animes, posts, threads, tracks, characters, companies := arn.Search(
|
||||
term,
|
||||
maxUsers,
|
||||
maxAnime,
|
||||
maxPosts,
|
||||
maxThreads,
|
||||
maxSoundTracks,
|
||||
maxCharacters,
|
||||
maxCompanies,
|
||||
)
|
||||
|
||||
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters, companies, nil))
|
||||
}
|
||||
|
||||
// GetEmptySearch renders the search page with no contents.
|
||||
func GetEmptySearch(ctx *aero.Context) string {
|
||||
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil))
|
||||
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil))
|
||||
}
|
||||
|
||||
// Anime search.
|
||||
@ -83,3 +96,12 @@ func Users(ctx *aero.Context) string {
|
||||
users := arn.SearchUsers(term, maxUsers)
|
||||
return ctx.HTML(components.UserSearchResults(users))
|
||||
}
|
||||
|
||||
// Companies search.
|
||||
func Companies(ctx *aero.Context) string {
|
||||
term := ctx.Get("term")
|
||||
term = strings.TrimPrefix(term, "/")
|
||||
|
||||
companies := arn.SearchCompanies(term, maxCompanies)
|
||||
return ctx.HTML(components.CompanySearchResults(companies))
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
component SearchResults(term string, users []*arn.User, animes []*arn.Anime, posts []*arn.Post, threads []*arn.Thread, tracks []*arn.SoundTrack, characters []*arn.Character)
|
||||
component SearchResults(term string, users []*arn.User, animes []*arn.Anime, posts []*arn.Post, threads []*arn.Thread, tracks []*arn.SoundTrack, characters []*arn.Character, companies []*arn.Company, quotes []*arn.Quote)
|
||||
h1.page-title= "Search: " + term
|
||||
|
||||
.search
|
||||
@ -33,6 +33,22 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
|
||||
|
||||
#soundtrack-search-results
|
||||
SoundTrackSearchResults(tracks)
|
||||
|
||||
//- .widget
|
||||
//- h3.widget-title
|
||||
//- Icon("quote-left")
|
||||
//- span Quotes
|
||||
|
||||
//- #quote-search-results
|
||||
//- QuoteSearchResults(quotes)
|
||||
|
||||
.widget
|
||||
h3.widget-title
|
||||
Icon("building")
|
||||
span Companies
|
||||
|
||||
#company-search-results
|
||||
CompanySearchResults(companies)
|
||||
|
||||
.widget
|
||||
h3.widget-title
|
||||
@ -89,6 +105,25 @@ component SoundTrackSearchResults(tracks []*arn.SoundTrack)
|
||||
each track in tracks
|
||||
li.mountable(data-mountable-type="track")
|
||||
a.ajax(href=track.Link())= track.Title
|
||||
span.soundtrack-search-anime= " - " + track.MainAnime().Title.Canonical
|
||||
|
||||
component CompanySearchResults(companies []*arn.Company)
|
||||
if len(companies) == 0
|
||||
p.no-search-results.mountable No companies found.
|
||||
else
|
||||
ul.company-search
|
||||
each company in companies
|
||||
li.mountable(data-mountable-type="company")
|
||||
a.ajax(href=company.Link())= company.Name.English
|
||||
|
||||
component QuoteSearchResults(quotes []*arn.Quote)
|
||||
if len(quotes) == 0
|
||||
p.no-search-results.mountable No quotes found.
|
||||
else
|
||||
ul.quote-search
|
||||
each quote in quotes
|
||||
li.mountable(data-mountable-type="quote")
|
||||
a.ajax(href=quote.Link())= quote.Text.English
|
||||
|
||||
component UserSearchResults(users []*arn.User)
|
||||
if len(users) == 0
|
||||
|
@ -37,6 +37,9 @@
|
||||
margin-bottom 1rem
|
||||
opacity 0.8
|
||||
|
||||
.soundtrack-search-anime
|
||||
opacity 0.35
|
||||
|
||||
.no-search-results
|
||||
text-align left
|
||||
padding-bottom typography-margin
|
@ -8,7 +8,8 @@ var correctResponseRendered = {
|
||||
"character": false,
|
||||
"forum": false,
|
||||
"soundtrack": false,
|
||||
"user": false
|
||||
"user": false,
|
||||
"company": false
|
||||
}
|
||||
|
||||
// Containers for all the search results
|
||||
@ -17,6 +18,7 @@ var characterSearchResults: HTMLElement
|
||||
var forumSearchResults: HTMLElement
|
||||
var soundtrackSearchResults: HTMLElement
|
||||
var userSearchResults: HTMLElement
|
||||
var companySearchResults: HTMLElement
|
||||
|
||||
// Search
|
||||
export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: KeyboardEvent) {
|
||||
@ -68,6 +70,7 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: Ke
|
||||
forumSearchResults = document.getElementById("forum-search-results")
|
||||
soundtrackSearchResults = document.getElementById("soundtrack-search-results")
|
||||
userSearchResults = document.getElementById("user-search-results")
|
||||
companySearchResults = document.getElementById("company-search-results")
|
||||
}
|
||||
|
||||
if(!term || term.length < 1) {
|
||||
@ -100,6 +103,10 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: Ke
|
||||
fetch("/_/user-search/" + term, fetchOptions)
|
||||
.then(showResponseInElement(arn, url, "user", userSearchResults))
|
||||
.catch(console.error)
|
||||
|
||||
fetch("/_/company-search/" + term, fetchOptions)
|
||||
.then(showResponseInElement(arn, url, "company", companySearchResults))
|
||||
.catch(console.error)
|
||||
} catch(err) {
|
||||
console.error(err)
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user