custom code for ChessWhiz because he's pretty awesome
This commit is contained in:
parent
018b315a5b
commit
212a1a569a
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
}
|
||||
@streams.map { s =>
|
||||
<a class="stream" href="@s.url" data-icon="1"> @s.name</a>
|
||||
<a class="stream" href="@s.url"><span data-icon="1"> LIVE!</span> @s.name</a>
|
||||
}
|
||||
<div id="timeline" data-href="@routes.Lobby.timeline">
|
||||
@timeline.entries(userTimeline)
|
||||
|
|
|
@ -7,6 +7,7 @@ import lila.common.PimpedConfig._
|
|||
final class Env(
|
||||
config: Config,
|
||||
hub: lila.hub.Env,
|
||||
isOnline: String => Boolean,
|
||||
system: akka.actor.ActorSystem,
|
||||
scheduler: lila.common.Scheduler) {
|
||||
|
||||
|
@ -22,6 +23,7 @@ final class Env(
|
|||
|
||||
private lazy val streaming = new Streaming(
|
||||
system = system,
|
||||
isOnline = isOnline,
|
||||
ustreamApiKey = UstreamApiKey)
|
||||
|
||||
def streamsOnAir = streaming.onAir
|
||||
|
@ -48,6 +50,7 @@ object Env {
|
|||
lazy val current = "[boot] tv" describes new Env(
|
||||
config = lila.common.PlayApp loadConfig "tv",
|
||||
hub = lila.hub.Env.current,
|
||||
isOnline = lila.user.Env.current.isOnline,
|
||||
system = lila.common.PlayApp.system,
|
||||
scheduler = lila.common.PlayApp.scheduler)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import play.api.libs.ws.WS
|
|||
|
||||
private final class Streaming(
|
||||
system: ActorSystem,
|
||||
ustreamApiKey: String) {
|
||||
ustreamApiKey: String,
|
||||
isOnline: String => Boolean) {
|
||||
|
||||
import Streaming._
|
||||
import Twitch.Reads._
|
||||
|
@ -26,16 +27,16 @@ private final class Streaming(
|
|||
case Get => sender ! onAir
|
||||
|
||||
case Search =>
|
||||
val keyword = "lichess.org"
|
||||
val max = 2
|
||||
val twitch = WS.url("https://api.twitch.tv/kraken/search/streams")
|
||||
.withQueryString("q" -> keyword)
|
||||
.withQueryString("q" -> "lichess.org")
|
||||
.withHeaders("Accept" -> "application/vnd.twitchtv.v2+json")
|
||||
.get().map { _.json.asOpt[Twitch.Result] ?? (_.streamsOnAir take max) }
|
||||
val ustream = WS.url(s"http://api.ustream.tv/json/stream/all/search/description:like:$keyword")
|
||||
val chesswhiz = isOnline("chesswhiz") ??
|
||||
WS.url(s"http://api.ustream.tv/json/stream/recent/search/title:like:chesswhiz")
|
||||
.withQueryString("key" -> ustreamApiKey)
|
||||
.get().map { _.json.asOpt[Ustream.Result] ?? (_.streamsOnAir take max) }
|
||||
twitch |+| ustream map StreamsOnAir.apply pipeTo self
|
||||
twitch |+| chesswhiz map StreamsOnAir.apply pipeTo self
|
||||
|
||||
case StreamsOnAir(streams) => onAir = streams
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ object ApplicationBuild extends Build {
|
|||
play.api, RM, PRM, elastic4s)
|
||||
)
|
||||
|
||||
lazy val tv = project("tv", Seq(common, db, hub, game, chess)).settings(
|
||||
lazy val tv = project("tv", Seq(common, db, hub, game, user, chess)).settings(
|
||||
libraryDependencies ++= provided(
|
||||
play.api, RM, PRM)
|
||||
)
|
||||
|
|
|
@ -1978,6 +1978,13 @@ div.lichess_overboard.joining .mini_board {
|
|||
#site_header a.stream:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#site_header a.stream span {
|
||||
color: #d59120;
|
||||
font-weight: bold;
|
||||
}
|
||||
#site_header a.stream span:before {
|
||||
vertical-align: -3px;
|
||||
}
|
||||
#timeline {
|
||||
margin-top: 2em;
|
||||
border-top: 1px solid #e4e4e4;
|
||||
|
|
Loading…
Reference in a new issue