improve game analysis ui, remove pgn and add bookmarkers
This commit is contained in:
parent
fa188d9335
commit
810173cbf0
|
@ -15,6 +15,4 @@ final class AnalyseEnv(
|
|||
lazy val pgnDump = new PgnDump(
|
||||
userRepo = userRepo,
|
||||
gameRepo = gameRepo)
|
||||
|
||||
lazy val gameInfo = GameInfo(pgnDump) _
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package lila
|
||||
package analyse
|
||||
|
||||
import chess.OpeningExplorer
|
||||
import chess.format.Forsyth
|
||||
import game.DbGame
|
||||
|
||||
import scalaz.effects.IO
|
||||
|
||||
final class GameInfo private (
|
||||
val game: DbGame,
|
||||
val pgn: String,
|
||||
val opening: Option[OpeningExplorer.Opening]) {
|
||||
|
||||
def toMap = Map(
|
||||
"pgn" -> pgn,
|
||||
"opening" -> game.variant.standard.fold(
|
||||
opening map { o ⇒ Map("code" -> o.code, "name" -> o.name) },
|
||||
None)
|
||||
)
|
||||
}
|
||||
|
||||
object GameInfo {
|
||||
|
||||
def apply(pgnDump: PgnDump)(game: DbGame): IO[GameInfo] =
|
||||
pgnDump >> game map { pgn ⇒
|
||||
new GameInfo(
|
||||
game = game,
|
||||
pgn = pgn,
|
||||
opening = OpeningExplorer openingOf game.pgn)
|
||||
}
|
||||
}
|
|
@ -10,13 +10,19 @@ import scalaz.effects._
|
|||
|
||||
object Analyse extends LilaController {
|
||||
|
||||
val gameRepo = env.game.gameRepo
|
||||
val gameInfo = env.analyse.gameInfo
|
||||
val pgnDump = env.analyse.pgnDump
|
||||
def gameRepo = env.game.gameRepo
|
||||
def pgnDump = env.analyse.pgnDump
|
||||
def openingExplorer = chess.OpeningExplorer
|
||||
def starApi = env.star.api
|
||||
|
||||
def replay(id: String, color: String) = Open { implicit ctx ⇒
|
||||
IOptionIOk(gameRepo.pov(id, color)) { pov ⇒
|
||||
gameInfo(pov.game) map { html.analyse.replay(pov, _) }
|
||||
starApi usersByGame pov.game map { bookmarkers ⇒
|
||||
html.analyse.replay(
|
||||
pov,
|
||||
bookmarkers,
|
||||
openingExplorer openingOf pov.game.pgn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, info: lila.analyse.GameInfo)(implicit ctx: Context)
|
||||
@(pov: Pov, bookmarkers: List[User], opening: Option[chess.OpeningExplorer.Opening])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -45,17 +45,27 @@
|
|||
@trans.thisGameIsRated()<br />
|
||||
}
|
||||
@trans.opening() -
|
||||
@info.opening.map { o =>
|
||||
@opening.map { o =>
|
||||
<a href="http://www.chessgames.com/perl/chessopening?eco=@o.code">@o.code @o.name</a><br />
|
||||
}.getOrElse { "Unknown" }
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
<a class="rotate_board" href="@routes.Analyse.replay(gameId, (!color).name)">@trans.flipBoard()</a><br />
|
||||
<br />
|
||||
Export PGN:
|
||||
<textarea id="pgnText" readonly="readonly">@Html(info.pgn)</textarea>
|
||||
<a href="@routes.Analyse.pgn(game.id)">Download PGN</a>
|
||||
@if(bookmarkers.nonEmpty) {
|
||||
<div class="bookmarkers">
|
||||
<p>@trans.bookmarkedByNbPlayers(bookmarkers.size)</p>
|
||||
<ul>
|
||||
@bookmarkers.map { bookmarker =>
|
||||
<li>@userLink(bookmarker)</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<textarea id="pgnText" readonly="readonly">@Html(game.pgn)</textarea>
|
||||
}
|
||||
|
||||
@analyse.layout(
|
||||
|
@ -73,4 +83,5 @@ moreJs = moreJs) {
|
|||
<div id="GameText"></div>
|
||||
</div>
|
||||
</div>
|
||||
@round.share(game)
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ menu = menu.some) {
|
|||
<div class="all_games infinitescroll">
|
||||
@next.map { n =>
|
||||
<div class="pager none"><a href="@n">Next</a></div>
|
||||
}.getOrElse {
|
||||
<div class="none"></div>
|
||||
}
|
||||
@game.widgets(paginator.currentPageResults)
|
||||
</div>
|
||||
|
|
|
@ -3,17 +3,7 @@
|
|||
margin-bottom: 5px;
|
||||
}
|
||||
#pgnText {
|
||||
color: #666;
|
||||
width: 182px;
|
||||
height: 220px;
|
||||
border: 1px solid #C0C0C0;
|
||||
overflow: auto;
|
||||
padding: 5px;
|
||||
margin: 0.5em 0;
|
||||
border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
background: transparent;
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.board_wrap {
|
||||
|
|
1
todo
1
todo
|
@ -26,6 +26,7 @@ tournaments http://www.chess.com/tournaments/help.html
|
|||
long name display issue http://en.lichess.org/forum/lichess-feedback/long-names-alter-layout
|
||||
remove bookmark when removing game
|
||||
fix game list translations
|
||||
friend game invited is not blamed
|
||||
|
||||
next deploy:
|
||||
db.game2.ensureIndex({"bm": -1}, {sparse: true})
|
||||
|
|
Loading…
Reference in a new issue