Added AMV search
This commit is contained in:
parent
dc04601072
commit
9e3ec7656d
@ -16,6 +16,7 @@ func Register(l *layout.Layout) {
|
|||||||
l.Page("/forum-search/*term", search.Forum)
|
l.Page("/forum-search/*term", search.Forum)
|
||||||
l.Page("/soundtrack-search/*term", search.SoundTracks)
|
l.Page("/soundtrack-search/*term", search.SoundTracks)
|
||||||
l.Page("/user-search/*term", search.Users)
|
l.Page("/user-search/*term", search.Users)
|
||||||
|
l.Page("/amv-search/*term", search.AMVs)
|
||||||
l.Page("/company-search/*term", search.Companies)
|
l.Page("/company-search/*term", search.Companies)
|
||||||
|
|
||||||
// Multi-search
|
// Multi-search
|
||||||
|
@ -19,6 +19,7 @@ const (
|
|||||||
maxPosts = 2
|
maxPosts = 2
|
||||||
maxThreads = 2
|
maxThreads = 2
|
||||||
maxSoundTracks = 3
|
maxSoundTracks = 3
|
||||||
|
maxAMVs = 3
|
||||||
maxCharacters = 22
|
maxCharacters = 22
|
||||||
maxCompanies = 3
|
maxCompanies = 3
|
||||||
)
|
)
|
||||||
@ -29,7 +30,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
term = strings.TrimPrefix(term, "/")
|
term = strings.TrimPrefix(term, "/")
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
users, animes, posts, threads, tracks, characters, companies := search.All(
|
users, animes, posts, threads, tracks, characters, amvs, companies := search.All(
|
||||||
term,
|
term,
|
||||||
maxUsers,
|
maxUsers,
|
||||||
maxAnime,
|
maxAnime,
|
||||||
@ -37,15 +38,16 @@ func Get(ctx *aero.Context) string {
|
|||||||
maxThreads,
|
maxThreads,
|
||||||
maxSoundTracks,
|
maxSoundTracks,
|
||||||
maxCharacters,
|
maxCharacters,
|
||||||
|
maxAMVs,
|
||||||
maxCompanies,
|
maxCompanies,
|
||||||
)
|
)
|
||||||
|
|
||||||
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters, companies, nil, user))
|
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters, amvs, companies, nil, user))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEmptySearch renders the search page with no contents.
|
// GetEmptySearch renders the search page with no contents.
|
||||||
func GetEmptySearch(ctx *aero.Context) string {
|
func GetEmptySearch(ctx *aero.Context) string {
|
||||||
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, utils.GetUser(ctx)))
|
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, nil, utils.GetUser(ctx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anime search.
|
// Anime search.
|
||||||
@ -96,6 +98,16 @@ func SoundTracks(ctx *aero.Context) string {
|
|||||||
return ctx.HTML(components.SoundTrackSearchResults(tracks, user))
|
return ctx.HTML(components.SoundTrackSearchResults(tracks, user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AMVs search.
|
||||||
|
func AMVs(ctx *aero.Context) string {
|
||||||
|
term := ctx.Get("term")
|
||||||
|
term = strings.TrimPrefix(term, "/")
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
amvs := search.AMVs(term, maxAMVs)
|
||||||
|
return ctx.HTML(components.AMVSearchResults(amvs, user))
|
||||||
|
}
|
||||||
|
|
||||||
// Users search.
|
// Users search.
|
||||||
func Users(ctx *aero.Context) string {
|
func Users(ctx *aero.Context) string {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
|
@ -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, companies []*arn.Company, quotes []*arn.Quote, user *arn.User)
|
component SearchResults(term string, users []*arn.User, animes []*arn.Anime, posts []*arn.Post, threads []*arn.Thread, tracks []*arn.SoundTrack, characters []*arn.Character, amvs []*arn.AMV, companies []*arn.Company, quotes []*arn.Quote, user *arn.User)
|
||||||
h1.page-title= "Search: " + term
|
h1.page-title= "Search: " + term
|
||||||
|
|
||||||
.search
|
.search
|
||||||
@ -34,6 +34,14 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
|
|||||||
#soundtrack-search-results
|
#soundtrack-search-results
|
||||||
SoundTrackSearchResults(tracks, user)
|
SoundTrackSearchResults(tracks, user)
|
||||||
|
|
||||||
|
.widget
|
||||||
|
h3.widget-title
|
||||||
|
Icon("video-camera")
|
||||||
|
span AMVs
|
||||||
|
|
||||||
|
#amv-search-results
|
||||||
|
AMVSearchResults(amvs, user)
|
||||||
|
|
||||||
//- .widget
|
//- .widget
|
||||||
//- h3.widget-title
|
//- h3.widget-title
|
||||||
//- Icon("quote-left")
|
//- Icon("quote-left")
|
||||||
@ -107,6 +115,20 @@ component SoundTrackSearchResults(tracks []*arn.SoundTrack, user *arn.User)
|
|||||||
a(href=track.Link())= track.Title.ByUser(user)
|
a(href=track.Link())= track.Title.ByUser(user)
|
||||||
span.soundtrack-search-anime= " - " + track.MainAnime().Title.Canonical
|
span.soundtrack-search-anime= " - " + track.MainAnime().Title.Canonical
|
||||||
|
|
||||||
|
component AMVSearchResults(amvs []*arn.AMV, user *arn.User)
|
||||||
|
if len(amvs) == 0
|
||||||
|
p.no-search-results.mountable No AMVs found.
|
||||||
|
else
|
||||||
|
ul.amv-search
|
||||||
|
each amv in amvs
|
||||||
|
li.mountable(data-mountable-type="amv")
|
||||||
|
a(href=amv.Link())= amv.Title.ByUser(user)
|
||||||
|
|
||||||
|
if amv.MainAnime() != nil
|
||||||
|
span.amv-search-anime= " - " + amv.MainAnime().Title.Canonical
|
||||||
|
else
|
||||||
|
span.amv-search-anime= fmt.Sprintf(" - %d anime", len(amv.ExtraAnimeIDs))
|
||||||
|
|
||||||
component CompanySearchResults(companies []*arn.Company)
|
component CompanySearchResults(companies []*arn.Company)
|
||||||
if len(companies) == 0
|
if len(companies) == 0
|
||||||
p.no-search-results.mountable No companies found.
|
p.no-search-results.mountable No companies found.
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
margin-bottom 1rem
|
margin-bottom 1rem
|
||||||
opacity 0.8
|
opacity 0.8
|
||||||
|
|
||||||
.soundtrack-search-anime
|
.soundtrack-search-anime,
|
||||||
|
.amv-search-anime
|
||||||
opacity 0.35
|
opacity 0.35
|
||||||
|
|
||||||
.no-search-results
|
.no-search-results
|
||||||
|
@ -11,6 +11,7 @@ var correctResponseRendered = {
|
|||||||
"forum": false,
|
"forum": false,
|
||||||
"soundtrack": false,
|
"soundtrack": false,
|
||||||
"user": false,
|
"user": false,
|
||||||
|
"amv": false,
|
||||||
"company": false
|
"company": false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ var characterSearchResults: HTMLElement
|
|||||||
var forumSearchResults: HTMLElement
|
var forumSearchResults: HTMLElement
|
||||||
var soundtrackSearchResults: HTMLElement
|
var soundtrackSearchResults: HTMLElement
|
||||||
var userSearchResults: HTMLElement
|
var userSearchResults: HTMLElement
|
||||||
|
var amvSearchResults: HTMLElement
|
||||||
var companySearchResults: HTMLElement
|
var companySearchResults: HTMLElement
|
||||||
|
|
||||||
// Delay before a request is sent
|
// Delay before a request is sent
|
||||||
@ -60,6 +62,7 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?:
|
|||||||
correctResponseRendered.forum = false
|
correctResponseRendered.forum = false
|
||||||
correctResponseRendered.soundtrack = false
|
correctResponseRendered.soundtrack = false
|
||||||
correctResponseRendered.user = false
|
correctResponseRendered.user = false
|
||||||
|
correctResponseRendered.amv = false
|
||||||
correctResponseRendered.company = false
|
correctResponseRendered.company = false
|
||||||
|
|
||||||
// Set browser URL
|
// Set browser URL
|
||||||
@ -108,6 +111,7 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?:
|
|||||||
forumSearchResults = document.getElementById("forum-search-results")
|
forumSearchResults = document.getElementById("forum-search-results")
|
||||||
soundtrackSearchResults = document.getElementById("soundtrack-search-results")
|
soundtrackSearchResults = document.getElementById("soundtrack-search-results")
|
||||||
userSearchResults = document.getElementById("user-search-results")
|
userSearchResults = document.getElementById("user-search-results")
|
||||||
|
amvSearchResults = document.getElementById("amv-search-results")
|
||||||
companySearchResults = document.getElementById("company-search-results")
|
companySearchResults = document.getElementById("company-search-results")
|
||||||
searchPageTitle = document.getElementsByTagName("h1")[0]
|
searchPageTitle = document.getElementsByTagName("h1")[0]
|
||||||
}
|
}
|
||||||
@ -147,6 +151,10 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?:
|
|||||||
.then(showResponseInElement(arn, url, "user", userSearchResults))
|
.then(showResponseInElement(arn, url, "user", userSearchResults))
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
|
||||||
|
fetch("/_/amv-search/" + term, fetchOptions)
|
||||||
|
.then(showResponseInElement(arn, url, "amv", amvSearchResults))
|
||||||
|
.catch(console.error)
|
||||||
|
|
||||||
fetch("/_/company-search/" + term, fetchOptions)
|
fetch("/_/company-search/" + term, fetchOptions)
|
||||||
.then(showResponseInElement(arn, url, "company", companySearchResults))
|
.then(showResponseInElement(arn, url, "company", companySearchResults))
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
Loading…
Reference in New Issue
Block a user