2020-01-30 09:24:12 -07:00
|
|
|
package views.html
|
|
|
|
package user
|
|
|
|
|
2021-01-15 07:21:19 -07:00
|
|
|
import controllers.routes
|
|
|
|
|
2020-01-30 09:24:12 -07:00
|
|
|
import lila.api.Context
|
|
|
|
import lila.app.templating.Environment._
|
|
|
|
import lila.app.ui.ScalatagsTemplate._
|
|
|
|
import lila.user.User
|
|
|
|
|
|
|
|
object bots {
|
|
|
|
|
|
|
|
def apply(users: List[User])(implicit ctx: Context) = {
|
|
|
|
|
2020-01-31 07:48:49 -07:00
|
|
|
val title = s"${users.size} Online bots"
|
2020-01-30 09:24:12 -07:00
|
|
|
|
2021-01-15 07:21:19 -07:00
|
|
|
val sorted = users.sortBy { -_.playTime.??(_.total) }
|
|
|
|
|
2020-01-30 09:24:12 -07:00
|
|
|
views.html.base.layout(
|
|
|
|
title = title,
|
|
|
|
moreCss = frag(cssTag("slist"), cssTag("user.list")),
|
|
|
|
wrapClass = "full-screen-force"
|
|
|
|
)(
|
|
|
|
main(cls := "page-menu bots")(
|
|
|
|
user.bits.communityMenu("bots"),
|
2021-01-15 07:21:19 -07:00
|
|
|
sorted.partition(_.isVerified) match {
|
|
|
|
case (featured, all) =>
|
|
|
|
div(cls := "bots page-menu__content")(
|
|
|
|
div(cls := "box bots__featured")(
|
|
|
|
div(cls := "box__top")(h1("Featured bots")),
|
|
|
|
botTable(featured)
|
|
|
|
),
|
|
|
|
div(cls := "box")(
|
2021-01-29 10:07:20 -07:00
|
|
|
div(cls := "box__top")(
|
|
|
|
h1("Community bots"),
|
|
|
|
a(
|
|
|
|
cls := "bots__about",
|
|
|
|
href := "https://lichess.org/blog/WvDNticAAMu_mHKP/welcome-lichess-bots"
|
|
|
|
)(
|
|
|
|
"About Lichess Bots"
|
|
|
|
)
|
|
|
|
),
|
2021-01-15 07:21:19 -07:00
|
|
|
botTable(all)
|
|
|
|
)
|
2020-01-30 09:24:12 -07:00
|
|
|
)
|
2021-01-15 07:21:19 -07:00
|
|
|
}
|
2020-01-30 09:24:12 -07:00
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-01-15 07:21:19 -07:00
|
|
|
private def botTable(users: List[User])(implicit ctx: Context) = table(cls := "slist slist-pad")(
|
|
|
|
tbody(
|
|
|
|
users.sortBy { u =>
|
|
|
|
(if (u.isVerified) -1 else 1, -u.playTime.??(_.total))
|
|
|
|
} map { u =>
|
|
|
|
tr(
|
|
|
|
td(userLink(u)),
|
|
|
|
u.profile
|
|
|
|
.ifTrue(ctx.noKid)
|
|
|
|
.ifTrue(!u.marks.troll || ctx.is(u))
|
|
|
|
.flatMap(_.nonEmptyBio)
|
|
|
|
.map { bio =>
|
|
|
|
td(shorten(bio, 400))
|
|
|
|
} | td,
|
2021-10-21 04:08:11 -06:00
|
|
|
ctx.pref.showRatings option td(cls := "rating")(u.best3Perfs.map {
|
2021-01-15 07:21:19 -07:00
|
|
|
showPerfRating(u, _)
|
|
|
|
}),
|
|
|
|
u.playTime.fold(td) { playTime =>
|
|
|
|
td(
|
|
|
|
p(
|
|
|
|
cls := "text",
|
2021-06-14 01:13:27 -06:00
|
|
|
dataIcon := "",
|
2021-01-15 07:21:19 -07:00
|
|
|
st.title := trans.tpTimeSpentPlaying.txt(showPeriod(playTime.totalPeriod))
|
|
|
|
)(showPeriod(playTime.totalPeriod)),
|
|
|
|
playTime.nonEmptyTvPeriod.map { tvPeriod =>
|
|
|
|
p(
|
|
|
|
cls := "text",
|
2021-06-14 01:13:27 -06:00
|
|
|
dataIcon := "",
|
2021-01-15 07:21:19 -07:00
|
|
|
st.title := trans.tpTimeSpentOnTV.txt(showPeriod(tvPeriod))
|
|
|
|
)(showPeriod(tvPeriod))
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
if (ctx is u) td
|
|
|
|
else {
|
|
|
|
td(
|
|
|
|
a(
|
2021-06-14 01:13:27 -06:00
|
|
|
dataIcon := "",
|
2021-01-15 07:21:19 -07:00
|
|
|
cls := List("button button-empty text" -> true),
|
2021-01-21 05:23:08 -07:00
|
|
|
st.title := trans.challenge.challengeToPlay.txt(),
|
2021-02-08 07:25:21 -07:00
|
|
|
href := s"${routes.Lobby.home}?user=${u.username}#friend"
|
2021-01-15 07:21:19 -07:00
|
|
|
)(trans.play())
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
2020-01-30 09:24:12 -07:00
|
|
|
}
|