move streamer thumbnail code
parent
7ac1be05ee
commit
26b598510f
|
@ -31,23 +31,6 @@ object bits extends Context.ToLang {
|
|||
)
|
||||
)
|
||||
|
||||
object thumbnail {
|
||||
val size = 300
|
||||
def apply(s: lila.streamer.Streamer, u: User) =
|
||||
img(
|
||||
width := size,
|
||||
height := size,
|
||||
cls := "picture",
|
||||
src := url(s),
|
||||
alt := s"${u.titleUsername} Lichess streamer picture"
|
||||
)
|
||||
def url(s: lila.streamer.Streamer) =
|
||||
s.picture match {
|
||||
case Some(image) => picfitUrl.thumbnail(image, size, size)
|
||||
case _ => assetUrl("images/placeholder.png")
|
||||
}
|
||||
}
|
||||
|
||||
def menu(active: String, s: Option[lila.streamer.Streamer.WithUser])(implicit ctx: Context) =
|
||||
st.nav(cls := "subnav")(
|
||||
a(cls := active.active("index"), href := routes.Streamer.index())(allStreamers()),
|
||||
|
|
|
@ -34,7 +34,7 @@ object edit extends Context.ToLang {
|
|||
href := routes.Streamer.picture,
|
||||
title := changePicture.txt()
|
||||
)(
|
||||
bits.thumbnail(s.streamer, s.user)
|
||||
picture.thumbnail(s.streamer, s.user)
|
||||
)
|
||||
else
|
||||
div(cls := "picture-create")(
|
||||
|
|
|
@ -12,7 +12,7 @@ object header {
|
|||
|
||||
def apply(s: lila.streamer.Streamer.WithUserAndStream)(implicit ctx: Context) =
|
||||
div(cls := "streamer-header")(
|
||||
bits.thumbnail(s.streamer, s.user),
|
||||
picture.thumbnail(s.streamer, s.user),
|
||||
div(cls := "overview")(
|
||||
h1(dataIcon := "")(
|
||||
titleTag(s.user.title),
|
||||
|
|
|
@ -27,7 +27,7 @@ object index {
|
|||
else
|
||||
bits.redirectLink(s.user.username, stream.isDefined.some)(cls := "overlay"),
|
||||
stream.isDefined option span(cls := "ribbon")(span(trans.streamer.live())),
|
||||
bits.thumbnail(s.streamer, s.user),
|
||||
picture.thumbnail(s.streamer, s.user),
|
||||
div(cls := "overview")(
|
||||
h1(dataIcon := "")(titleTag(s.user.title), s.streamer.name),
|
||||
s.streamer.headline.map(_.value).map { d =>
|
||||
|
|
|
@ -5,6 +5,7 @@ import controllers.routes
|
|||
import lila.api.Context
|
||||
import lila.app.templating.Environment._
|
||||
import lila.app.ui.ScalatagsTemplate._
|
||||
import lila.user.User
|
||||
|
||||
object picture {
|
||||
|
||||
|
@ -22,7 +23,7 @@ $('.streamer-picture form.upload input[type=file]').on('change', function() {
|
|||
) {
|
||||
main(cls := "streamer-picture small-page box")(
|
||||
h1(xStreamerPicture(userLink(s.user))),
|
||||
div(cls := "picture_wrap")(bits.thumbnail(s.streamer, s.user)),
|
||||
div(cls := "picture_wrap")(thumbnail(s.streamer, s.user)),
|
||||
div(cls := "forms")(
|
||||
error.map { badTag(_) },
|
||||
postForm(
|
||||
|
@ -40,4 +41,21 @@ $('.streamer-picture form.upload input[type=file]').on('change', function() {
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
object thumbnail {
|
||||
val size = 300
|
||||
def apply(s: lila.streamer.Streamer, u: User) =
|
||||
img(
|
||||
width := size,
|
||||
height := size,
|
||||
cls := "picture",
|
||||
src := url(s),
|
||||
alt := s"${u.titleUsername} Lichess streamer picture"
|
||||
)
|
||||
def url(s: lila.streamer.Streamer) =
|
||||
s.picture match {
|
||||
case Some(image) => picfitUrl.thumbnail(image, size, size)
|
||||
case _ => assetUrl("images/placeholder.png")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ object show {
|
|||
shorten(~(s.streamer.headline.map(_.value) orElse s.streamer.description.map(_.value)), 152),
|
||||
url = s"$netBaseUrl${routes.Streamer.show(s.user.username)}",
|
||||
`type` = "video",
|
||||
image = s.streamer.hasPicture option bits.thumbnail.url(s.streamer)
|
||||
image = s.streamer.hasPicture option picture.thumbnail.url(s.streamer)
|
||||
)
|
||||
.some,
|
||||
csp = defaultCsp.finalizeWithTwitch.some
|
||||
|
|
Loading…
Reference in New Issue