Prepare to use user language when displaying characters

This commit is contained in:
Eduard Urbach 2018-04-22 16:12:00 +02:00
parent bec7ff76e7
commit e8c66f28ab
10 changed files with 61 additions and 25 deletions

View File

@ -1,34 +1,34 @@
component Quote(quote *arn.Quote)
component Quote(quote *arn.Quote, user *arn.User)
.quote.mountable
QuoteContent(quote)
QuoteContent(quote, user)
QuoteFooter(quote)
component QuotePreview(quote *arn.Quote)
component QuotePreview(quote *arn.Quote, user *arn.User)
.quote.mountable
QuoteContentPreview(quote)
QuoteContentPreview(quote, user)
QuoteFooter(quote)
component QuoteContent(quote *arn.Quote)
component QuoteContent(quote *arn.Quote, user *arn.User)
.quote-content
a.quotation(href=quote.Link())
QuoteText(quote)
QuoteCharacter(quote)
QuoteCharacter(quote, user)
component QuoteContentPreview(quote *arn.Quote)
component QuoteContentPreview(quote *arn.Quote, user *arn.User)
.quote-content
a.quotation(href=quote.Link())
QuoteTextPreview(quote)
QuoteCharacter(quote)
QuoteCharacter(quote, user)
component QuoteText(quote *arn.Quote)
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
footer.quote-character
CharacterSmall(quote.Character())
CharacterSmall(quote.Character(), user)
component QuoteTextPreview(quote *arn.Quote)
if len(quote.Text.English) > 170

View File

@ -1,9 +1,9 @@
component Character(character *arn.Character)
component Character(character *arn.Character, user *arn.User)
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)
.image-title
.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)
img.character-image-small.lazy(data-src=character.ImageLink("small"), data-webp="true", data-color=character.AverageColor(), alt=character.Name.Canonical)

View File

@ -12,4 +12,4 @@ component AnimeCharacters(anime *arn.Anime, user *arn.User, standAlonePage bool)
each character in anime.Characters().Items
if (character.Role == "main" || standAlonePage) && character.Character() != nil
.mountable(data-mountable-type="character")
Character(character.Character())
Character(character.Character(), user)

View File

@ -28,7 +28,7 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
if mainQuote != nil
.character-quote
Quote(mainQuote)
Quote(mainQuote, user)
.character-description.mountable!= markdown.Render(character.Description)
@ -46,7 +46,7 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
each quote in quotes
if mainQuote == nil || quote.ID != mainQuote.ID
.character-quote
Quote(quote)
Quote(quote, user)
.character-sidebar
if len(character.Attributes) > 0

View 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")

View File

@ -7,5 +7,5 @@ component ProfileCharacters(characters []*arn.Character, viewUser *arn.User, use
.characters.profile-characters
each character in characters
.mountable
Character(character)
Character(character, user)

View File

@ -9,7 +9,7 @@ component QuotePage(quote *arn.Quote, character *arn.Character, user *arn.User)
component QuoteMainColumn(quote *arn.Quote, user *arn.User)
.widget-form.mountable
QuoteContent(quote)
QuoteContent(quote, user)
.footer.mountable
if quote.EditedBy != ""

View File

@ -23,7 +23,7 @@ component Quotes(quotes []*arn.Quote, nextIndex int, user *arn.User)
component QuotesScrollable(quotes []*arn.Quote, user *arn.User)
each quote in quotes
QuotePreview(quote)
QuotePreview(quote, user)
component QuotesTabs
.tabs

View File

@ -3,6 +3,8 @@ package search
import (
"strings"
"github.com/animenotifier/notify.moe/utils"
"github.com/aerogo/flow"
"github.com/aerogo/aero"
@ -25,6 +27,7 @@ const (
func Get(ctx *aero.Context) string {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
users, animes, posts, threads, tracks, characters, companies := search.All(
term,
@ -37,12 +40,12 @@ func Get(ctx *aero.Context) string {
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.
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.
@ -58,9 +61,10 @@ func Anime(ctx *aero.Context) string {
func Characters(ctx *aero.Context) string {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
characters := search.Characters(term, maxCharacters)
return ctx.HTML(components.CharacterSearchResults(characters))
return ctx.HTML(components.CharacterSearchResults(characters, user))
}
// Forum search.

View File

@ -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
.search
@ -16,7 +16,7 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
span Characters
#character-search-results
CharacterSearchResults(characters)
CharacterSearchResults(characters, user)
.widget
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")
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
p.no-search-results.mountable No characters found.
else
.character-search
each character in characters
.mountable(data-mountable-type="character")
CharacterSmall(character)
CharacterSmall(character, user)
component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread)
if len(posts) == 0 && len(threads) == 0