huge info page update

This commit is contained in:
Laura Hausmann 2020-01-03 23:54:46 +01:00
parent 6c5b4fd423
commit 9049976524
Signed by: zotan
GPG key ID: 5EC1D38FFC321311
8 changed files with 156 additions and 48 deletions

View file

@ -12,6 +12,9 @@
<e p="c3stream.csproj" t="IncludeRecursive" />
<e p="c3stream.sln" t="IncludeFlat" />
<e p="data" t="Include">
<e p="33c3.json" t="Include" />
<e p="34c3.json" t="Include" />
<e p="35c3.json" t="Include" />
<e p="_c3stream.json" t="Include" />
</e>
<e p="LICENSE" t="Include" />
@ -29,12 +32,12 @@
<e p="_ViewStart.cshtml" t="Include" />
<e p="Conference.cshtml" t="Include" />
<e p="Conference.cshtml.cs" t="Include" />
<e p="Description.cshtml" t="Include" />
<e p="Description.cshtml.cs" t="Include" />
<e p="Error.cshtml" t="Include" />
<e p="Error.cshtml.cs" t="Include" />
<e p="Index.cshtml" t="Include" />
<e p="Index.cshtml.cs" t="Include" />
<e p="Info.cshtml" t="Include" />
<e p="Info.cshtml.cs" t="Include" />
<e p="Privacy.cshtml" t="Include" />
<e p="Privacy.cshtml.cs" t="Include" />
<e p="Shared" t="Include">

View file

@ -28,7 +28,7 @@
HttpContext.Session.SetString("bookmark", Guid.NewGuid().ToString());
}
if (!Request.Query.ContainsKey("bookmark") || HttpContext.Session.GetString("bookmark") != Request.Query["bookmark"]) {
Response.Redirect("/?bookmark=" + HttpContext.Session.GetString("bookmark") + (Request.Query["orderby"] == "published" ? "&orderby=published" : ""));
Response.Redirect("/Conference?c=" + Request.Query["c"] + "&bookmark=" + HttpContext.Session.GetString("bookmark") + (Request.Query["orderby"] == "published" ? "&orderby=published" : ""));
}
ViewData["Title"] = Request.Query["c"];
@ -102,7 +102,7 @@
<i class="fas fa-cloud-download"></i>
</a>
}
<a href="/Description?bookmark=@Request.Query["bookmark"]&guid=@talk.Guid?.ToString()" target="_blank" type="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Description">
<a href="/Info?guid=@talk.Guid?.ToString()&bookmark=@Request.Query["bookmark"]" target="_blank" type="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="top" title="Info">
<i class="fas fa-info-circle"></i>
</a>
@if (isWatched) {

View file

@ -1,29 +0,0 @@
@page
@model DescriptionModel
@{
ViewData["Title"] = "Description";
}
@{
if (string.IsNullOrWhiteSpace(Request.Query["guid"])) {
Response.Redirect("/");
return;
}
ConferenceModel.ReadEventMetadata();
var talk = ConferenceModel.EventMetadata.FirstOrDefault(p => p.Guid == Request.Query["guid"]);
if (talk == null) {
Response.Redirect("/");
return;
}
var title = talk.Talk.Title;
var speakers = talk.Talk.Persons.Aggregate((s, s1) => $"{s}, {s1}");
var description = talk.Talk.Description;
if (string.IsNullOrEmpty(description)) {
description = "&lt;missing description&gt;";
}
}
<h3>@title - <i>@speakers</i></h3>
<p style="text-align: justify">
@Html.Raw(description.Replace("\n", "<br/>").Replace("<p>", "").Replace("</p>", ""))
</p>

View file

@ -1,12 +0,0 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace c3stream.Pages {
public class DescriptionModel : PageModel {
private readonly ILogger<DescriptionModel> _logger;
public DescriptionModel(ILogger<DescriptionModel> logger) => _logger = logger;
public void OnGet() { }
}
}

View file

@ -17,7 +17,7 @@
<div style="text-align: center">
<h1>Welcome to c3stream!</h1>
Your bookmark link:<br/>
<code>https://@Request.Host.Value?bookmark=@HttpContext.Session.GetString("bookmark")</code><br/><br/>
<code onclick="copyToClipboard(this)">https://@Request.Host.Value?bookmark=@HttpContext.Session.GetString("bookmark")</code><br/><br/>
<div class="btn-group">
<a type="button" class="btn btn-primary" href="/Conference?c=36c3&bookmark=@HttpContext.Session.GetString("bookmark")">36c3</a>
<a type="button" class="btn btn-primary" href="/Conference?c=35c3&bookmark=@HttpContext.Session.GetString("bookmark")">35c3</a>

122
Pages/Info.cshtml Normal file
View file

@ -0,0 +1,122 @@
@page
@using Microsoft.AspNetCore.Http
@model InfoModel
@{
ViewData["Title"] = "Info";
}
@{
if (string.IsNullOrWhiteSpace(Request.Query["guid"])) {
Response.Redirect("/");
return;
}
if (Request.Query.ContainsKey("bookmark") && HttpContext.Session.GetString("bookmark") != Request.Query["bookmark"]) {
HttpContext.Session.SetString("bookmark", Request.Query["bookmark"]);
}
if (!HttpContext.Session.Keys.Contains("bookmark") || !Guid.TryParseExact(HttpContext.Session.GetString("bookmark"), "D", out _)) {
HttpContext.Session.SetString("bookmark", Guid.NewGuid().ToString());
}
if (!Request.Query.ContainsKey("bookmark") || HttpContext.Session.GetString("bookmark") != Request.Query["bookmark"]) {
Response.Redirect("/Info?guid=" + Request.Query["guid"] + "&bookmark=" + HttpContext.Session.GetString("bookmark"));
}
ConferenceModel.ReadEventMetadata();
var talk = ConferenceModel.EventMetadata.FirstOrDefault(p => p.Guid == Request.Query["guid"]);
if (talk == null) {
Response.Redirect("/");
return;
}
var title = talk.Talk.Title;
var speakers = talk.Talk.Persons.Aggregate((s, s1) => $"{s}, {s1}");
var description = talk.Talk.Description;
if (string.IsNullOrEmpty(description)) {
description = "&lt;missing description&gt;";
}
var isWatched = talk.State.FirstOrDefault(q => q.Guid == HttpContext.Session.GetString("bookmark"))?.State == "watched";
var isMarked = talk.State.FirstOrDefault(q => q.Guid == HttpContext.Session.GetString("bookmark"))?.State == "marked";
var file = talk.Talk.Recordings.FirstOrDefault(p => System.IO.File.Exists(System.IO.Path.Combine(c3stream.CachePath, talk.Talk.ConferenceUrl.AbsoluteUri.Split("/").Last(), p.Filename)));
var eventName = talk.Talk.Tags[0].Replace("-", "-<br/>");
int tagFormat;
switch (talk.Talk.ConferenceUrl.AbsoluteUri.Split("/").Last()) {
case "36c3":
tagFormat = 2;
break;
case "35c3":
case "34c3":
tagFormat = 1;
break;
case "33c3":
tagFormat = 0;
break;
default:
Response.Redirect("/");
return;
}
var category = tagFormat switch {
0 => talk.Talk.Tags[0],
1 => talk.Talk.Tags[2],
2 => talk.Talk.Tags[3],
_ => ""
};
}
@if (isWatched) {
<h3 style="color: limegreen">@title - <i>@speakers</i></h3>
}
else if (isMarked) {
<h3 style="color: orangered">@title - <i>@speakers</i></h3>
}
else {
<h3>@title - <i>@speakers</i></h3>
}
<div class="btn-group" role="group" style="margin-bottom: 10px">
<a href="@talk.Talk.FrontendLink.AbsoluteUri" target="_blank" type="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="right" title="Play">
<i class="fas fa-play-circle"></i>
</a>
@if (file != null) {
<a href="@(c3stream.CacheUrl + $"{talk.Talk.ConferenceUrl.AbsoluteUri.Split("/").Last()}/{file.Filename}")" target="_blank" type="button" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="right" title="Mirror">
<i class="fas fa-cloud-download"></i>
</a>
}
else {
<a href="/" target="_blank" type="button" class="btn btn-primary disabled">
<i class="fas fa-cloud-download"></i>
</a>
}
@if (isWatched) {
<button onclick="SetState('@talk.Guid', 'unwatched')" class="btn btn-primary w-100" data-toggle="tooltip" data-placement="left" 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="left" 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="left" 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="left" 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="left" title="Add to watch later">
<i class="fas fa-clock"></i>
</button>
}
</div>
<p style="text-align: justify">
@Html.Raw(description.Replace("\n", "<br/>").Replace("<p>", "").Replace("</p>", ""))
</p>
Share this talk:<br/>
<code onclick="copyToClipboard(this)">https://@Request.Host.Value/Info?guid=@Request.Query["guid"]</code>

12
Pages/Info.cshtml.cs Normal file
View file

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace c3stream.Pages {
public class InfoModel : PageModel {
private readonly ILogger<InfoModel> _logger;
public InfoModel(ILogger<InfoModel> logger) => _logger = logger;
public void OnGet() { }
}
}

View file

@ -3,12 +3,24 @@
// Write your Javascript code.
function SetState(guid, state){
$.get("/Conference?state="+state+"&guid="+guid, function(data, status){
function SetState(guid, state) {
$.get("/Conference?state=" + state + "&guid=" + guid, function (data, status) {
location.reload();
});
}
function copyToClipboard(field) {
let textarea = document.createElement('textarea');
textarea.id = 't';
textarea.style.height = "0";
document.body.appendChild(textarea);
textarea.value = field.innerText;
let selector = document.querySelector('#t');
selector.select();
document.execCommand('copy');
document.body.removeChild(textarea);
}
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});