Prepare to use user language when displaying characters
This commit is contained in:
parent
bec7ff76e7
commit
e8c66f28ab
@ -1,34 +1,34 @@
|
|||||||
component Quote(quote *arn.Quote)
|
component Quote(quote *arn.Quote, user *arn.User)
|
||||||
.quote.mountable
|
.quote.mountable
|
||||||
QuoteContent(quote)
|
QuoteContent(quote, user)
|
||||||
QuoteFooter(quote)
|
QuoteFooter(quote)
|
||||||
|
|
||||||
component QuotePreview(quote *arn.Quote)
|
component QuotePreview(quote *arn.Quote, user *arn.User)
|
||||||
.quote.mountable
|
.quote.mountable
|
||||||
QuoteContentPreview(quote)
|
QuoteContentPreview(quote, user)
|
||||||
QuoteFooter(quote)
|
QuoteFooter(quote)
|
||||||
|
|
||||||
component QuoteContent(quote *arn.Quote)
|
component QuoteContent(quote *arn.Quote, user *arn.User)
|
||||||
.quote-content
|
.quote-content
|
||||||
a.quotation(href=quote.Link())
|
a.quotation(href=quote.Link())
|
||||||
QuoteText(quote)
|
QuoteText(quote)
|
||||||
|
|
||||||
QuoteCharacter(quote)
|
QuoteCharacter(quote, user)
|
||||||
|
|
||||||
component QuoteContentPreview(quote *arn.Quote)
|
component QuoteContentPreview(quote *arn.Quote, user *arn.User)
|
||||||
.quote-content
|
.quote-content
|
||||||
a.quotation(href=quote.Link())
|
a.quotation(href=quote.Link())
|
||||||
QuoteTextPreview(quote)
|
QuoteTextPreview(quote)
|
||||||
|
|
||||||
QuoteCharacter(quote)
|
QuoteCharacter(quote, user)
|
||||||
|
|
||||||
component QuoteText(quote *arn.Quote)
|
component QuoteText(quote *arn.Quote)
|
||||||
blockquote!= utils.RenderQuoteText(quote.Text.English)
|
blockquote!= utils.RenderQuoteText(quote.Text.English)
|
||||||
|
|
||||||
component QuoteCharacter(quote *arn.Quote)
|
component QuoteCharacter(quote *arn.Quote, user *arn.User)
|
||||||
if quote.CharacterID != "" && quote.Character() != nil
|
if quote.CharacterID != "" && quote.Character() != nil
|
||||||
footer.quote-character
|
footer.quote-character
|
||||||
CharacterSmall(quote.Character())
|
CharacterSmall(quote.Character(), user)
|
||||||
|
|
||||||
component QuoteTextPreview(quote *arn.Quote)
|
component QuoteTextPreview(quote *arn.Quote)
|
||||||
if len(quote.Text.English) > 170
|
if len(quote.Text.English) > 170
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
component Character(character *arn.Character)
|
component Character(character *arn.Character, user *arn.User)
|
||||||
a.character(href="/character/" + character.ID)
|
a.character(href="/character/" + character.ID)
|
||||||
img.character-image-medium.lazy(data-src=character.ImageLink("medium"), data-webp="true", data-color=character.AverageColor(), alt=character.Name.Canonical)
|
img.character-image-medium.lazy(data-src=character.ImageLink("medium"), data-webp="true", data-color=character.AverageColor(), alt=character.Name.Canonical)
|
||||||
.image-title
|
.image-title
|
||||||
.image-title-text= character.Name.Canonical
|
.image-title-text= character.Name.Canonical
|
||||||
|
|
||||||
component CharacterSmall(character *arn.Character)
|
component CharacterSmall(character *arn.Character, user *arn.User)
|
||||||
a.character.tip(href="/character/" + character.ID, aria-label=character.Name.Canonical)
|
a.character.tip(href="/character/" + character.ID, aria-label=character.Name.Canonical)
|
||||||
img.character-image-small.lazy(data-src=character.ImageLink("small"), data-webp="true", data-color=character.AverageColor(), alt=character.Name.Canonical)
|
img.character-image-small.lazy(data-src=character.ImageLink("small"), data-webp="true", data-color=character.AverageColor(), alt=character.Name.Canonical)
|
@ -12,4 +12,4 @@ component AnimeCharacters(anime *arn.Anime, user *arn.User, standAlonePage bool)
|
|||||||
each character in anime.Characters().Items
|
each character in anime.Characters().Items
|
||||||
if (character.Role == "main" || standAlonePage) && character.Character() != nil
|
if (character.Role == "main" || standAlonePage) && character.Character() != nil
|
||||||
.mountable(data-mountable-type="character")
|
.mountable(data-mountable-type="character")
|
||||||
Character(character.Character())
|
Character(character.Character(), user)
|
@ -28,7 +28,7 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
|
|||||||
|
|
||||||
if mainQuote != nil
|
if mainQuote != nil
|
||||||
.character-quote
|
.character-quote
|
||||||
Quote(mainQuote)
|
Quote(mainQuote, user)
|
||||||
|
|
||||||
.character-description.mountable!= markdown.Render(character.Description)
|
.character-description.mountable!= markdown.Render(character.Description)
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
|
|||||||
each quote in quotes
|
each quote in quotes
|
||||||
if mainQuote == nil || quote.ID != mainQuote.ID
|
if mainQuote == nil || quote.ID != mainQuote.ID
|
||||||
.character-quote
|
.character-quote
|
||||||
Quote(quote)
|
Quote(quote, user)
|
||||||
|
|
||||||
.character-sidebar
|
.character-sidebar
|
||||||
if len(character.Attributes) > 0
|
if len(character.Attributes) > 0
|
||||||
|
32
pages/characters/characters.pixy
Normal file
32
pages/characters/characters.pixy
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
component Characters(characters []*arn.Character, nextIndex int, tag string, user *arn.User)
|
||||||
|
h1.page-title Characters
|
||||||
|
|
||||||
|
CharactersTabs(tag)
|
||||||
|
|
||||||
|
.corner-buttons
|
||||||
|
if user != nil
|
||||||
|
if user.DraftIndex().CharacterID == ""
|
||||||
|
button.action(data-action="newObject", data-trigger="click", data-type="character")
|
||||||
|
Icon("plus")
|
||||||
|
span Add Character
|
||||||
|
else
|
||||||
|
a.button(href="/character/" + user.DraftIndex().CharacterID + "/edit")
|
||||||
|
Icon("pencil")
|
||||||
|
span Edit draft
|
||||||
|
|
||||||
|
//- #load-more-target.characters.characters-page
|
||||||
|
//- CharactersScrollable(characters, user)
|
||||||
|
|
||||||
|
//- if nextIndex != -1
|
||||||
|
//- .buttons
|
||||||
|
//- LoadMore(nextIndex)
|
||||||
|
|
||||||
|
component CharactersScrollable(characters []*arn.Character, user *arn.User)
|
||||||
|
each character in characters
|
||||||
|
Character(character, user)
|
||||||
|
|
||||||
|
component CharactersTabs(tag string)
|
||||||
|
//- .tab-groups
|
||||||
|
//- .tabs
|
||||||
|
//- Tab("Latest", "video-camera", "/characters")
|
||||||
|
//- Tab("Best", "heart", "/characters/best")
|
@ -7,5 +7,5 @@ component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, use
|
|||||||
.characters.profile-characters
|
.characters.profile-characters
|
||||||
each character in characters
|
each character in characters
|
||||||
.mountable
|
.mountable
|
||||||
Character(character)
|
Character(character, user)
|
||||||
|
|
@ -9,7 +9,7 @@ component QuotePage(quote *arn.Quote, character *arn.Character, user *arn.User)
|
|||||||
|
|
||||||
component QuoteMainColumn(quote *arn.Quote, user *arn.User)
|
component QuoteMainColumn(quote *arn.Quote, user *arn.User)
|
||||||
.widget-form.mountable
|
.widget-form.mountable
|
||||||
QuoteContent(quote)
|
QuoteContent(quote, user)
|
||||||
|
|
||||||
.footer.mountable
|
.footer.mountable
|
||||||
if quote.EditedBy != ""
|
if quote.EditedBy != ""
|
||||||
|
@ -23,7 +23,7 @@ component Quotes(quotes []*arn.Quote, nextIndex int, user *arn.User)
|
|||||||
|
|
||||||
component QuotesScrollable(quotes []*arn.Quote, user *arn.User)
|
component QuotesScrollable(quotes []*arn.Quote, user *arn.User)
|
||||||
each quote in quotes
|
each quote in quotes
|
||||||
QuotePreview(quote)
|
QuotePreview(quote, user)
|
||||||
|
|
||||||
component QuotesTabs
|
component QuotesTabs
|
||||||
.tabs
|
.tabs
|
||||||
|
@ -3,6 +3,8 @@ package search
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
|
||||||
"github.com/aerogo/flow"
|
"github.com/aerogo/flow"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
@ -25,6 +27,7 @@ const (
|
|||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
term = strings.TrimPrefix(term, "/")
|
term = strings.TrimPrefix(term, "/")
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
users, animes, posts, threads, tracks, characters, companies := search.All(
|
users, animes, posts, threads, tracks, characters, companies := search.All(
|
||||||
term,
|
term,
|
||||||
@ -37,12 +40,12 @@ func Get(ctx *aero.Context) string {
|
|||||||
maxCompanies,
|
maxCompanies,
|
||||||
)
|
)
|
||||||
|
|
||||||
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters, companies, nil))
|
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters, 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))
|
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, utils.GetUser(ctx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anime search.
|
// Anime search.
|
||||||
@ -58,9 +61,10 @@ func Anime(ctx *aero.Context) string {
|
|||||||
func Characters(ctx *aero.Context) string {
|
func Characters(ctx *aero.Context) string {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
term = strings.TrimPrefix(term, "/")
|
term = strings.TrimPrefix(term, "/")
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
characters := search.Characters(term, maxCharacters)
|
characters := search.Characters(term, maxCharacters)
|
||||||
return ctx.HTML(components.CharacterSearchResults(characters))
|
return ctx.HTML(components.CharacterSearchResults(characters, user))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forum search.
|
// Forum search.
|
||||||
|
@ -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)
|
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)
|
||||||
h1.page-title= "Search: " + term
|
h1.page-title= "Search: " + term
|
||||||
|
|
||||||
.search
|
.search
|
||||||
@ -16,7 +16,7 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
|
|||||||
span Characters
|
span Characters
|
||||||
|
|
||||||
#character-search-results
|
#character-search-results
|
||||||
CharacterSearchResults(characters)
|
CharacterSearchResults(characters, user)
|
||||||
|
|
||||||
.widget
|
.widget
|
||||||
h3.widget-title
|
h3.widget-title
|
||||||
@ -67,14 +67,14 @@ component AnimeSearchResults(animes []*arn.Anime)
|
|||||||
a.profile-watching-list-item.tip.mountable(href=anime.Link(), aria-label=anime.Title.Canonical, data-mountable-type="anime")
|
a.profile-watching-list-item.tip.mountable(href=anime.Link(), aria-label=anime.Title.Canonical, data-mountable-type="anime")
|
||||||
img.anime-cover-image.anime-search-result.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.Canonical)
|
img.anime-cover-image.anime-search-result.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.Canonical)
|
||||||
|
|
||||||
component CharacterSearchResults(characters []*arn.Character)
|
component CharacterSearchResults(characters []*arn.Character, user *arn.User)
|
||||||
if len(characters) == 0
|
if len(characters) == 0
|
||||||
p.no-search-results.mountable No characters found.
|
p.no-search-results.mountable No characters found.
|
||||||
else
|
else
|
||||||
.character-search
|
.character-search
|
||||||
each character in characters
|
each character in characters
|
||||||
.mountable(data-mountable-type="character")
|
.mountable(data-mountable-type="character")
|
||||||
CharacterSmall(character)
|
CharacterSmall(character, user)
|
||||||
|
|
||||||
component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread)
|
component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread)
|
||||||
if len(posts) == 0 && len(threads) == 0
|
if len(posts) == 0 && len(threads) == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user