c3stream/Pages/Conference.cshtml

114 lines
5.5 KiB
Plaintext
Raw Normal View History

2020-01-03 15:10:06 +01:00
@page
@model ConferenceModel
@using System.Net
@using static ConferenceModel
@{
2020-01-04 14:23:52 +01:00
if (c3stream.Conferences.All(c => c.Acronym != Request.Query["c"])) {
Response.Redirect("/");
return;
2020-01-03 15:10:06 +01:00
}
2020-12-28 05:04:01 +01:00
c3stream.UpdateCookie(Request, Response, $"/Conference?c={Request.Query["c"]}");
2020-01-04 14:23:52 +01:00
ReadUserData();
2020-01-03 15:10:06 +01:00
ViewData["Title"] = Request.Query["c"];
var wc = new WebClient();
2020-01-04 14:23:52 +01:00
var conference = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]);
if (conference.Ongoing) {
c3stream.UpdateConference(conference);
}
2020-01-03 15:10:06 +01:00
wc.Dispose();
}
<table class="table">
<thead>
<tr>
<th scope="col">Event</th>
<th scope="col">
2020-12-28 05:11:40 +01:00
@Html.Raw(Request.Query["orderby"] == "published" ? $"<a href=\"/Conference?c={Request.Query["c"]}\">Published" : $"<a href=\"/Conference?c={Request.Query["c"]}&orderby=published\">Date")</th>
2020-01-03 15:10:06 +01:00
<th scope="col">Category</th>
<th scope="col">Title</th>
<th scope="col">Speaker(s)</th>
<th scope="col">Lang</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
2020-01-04 14:23:52 +01:00
@foreach (var talk in Request.Query["orderby"] == "published" ? conference.Talks.OrderByDescending(p => p.ReleaseDate) : conference.Talks.OrderBy(p => p.Date)) {
var state = UserData.FirstOrDefault(p => p.TalkId == talk.Guid && p.UserId == Request.Cookies["bookmark"])?.State;
var isWatched = state == "watched";
var isMarked = state == "marked";
var file = $"{talk.Slug}.mp4";
2020-01-04 16:56:40 +01:00
var eventName = talk.Tags.Count <= 1 ? conference.Acronym : talk.Tags[0].Replace("-", "-<br/>");
var category = talk.Tags.Count switch {
0 => "<no category>",
1 => talk.Tags[0],
2 => "<no category>",
3 => talk.Tags[2],
4 => talk.Tags[3],
5 => talk.Tags[3],
2020-12-28 05:25:56 +01:00
6 => talk.Tags[3], // rc3: is this correct?
_ => "<unknown tag format>"
2020-01-03 15:10:06 +01:00
};
<tr>
<td>@Html.Raw(eventName)</td>
<td>@(Request.Query["orderby"] == "published" ? talk.ReleaseDate?.Date.ToShortDateString() : talk.Date?.Date.ToShortDateString())</td>
<td>@category</td>
@if (isWatched) {
2020-01-04 16:43:34 +01:00
<td style="color: #95cb7a">@talk.Title</td>
2020-01-03 15:10:06 +01:00
}
else if (isMarked) {
2020-01-04 16:43:34 +01:00
<td style="color: #da7d4f">@talk.Title</td>
2020-01-03 15:10:06 +01:00
}
else {
<td>@talk.Title</td>
}
<td>@(talk.Persons.Any() ? talk.Persons.Aggregate((s, s1) => $"{s}, {s1}") : "<no speakers>")</td>
2020-01-03 15:10:06 +01:00
<td>@talk.OriginalLanguage</td>
<td>
2020-12-28 05:18:45 +01:00
<div class="btn-group" role="group">
2020-03-24 19:50:55 +01:00
<a href="@talk.FrontendLink.AbsoluteUri" role="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Play">
2020-01-03 15:10:06 +01:00
<i class="fas fa-play-circle"></i>
</a>
2020-01-04 14:23:52 +01:00
@if (System.IO.File.Exists(System.IO.Path.Combine(c3stream.CachePath, conference.Acronym, file))) {
2020-03-24 19:50:55 +01:00
<a href="@(c3stream.CacheUrl + $"{conference.Acronym}/{file}")" role="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Mirror">
2020-01-03 15:10:06 +01:00
<i class="fas fa-cloud-download"></i>
</a>
}
else {
2020-03-24 19:50:55 +01:00
<a href="/" role="button" class="btn btn-primary disabled">
2020-01-03 15:10:06 +01:00
<i class="fas fa-cloud-download"></i>
</a>
}
2020-12-28 05:10:55 +01:00
<a href="/Info?guid=@talk.Guid" role="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Info">
2020-01-03 15:10:06 +01:00
<i class="fas fa-info-circle"></i>
</a>
@if (isWatched) {
<button onclick="SetState('@talk.Guid', 'unwatched')" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Mark unwatched">
<i class="fas fa-times"></i>
</button>
<button class="btn btn-primary disabled">
<i class="fas fa-clock"></i>
</button>
}
else if (isMarked) {
<button onclick="SetState('@talk.Guid', 'watched')" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Mark watched">
<i class="fas fa-check"></i>
</button>
<button onclick="SetState('@talk.Guid', 'unwatched')" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Remove from watch later">
<i class="fas fa-undo-alt"></i>
</button>
}
else {
<button onclick="SetState('@talk.Guid', 'watched')" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Mark watched">
<i class="fas fa-check"></i>
</button>
<button onclick="SetState('@talk.Guid', 'marked')" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Add to watch later">
<i class="fas fa-clock"></i>
</button>
}
</div>
</td>
</tr>
}
</tbody>
</table>