improve export of a single game

pull/4339/head
Thibault Duplessis 2018-05-07 02:17:23 +02:00
parent 3428119b3c
commit e89b7f1ef1
3 changed files with 8 additions and 22 deletions

View File

@ -34,7 +34,7 @@ object Game extends LilaController {
val config = GameApiV2.OneConfig(
format = if (HTTPRequest acceptsJson ctx.req) GameApiV2.Format.JSON else GameApiV2.Format.PGN,
imported = getBool("imported"),
flags = requestPgnFlags(ctx.req)
flags = requestPgnFlags(ctx.req, extended = true)
)
lila.mon.export.pgn.game()
Env.api.gameApiV2.exportOne(game, config) flatMap { content =>
@ -71,7 +71,7 @@ object Game extends LilaController {
perfType = ~get("perfType", req) split "," flatMap { lila.rating.PerfType(_) } toSet,
color = get("color", req) flatMap chess.Color.apply,
analysed = getBoolOpt("analysed", req),
flags = requestPgnFlags(req),
flags = requestPgnFlags(req, extended = false),
perSecond = MaxPerSecond(me match {
case Some(m) if m is user.id => 50
case Some(_) if oauth => 20 // bonus for oauth logged in only (not for XSRF)
@ -89,13 +89,13 @@ object Game extends LilaController {
}
}
private def requestPgnFlags(req: RequestHeader) =
private def requestPgnFlags(req: RequestHeader, extended: Boolean) =
lila.game.PgnDump.WithFlags(
moves = getBoolOpt("moves", req) | true,
tags = getBoolOpt("tags", req) | true,
clocks = getBoolOpt("clocks", req) | false,
evals = getBoolOpt("evals", req) | false,
opening = getBoolOpt("opening", req) | false
clocks = getBoolOpt("clocks", req) | extended,
evals = getBoolOpt("evals", req) | extended,
opening = getBoolOpt("opening", req) | extended
)
private def gameContentType(config: GameApiV2.Config) = config.format match {

View File

@ -69,10 +69,8 @@ atom = atom.some) {
<div class="pgn_options">
<strong>PGN</strong>
<div>
<a data-icon="x" class="text" rel="nofollow" href="@routes.Game.exportOne(game.id)?evals=1&clocks=1&opening=1">@trans.downloadAnnotated()</a>
@if(analysis.isDefined) {
<a data-icon="x" class="text" rel="nofollow" href="@routes.Game.exportOne(game.id)">@trans.downloadRaw()</a>
}
<a data-icon="x" class="text" rel="nofollow" href="@routes.Game.exportOne(game.id)">@trans.downloadAnnotated()</a>
<a data-icon="x" class="text" rel="nofollow" href="@routes.Game.exportOne(game.id)?evals=0&clocks=0">@trans.downloadRaw()</a>
@if(game.isPgnImport) {
<a data-icon="x" class="text" rel="nofollow" href="@routes.Game.exportOne(game.id)?imported=1">@trans.downloadImported()</a>
}

View File

@ -52,18 +52,6 @@ chessground = false) {
<div class="underboard_content">
<div class="analysis_panels">
<div class="panel fen_pgn">
<p><strong>FEN</strong><input readonly="true" spellcheck="false" class="copyable autoselect fen" /></p>
<p><strong>PGN</strong>
<a data-icon="x" rel="nofollow" href="@routes.Game.exportOne(game.id)?evals=1&clocks=1&opening=1"> @trans.downloadAnnotated()</a>
@if(analysis.isDefined) {
/
<a data-icon="x" rel="nofollow" href="@routes.Game.exportOne(game.id)"> @trans.downloadRaw()</a>
}
@if(game.isPgnImport) {
/
<a data-icon="x" rel="nofollow" href="@routes.Game.exportOne(game.id)?imported=1"> @trans.downloadImported()</a>
}
</p>
<div class="pgn">@pgn</div>
</div>
@cross.map { c =>