event details page
parent
d42bcd145f
commit
33e0c591a1
|
@ -15,6 +15,12 @@ object Event extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def show(id: String) = Open { implicit ctx =>
|
||||
OptionOk(api oneEnabled id) { event =>
|
||||
html.event.show(event)
|
||||
}
|
||||
}
|
||||
|
||||
def manager = Secure(_.ManageEvent) { implicit ctx =>
|
||||
me =>
|
||||
api.list map { events =>
|
||||
|
|
|
@ -27,7 +27,10 @@ trait StringHelper { self: NumberHelper =>
|
|||
|
||||
def pluralize(s: String, n: Int) = "%d %s%s".format(n, s, if (n > 1) "s" else "")
|
||||
|
||||
def autoLink(text: String) = Html { (nl2br _ compose addUserProfileLinks _ compose addLinks _ compose escape _)(text) }
|
||||
private val autoLinkFun: String => String =
|
||||
nl2br _ compose addUserProfileLinks _ compose addLinks _ compose escape _
|
||||
|
||||
def autoLink(text: String) = Html { autoLinkFun(text) }
|
||||
|
||||
// the replace quot; -> " is required
|
||||
// to avoid issues caused by addLinks
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
}
|
||||
|
||||
@markdown(field: Field, name: Html) = {
|
||||
@textarea(field: Field, name: Html) = {
|
||||
@group(field, name, largeLabel = true) {
|
||||
<textarea name="@field.name" id="@field.id">@field.value</textarea>
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ evenMoreCss = Some(cssTag("material.form.css"))) {
|
|||
@group(form("profile.headline"), Html("Short and inspiring headline")) {
|
||||
@base.input(form("profile.headline"))
|
||||
}
|
||||
@markdown(form("profile.description"), Html("Who are you? <em>age, profession, country... let your students know you</em>"))
|
||||
@markdown(form("profile.playingExperience"), Html("Playing experience <em>tournaments played, best wins, other achievements</em>"))
|
||||
@markdown(form("profile.teachingExperience"), Html("Teaching experience <em>diplomas, years of practice, best student results</em>"))
|
||||
@markdown(form("profile.otherExperience"), Html("Other experiences <em>e.g. as chess commentator, or teaching other domains</em>"))
|
||||
@markdown(form("profile.skills"), Html("Best skills in chess and teaching"))
|
||||
@markdown(form("profile.methodology"), Html("Teaching methodology <em>How you prepare and run lessons. How you follow up with students.</em>"))
|
||||
@textarea(form("profile.description"), Html("Who are you? <em>age, profession, country... let your students know you</em>"))
|
||||
@textarea(form("profile.playingExperience"), Html("Playing experience <em>tournaments played, best wins, other achievements</em>"))
|
||||
@textarea(form("profile.teachingExperience"), Html("Teaching experience <em>diplomas, years of practice, best student results</em>"))
|
||||
@textarea(form("profile.otherExperience"), Html("Other experiences <em>e.g. as chess commentator, or teaching other domains</em>"))
|
||||
@textarea(form("profile.skills"), Html("Best skills in chess and teaching"))
|
||||
@textarea(form("profile.methodology"), Html("Teaching methodology <em>How you prepare and run lessons. How you follow up with students.</em>"))
|
||||
<div class="button-container">
|
||||
<button type="submit" class="submit button text" data-icon="E">Save now</button>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@(e: lila.event.Event)(implicit ctx: Context)
|
||||
|
||||
<a href="@e.url" class="tour_spotlight event_spotlight id_@e.id@if(e.isNowOrSoon){ invert}">
|
||||
<a href="@{if(e.isNow) e.url else routes.Event.show(e.id)}"
|
||||
class="tour_spotlight event_spotlight id_@e.id@if(e.isNowOrSoon){ invert}">
|
||||
<i class="img" data-icon=""></i>
|
||||
<span class="content">
|
||||
<span class="name">@e.title</span>
|
||||
|
|
|
@ -14,12 +14,17 @@
|
|||
@group(form("finishesAt"), Html("End date <strong>UTC</strong>"), half = true) {
|
||||
@base.flatpickr(form("finishesAt"))
|
||||
}
|
||||
@group(form("title"), Html("Title")) {
|
||||
@group(form("title"), Html("Short title")) {
|
||||
@base.input(form("title"))
|
||||
}
|
||||
@group(form("headline"), Html("Headline")) {
|
||||
@group(form("headline"), Html("Short headline")) {
|
||||
@base.input(form("headline"))
|
||||
}
|
||||
@defining(form("description")) { field =>
|
||||
@group(field, Html("Possibly long description")) {
|
||||
<textarea name="@field.name" id="@field.id">@field.value</textarea>
|
||||
}
|
||||
}
|
||||
@group(form("url"), Html("External URL")) {
|
||||
@base.input(form("url"))
|
||||
}
|
||||
|
|
|
@ -18,18 +18,18 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@events.map { event =>
|
||||
@events.map { e =>
|
||||
<tr>
|
||||
<td><a href="@routes.Event.edit(event.id)">@event.title</a></td>
|
||||
<td><a href="@routes.Event.edit(e.id)">@e.title</a></td>
|
||||
<td>
|
||||
@showDateTimeUTC(event.startsAt)
|
||||
@momentFromNow(event.startsAt)
|
||||
@showDateTimeUTC(e.startsAt)
|
||||
@momentFromNow(e.startsAt)
|
||||
</td>
|
||||
<td>
|
||||
@showDateTimeUTC(event.finishesAt)
|
||||
@momentFromNow(event.finishesAt)
|
||||
@showDateTimeUTC(e.finishesAt)
|
||||
@momentFromNow(e.finishesAt)
|
||||
</td>
|
||||
<td><a class="text"href="@event.url" data-icon="v">URL</a></td>
|
||||
<td><a class="text"href="@routes.Event.show(e.id)" data-icon="v"></a></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
@(e: lila.event.Event)(implicit ctx: Context)
|
||||
|
||||
@base.layout(
|
||||
title = e.title,
|
||||
moreCss = cssTag("event.css")) {
|
||||
<div id="event" class="content_box small_box">
|
||||
<h1 data-icon="" class="text">@e.title</h1>
|
||||
<h2 class="headline">
|
||||
@e.headline
|
||||
</h2>
|
||||
<p class="when">
|
||||
@if(e.isNow) {
|
||||
<a href="@e.url" class="button">@trans.playingRightNow()</a>
|
||||
} else { @momentFromNow(e.startsAt) }
|
||||
</p>
|
||||
@e.description.map { d =>
|
||||
<p class="desc">@autoLink(d)</p>
|
||||
}
|
||||
</div>
|
||||
}
|
|
@ -432,6 +432,7 @@ GET /api/status controllers.Api.status
|
|||
|
||||
# Events
|
||||
GET /event controllers.Event.index
|
||||
GET /event/$id<\w{8}> controllers.Event.show(id: String)
|
||||
GET /event/manager controllers.Event.manager
|
||||
GET /event/manager/$id<\w{8}> controllers.Event.edit(id: String)
|
||||
POST /event/manager/$id<\w{8}> controllers.Event.update(id: String)
|
||||
|
|
|
@ -8,6 +8,7 @@ case class Event(
|
|||
_id: String,
|
||||
title: String,
|
||||
headline: String,
|
||||
description: Option[String],
|
||||
homepageHours: Int,
|
||||
url: String,
|
||||
enabled: Boolean,
|
||||
|
@ -18,11 +19,13 @@ case class Event(
|
|||
|
||||
def featureSince = startsAt minusHours homepageHours
|
||||
|
||||
def featureNow = featureSince.isBefore(DateTime.now) && !isFinished
|
||||
|
||||
def isFinished = finishesAt.isBefore(DateTime.now)
|
||||
|
||||
def isNow = featureSince.isBefore(DateTime.now) && !isFinished
|
||||
def isNow = startsAt.isBefore(DateTime.now) && !isFinished
|
||||
|
||||
def isNowOrSoon = featureSince.isBefore(DateTime.now minusMinutes 10) && !isFinished
|
||||
def isNowOrSoon = startsAt.isBefore(DateTime.now plusMinutes 10) && !isFinished
|
||||
|
||||
def id = _id
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ final class EventApi(coll: Coll) {
|
|||
"enabled" -> true,
|
||||
"startsAt" $gt DateTime.now.minusDays(1) $lt DateTime.now.plusDays(1)
|
||||
)).sort($doc("startsAt" -> 1)).list[Event](5).map {
|
||||
_.filter(_.isNow)
|
||||
_.filter(_.featureNow)
|
||||
}
|
||||
|
||||
def list = coll.find($empty).sort($doc("startsAt" -> -1)).list[Event](50)
|
||||
|
@ -26,6 +26,8 @@ final class EventApi(coll: Coll) {
|
|||
.sort($doc("startsAt" -> -1))
|
||||
.list[Event](50)
|
||||
|
||||
def oneEnabled(id: String) = coll.byId[Event](id).map(_.filter(_.enabled))
|
||||
|
||||
def one(id: String) = coll.byId[Event](id)
|
||||
|
||||
def editForm(event: Event) = EventForm.form fill {
|
||||
|
|
|
@ -15,6 +15,7 @@ object EventForm {
|
|||
val form = Form(mapping(
|
||||
"title" -> nonEmptyText(minLength = 3, maxLength = 40),
|
||||
"headline" -> nonEmptyText(minLength = 5, maxLength = 30),
|
||||
"description" -> optional(nonEmptyText(minLength = 5, maxLength = 4000)),
|
||||
"homepageHours" -> number(min = 0, max = 24),
|
||||
"url" -> nonEmptyText,
|
||||
"enabled" -> boolean,
|
||||
|
@ -25,6 +26,7 @@ object EventForm {
|
|||
case class Data(
|
||||
title: String,
|
||||
headline: String,
|
||||
description: Option[String],
|
||||
homepageHours: Int,
|
||||
url: String,
|
||||
enabled: Boolean,
|
||||
|
@ -34,6 +36,7 @@ object EventForm {
|
|||
def update(event: Event) = event.copy(
|
||||
title = title,
|
||||
headline = headline,
|
||||
description = description,
|
||||
homepageHours = homepageHours,
|
||||
url = url,
|
||||
enabled = enabled,
|
||||
|
@ -44,6 +47,7 @@ object EventForm {
|
|||
_id = Event.makeId,
|
||||
title = title,
|
||||
headline = headline,
|
||||
description = description,
|
||||
homepageHours = homepageHours,
|
||||
url = url,
|
||||
enabled = enabled,
|
||||
|
@ -58,6 +62,7 @@ object EventForm {
|
|||
def make(event: Event) = Data(
|
||||
title = event.title,
|
||||
headline = event.headline,
|
||||
description = event.description,
|
||||
homepageHours = event.homepageHours,
|
||||
url = event.url,
|
||||
enabled = event.enabled,
|
||||
|
|
|
@ -1,15 +1,34 @@
|
|||
.datatable td {
|
||||
#events .datatable td {
|
||||
padding: 2em!important;
|
||||
}
|
||||
.datatable a {
|
||||
#events .datatable a {
|
||||
color: #3893E8;
|
||||
}
|
||||
.datatable h2 {
|
||||
#events .datatable h2 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.datatable strong {
|
||||
#events .datatable strong {
|
||||
font-weight: normal;
|
||||
}
|
||||
.datatable .date {
|
||||
#events .datatable .date {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#event h2 {
|
||||
font-size: 1.3em;
|
||||
margin-top: 4em;
|
||||
text-align: center;
|
||||
}
|
||||
#event .when {
|
||||
margin-top: 2em;
|
||||
text-align: center;
|
||||
}
|
||||
#event .when .button {
|
||||
display:inline-block;
|
||||
color: #3893E8;
|
||||
padding: 20px 30px;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
#event .desc {
|
||||
margin-top: 4em;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue