-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
UiEnv.scala
61 lines (49 loc) · 2.26 KB
/
UiEnv.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package lila.app
import lila.ui.*
import lila.web.ui.*
object UiEnv
extends ScalatagsTemplate
with lila.pref.PrefHelper
with SecurityHelper
with TeamHelper
with Helpers
with AssetFullHelper:
export lila.core.lilaism.Lilaism.{ *, given }
export lila.core.id.ImageId
export lila.common.extensions.*
export lila.common.String.html.richText
export lila.ui.{ Page, Nonce, OpenGraph, PageModule, EsmList, Icon }
export lila.api.Context.{ ctxToTranslate as _, *, given }
private var envVar: Option[Env] = None
def setEnv(e: Env) = envVar = Some(e)
def env: Env = envVar.get
def netConfig = env.net
def contactEmailInClear = env.net.email.value
def picfitUrl = env.memo.picfitUrl
given lila.core.config.NetDomain = env.net.domain
given (using ctx: PageContext): Option[Nonce] = ctx.nonce
given Conversion[lila.team.Team, lila.core.team.LightTeam] = _.light
def apiVersion = lila.security.Mobile.Api.currentVersion
def explorerEndpoint = env.explorerEndpoint
def tablebaseEndpoint = env.tablebaseEndpoint
def externalEngineEndpoint = env.externalEngineEndpoint
// helpers dependencies
lazy val assetBaseUrl = netConfig.assetBaseUrl
lazy val netBaseUrl = netConfig.baseUrl
protected val ratingApi = lila.rating.ratingApi
protected lazy val flairApi = env.user.flairApi
lazy val isOnline = env.socket.isOnline
lazy val lightUserSync = env.user.lightUserSync
def manifest = env.web.manifest
protected val jsDump = lila.i18n.JsDump
protected val translator = lila.i18n.Translator
val langList = lila.i18n.LangList
protected val namer = lila.game.Namer
protected lazy val lightTeamSync = env.team.lightTeamSync
protected lazy val syncBelongsTo = env.team.api.syncBelongsTo
def helpers: Helpers = this
def assetHelper: AssetFullHelper = this
def prefHelper: lila.pref.PrefHelper = this
def flagApi = lila.user.Flags
def lightUserFallback = env.user.lightUserSyncFallback
def isStreaming(userId: UserId) = env.streamer.liveStreamApi.isStreaming(userId)