bookmark game wip

pull/1/merge
Thibault Duplessis 2012-06-07 01:24:36 +02:00
parent 2a9a4a5ed8
commit 7cb52e589f
8 changed files with 57 additions and 34 deletions

View File

@ -13,8 +13,11 @@ object Star extends LilaController {
def toggle(gameId: String) = Auth { implicit ctx
me
IOptionIOk(gameRepo game gameId) { game
starRepo.toggle(game.id, me.id)
IOk {
for {
exists gameRepo exists gameId
_ exists.fold(starRepo.toggle(gameId, me.id), io())
} yield ()
}
}
}

View File

@ -162,5 +162,6 @@ final class I18nKeys(translator: Translator) {
val takebackPropositionAccepted = new Key("takebackPropositionAccepted")
val takebackPropositionCanceled = new Key("takebackPropositionCanceled")
val yourOpponentProposesATakeback = new Key("yourOpponentProposesATakeback")
val bookmarkThisGame = new Key("bookmarkThisGame")
val freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents = new Key("freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents")
}

View File

@ -7,10 +7,10 @@ import user.{ User, UserRepo }
import scalaz.effects._
final class StarApi(
starRepo: StarRepo,
gameRepo: GameRepo,
userRepo: UserRepo) {
starRepo: StarRepo,
gameRepo: GameRepo,
userRepo: UserRepo) {
def starred(game: DbGame, user: User): IO[Boolean] =
starRepo.exists(game.id, user.id)
def starred(game: DbGame, user: User): IO[Boolean] =
starRepo.exists(game.id, user.id)
}

View File

@ -1,12 +1,13 @@
@(game: DbGame)(implicit ctx: Context)
@defining("http://lichess.org" + routes.Round.watcher(game.id, "white")) { url =>
<div class="game_share">
<div class="game_share_top">
<a title="@trans.shareThisUrlToLetSpectatorsSeeTheGame()" class="game_permalink blank_if_play" href="@url">@url</a>
</div>
<div class="game_share clearfix">
@ctx.me.map { m =>
<a href="@routes.Star.toggle(game.id)" class="@starred(game, m).fold("starred", "")">star it</a>
<a
href="@routes.Star.toggle(game.id)"
class="star_game @starred(game, m).fold("starred", "")"
title="@trans.bookmarkThisGame()"></a>
}
<a title="@trans.shareThisUrlToLetSpectatorsSeeTheGame()" class="game_permalink blank_if_play" href="@url">@url</a>
</div>
}

View File

@ -138,4 +138,5 @@ takebackPropositionDeclined=Takeback proposition declined
takebackPropositionAccepted=Takeback proposition accepted
takebackPropositionCanceled=Takeback proposition canceled
yourOpponentProposesATakeback=Your opponent proposes a takeback
bookmarkThisGame=Bookmark this game
freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents=Free online Chess game. Play Chess now in a clean interface. No registration, no ads, no plugin required. Play Chess with computer, friends or random opponents.

View File

@ -92,7 +92,7 @@ GET /lobby/socket controllers.Lobby.socket
GET /lobby/log controllers.Lobby.log
# Star
GET /star/$gameId<[\w\-]{8}> controllers.Star.toggle(gameId: String)
POST /star/$gameId<[\w\-]{8}> controllers.Star.toggle(gameId: String)
# Forum
GET /forum controllers.ForumCateg.index

View File

@ -162,6 +162,12 @@ $(function() {
return confirm('Confirm this action?');
});
$('a.star_game').click(function() {
$(this).toggleClass("starred");
$.post($(this).attr("href"));
return false;
});
var elem = document.createElement('audio');
var canPlayAudio = !! elem.canPlayType && elem.canPlayType('audio/ogg; codecs="vorbis"');
var $soundToggle = $('#sound_state');

View File

@ -523,27 +523,6 @@ div.hooks td.action {
background: -o-linear-gradient(top , #aaa, #999) repeat scroll 0 0 #999;
background: linear-gradient(top , #aaa, #999) repeat scroll 0 0 #999;
}
div.game_share {
margin-top: 30px;
width: 512px;
box-shadow: 0 0 7px #d0d0d0;
-moz-box-shadow: 0 0 7px #d0d0d0;
-webkit-box-shadow: 0 0 7px #d0d0d0;
border: 1px solid #c0c0c0;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
div.game_share_top {
width: 92%;
height: 25px;
padding: 10px 4% 6px 4%;
}
div.game_share_top a.game_permalink {
float: left;
display: block;
margin-top: 3px;
}
div.checkmateFen {
float: left;
@ -564,3 +543,35 @@ div.checkmateCaptcha input {
font-weight: bold;
width: 5em;
}
div.game_share {
margin-top: 30px;
width: 492px;
box-shadow: 0 0 7px #d0d0d0;
-moz-box-shadow: 0 0 7px #d0d0d0;
-webkit-box-shadow: 0 0 7px #d0d0d0;
border: 1px solid #c0c0c0;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
padding: 3px 10px;
line-height: 24px;
}
div.game_share a.game_permalink {
float: left;
display: block;
margin-top: 3px;
}
a.star_game {
background: transparent url(../images/s24.png) top left no-repeat;
width: 24px;
height: 24px;
display: block;
}
a.star_game.starred {
background-position: 0 -24px;
}
div.game_share a.star_game {
float: right;
}