Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download i18ns in broadcast embeds #16249

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/views/base/embed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package views.base

import lila.app.UiEnv.{ *, given }
import lila.ui.ContentSecurityPolicy
import lila.core.i18n.I18nModule

object embed:
/* a minimalist embed that doesn't load site.ts */
Expand Down Expand Up @@ -49,7 +50,8 @@ object embed:
cssKeys: List[String] = Nil,
modules: EsmList = Nil,
pageModule: Option[PageModule] = None,
csp: Update[ContentSecurityPolicy] = identity
csp: Update[ContentSecurityPolicy] = identity,
i18nModules: List[I18nModule.Selector] = Nil
)(body: Modifier*)(using ctx: EmbedContext) = lila.ui.Snippet:
val allModules = modules ++ pageModule.so(module => esmPage(module.name))
frag(
Expand All @@ -65,7 +67,11 @@ object embed:
page.ui.pieceSprite(ctx.pieceSet.name),
cssTag("common.theme.embed"), // includes both light & dark colors
cssKeys.map(cssTag),
page.ui.sitePreload(Nil, allModules, isInquiry = false),
page.ui.sitePreload(
List[I18nModule.Selector](_.site, _.timeago) ++ i18nModules,
allModules,
isInquiry = false
),
page.ui.lichessFontFaceCss
),
st.body(bodyModifiers)(
Expand Down
4 changes: 3 additions & 1 deletion app/views/relay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ def embed(
data: lila.relay.JsonView.JsData,
socketVersion: SocketVersion
)(using ctx: EmbedContext) =
import lila.core.i18n.I18nModule
views.base.embed.site(
title = rt.fullName,
cssKeys = List("analyse.relay.embed"),
pageModule = ui.pageModule(rt, data, none, socketVersion, embed = true).some,
csp = _.withExternalAnalysisApis
csp = _.withExternalAnalysisApis,
i18nModules = List(_.site, _.timeago, _.study, _.broadcast)
)(
div(id := "main-wrap", cls := "is2d"):
ui.showPreload(rt, data)(cls := "relay-embed")
Expand Down