open explorer game with the same orientation

pull/1605/head
Thibault Duplessis 2016-02-12 17:29:25 +07:00
parent 05f08aaab4
commit ba8bb24f01
3 changed files with 6 additions and 5 deletions

View File

@ -39,7 +39,7 @@ object Importer extends LilaController {
)
}
def masterGame(id: String) = Open { implicit ctx =>
def masterGame(id: String, orientation: String) = Open { implicit ctx =>
lila.game.GameRepo game id flatMap {
case Some(game) => fuccess(Redirect(routes.Round.watcher(game.id, game.firstPlayer.color.name)))
case _ => Env.explorer.fetchPgn(id) flatMap {
@ -49,7 +49,7 @@ object Importer extends LilaController {
user = ctx.userId,
forceId = id.some) map { game =>
Redirect {
val url = routes.Round.watcher(game.id, game.firstPlayer.color.name).url
val url = routes.Round.watcher(game.id, orientation).url
s"$url#${~getInt("ply")}"
}
}

View File

@ -320,7 +320,7 @@ DELETE /notification/$id<\w{8}> controllers.Notification.remove(id)
# Paste
GET /paste controllers.Importer.importGame
POST /import controllers.Importer.sendGame
GET /import/master/$id<\w{8}> controllers.Importer.masterGame(id: String)
GET /import/master/$id<\w{8}>/:color controllers.Importer.masterGame(id: String, color: String)
# Edit
GET /editor/*urlFen controllers.Editor.load(urlFen: String)

View File

@ -85,10 +85,11 @@ function showGameTable(ctrl, type, games) {
onclick: function(e) {
var $tr = $(e.target).parents('tr');
if (!$tr.length) return;
var orientation = ctrl.chessground.data.orientation;
if (ctrl.explorer.config.data.db.selected() === 'lichess')
window.open('/' + $tr.data('id') + '#' + ctrl.vm.step.ply, '_blank');
window.open('/' + $tr.data('id') + '/' + orientation + '#' + ctrl.vm.step.ply, '_blank');
else
window.open('/import/master' + $tr.data('id') + '?ply=' + ctrl.vm.step.ply, '_blank');
window.open('/import/master/' + $tr.data('id') + '/' + orientation + '?ply=' + ctrl.vm.step.ply, '_blank');
}
}, games.map(function(game) {
return m('tr', {