click username opens a popup
parent
d89fa38fc2
commit
d16acfd537
|
@ -149,11 +149,13 @@ private[controllers] trait LilaController
|
|||
protected def OptionFuResult[A](fua: Fu[Option[A]])(op: A ⇒ Fu[Result])(implicit ctx: Context) =
|
||||
fua flatMap { _.fold(notFound(ctx))(a ⇒ op(a)) }
|
||||
|
||||
protected def notFound(implicit ctx: Context): Fu[Result] =
|
||||
(ctx.req.headers get "X-Requested-With") ?? ("XMLHttpRequest" ==) fold (
|
||||
NotFound("resource not found").fuccess,
|
||||
Lobby handleNotFound ctx
|
||||
)
|
||||
protected def notFound(implicit ctx: Context): Fu[Result] = isXhr fold (
|
||||
NotFound("resource not found").fuccess,
|
||||
Lobby handleNotFound ctx
|
||||
)
|
||||
|
||||
protected def isXhr(implicit ctx: Context) =
|
||||
(ctx.req.headers get "X-Requested-With") ?? ("XMLHttpRequest" ==)
|
||||
|
||||
protected def isGranted(permission: Permission.type ⇒ Permission)(implicit ctx: Context): Boolean =
|
||||
isGranted(permission(Permission))
|
||||
|
|
|
@ -20,13 +20,18 @@ object User extends LilaController {
|
|||
bookmarkApi = Env.bookmark.api,
|
||||
eloCalculator = Env.round.eloCalculator) _
|
||||
|
||||
def show(username: String) = showFilter(username, "all", 1)
|
||||
def show(username: String) = Open { implicit ctx ⇒
|
||||
isXhr.fold(mini(username), filter(username, "all", 1))
|
||||
}
|
||||
|
||||
def showFilter(username: String, filterName: String, page: Int) = Open { implicit ctx ⇒
|
||||
filter(username, filterName, page)
|
||||
}
|
||||
|
||||
private def filter(username: String, filterName: String, page: Int)(implicit ctx: Context) =
|
||||
Reasonable(page) {
|
||||
OptionFuOk(UserRepo named username) { userShow(_, filterName, page) }
|
||||
}
|
||||
}
|
||||
|
||||
private def userShow(u: UserModel, filterName: String, page: Int)(implicit ctx: Context) =
|
||||
(u.enabled || isGranted(_.UserSpy)).fold({
|
||||
|
@ -39,6 +44,11 @@ object User extends LilaController {
|
|||
} yield html.user.show(u, info, pag, filters)
|
||||
}, fuccess(html.user.disabled(u)))
|
||||
|
||||
private def mini(username: String)(implicit ctx: Context) =
|
||||
OptionOk(UserRepo named username) { user ⇒
|
||||
html.user.mini(user)
|
||||
}
|
||||
|
||||
def list(page: Int) = Open { implicit ctx ⇒
|
||||
Reasonable(page) {
|
||||
onlineUsers zip env.paginator.elo(page) map {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
@(u: User)(implicit ctx: Context)
|
||||
|
||||
@userLink(u, go = true)
|
||||
|
||||
@friend.button(u.id)
|
|
@ -319,6 +319,16 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
|
|||
return false;
|
||||
});
|
||||
|
||||
$('body').on('click', 'a.user_link', function() {
|
||||
$.ajax({
|
||||
url: $(this).attr('href'),
|
||||
success: function(html) {
|
||||
console.debug(html);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// Start game
|
||||
var $game = $('div.lichess_game').orNot();
|
||||
if ($game) $game.game(_ld_);
|
||||
|
|
Loading…
Reference in New Issue