refactor & reformat
parent
ed1a77929a
commit
21298545c2
|
@ -38,31 +38,7 @@ object otherTrophies {
|
|||
href := routes.Tournament.show(revol.tourId)
|
||||
)(revol.iconChar.toString)
|
||||
},
|
||||
info.trophies.find(_.kind._id == TrophyKind.zugMiracle).map { t =>
|
||||
frag(
|
||||
styleTag("""
|
||||
.trophy.zugMiracle {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
height: 40px;
|
||||
margin: 0 8px!important;
|
||||
transition: 2s;
|
||||
}
|
||||
.trophy.zugMiracle img {
|
||||
height: 60px;
|
||||
}
|
||||
@keyframes psyche {
|
||||
100% { filter: hue-rotate(360deg); }
|
||||
}
|
||||
.trophy.zugMiracle:hover {
|
||||
transform: translateY(-9px);
|
||||
animation: psyche 0.3s ease-in-out infinite alternate;
|
||||
}"""),
|
||||
a(awardCls(t), href := t.kind.url, ariaTitle(t.kind.name))(
|
||||
img(src := assetUrl("images/trophy/zug-trophy.png"))
|
||||
)
|
||||
)
|
||||
},
|
||||
info.trophies.find(_.kind._id == TrophyKind.zugMiracle).map(zugMiracleTrophy),
|
||||
info.trophies.filter(_.kind.withCustomImage).map { t =>
|
||||
a(
|
||||
awardCls(t),
|
||||
|
@ -101,4 +77,24 @@ object otherTrophies {
|
|||
)
|
||||
|
||||
private def awardCls(t: Trophy) = cls := s"trophy award ${t.kind._id} ${~t.kind.klass}"
|
||||
|
||||
private def zugMiracleTrophy(t: Trophy) = frag(
|
||||
styleTag("""
|
||||
.trophy.zugMiracle {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
height: 40px;
|
||||
margin: 0 8px!important;
|
||||
transition: 2s;
|
||||
}
|
||||
.trophy.zugMiracle img { height: 60px; }
|
||||
@keyframes psyche { 100% { filter: hue-rotate(360deg); } }
|
||||
.trophy.zugMiracle:hover {
|
||||
transform: translateY(-9px);
|
||||
animation: psyche 0.3s ease-in-out infinite alternate;
|
||||
}"""),
|
||||
a(awardCls(t), href := t.kind.url, ariaTitle(t.kind.name))(
|
||||
img(src := assetUrl("images/trophy/zug-trophy.png"))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -13,15 +13,12 @@ final class TrophyApi(
|
|||
cacheApi: CacheApi
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
private val trophyKindObjectBSONHandler = Macros.handler[TrophyKind]
|
||||
implicit private val trophyKindObjectBSONHandler = Macros.handler[TrophyKind]
|
||||
|
||||
val kindCache = cacheApi.sync[String, TrophyKind](
|
||||
name = "trophy.kind",
|
||||
initialCapacity = 32,
|
||||
compute = id =>
|
||||
kindColl.byId(id)(trophyKindObjectBSONHandler) map { k =>
|
||||
k.getOrElse(TrophyKind.Unknown)
|
||||
},
|
||||
compute = id => kindColl.byId[TrophyKind](id).dmap(_ | TrophyKind.Unknown),
|
||||
default = _ => TrophyKind.Unknown,
|
||||
strategy = Syncache.WaitAfterUptime(20 millis),
|
||||
expireAfter = Syncache.ExpireAfterWrite(1 hour)
|
||||
|
@ -35,7 +32,13 @@ final class TrophyApi(
|
|||
def findByUser(user: User, max: Int = 50): Fu[List[Trophy]] =
|
||||
coll.list[Trophy]($doc("user" -> user.id), max).map(_.filter(_.kind != TrophyKind.Unknown))
|
||||
|
||||
def roleBasedTrophies(user: User, isPublicMod: Boolean, isDev: Boolean, isVerified: Boolean, isCreator: Boolean): List[Trophy] =
|
||||
def roleBasedTrophies(
|
||||
user: User,
|
||||
isPublicMod: Boolean,
|
||||
isDev: Boolean,
|
||||
isVerified: Boolean,
|
||||
isCreator: Boolean
|
||||
): List[Trophy] =
|
||||
List(
|
||||
isPublicMod option Trophy(
|
||||
_id = "",
|
||||
|
|
Loading…
Reference in New Issue