diff --git a/.idea/.idea.c3stream/.idea/contentModel.xml b/.idea/.idea.c3stream/.idea/contentModel.xml index 40115c0..6cd4556 100644 --- a/.idea/.idea.c3stream/.idea/contentModel.xml +++ b/.idea/.idea.c3stream/.idea/contentModel.xml @@ -12,6 +12,9 @@ + + + @@ -29,12 +32,12 @@ - - + + diff --git a/Pages/Conference.cshtml b/Pages/Conference.cshtml index da9e70c..0ca296f 100644 --- a/Pages/Conference.cshtml +++ b/Pages/Conference.cshtml @@ -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 @@ } - + @if (isWatched) { diff --git a/Pages/Description.cshtml b/Pages/Description.cshtml deleted file mode 100644 index bea30b8..0000000 --- a/Pages/Description.cshtml +++ /dev/null @@ -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 = "<missing description>"; - } -} -

@title - @speakers

-

- @Html.Raw(description.Replace("\n", "
").Replace("

", "").Replace("

", "")) -

\ No newline at end of file diff --git a/Pages/Description.cshtml.cs b/Pages/Description.cshtml.cs deleted file mode 100644 index e3d4358..0000000 --- a/Pages/Description.cshtml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; - -namespace c3stream.Pages { - public class DescriptionModel : PageModel { - private readonly ILogger _logger; - - public DescriptionModel(ILogger logger) => _logger = logger; - - public void OnGet() { } - } -} \ No newline at end of file diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml index 94af6ef..27ba47f 100644 --- a/Pages/Index.cshtml +++ b/Pages/Index.cshtml @@ -17,7 +17,7 @@

Welcome to c3stream!

Your bookmark link:
- https://@Request.Host.Value?bookmark=@HttpContext.Session.GetString("bookmark")

+ https://@Request.Host.Value?bookmark=@HttpContext.Session.GetString("bookmark")

36c3 35c3 diff --git a/Pages/Info.cshtml b/Pages/Info.cshtml new file mode 100644 index 0000000..d1f90c5 --- /dev/null +++ b/Pages/Info.cshtml @@ -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 = "<missing description>"; + } + + 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("-", "-
"); + + 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) { +

@title - @speakers

+} +else if (isMarked) { +

@title - @speakers

+} +else { +

@title - @speakers

+} + +
+ + + + @if (file != null) { + + + + } + else { + + + + } + @if (isWatched) { + + + } + else if (isMarked) { + + + } + else { + + + } +
+ +

+ @Html.Raw(description.Replace("\n", "
").Replace("

", "").Replace("

", "")) +

+ +Share this talk:
+https://@Request.Host.Value/Info?guid=@Request.Query["guid"] \ No newline at end of file diff --git a/Pages/Info.cshtml.cs b/Pages/Info.cshtml.cs new file mode 100644 index 0000000..3b8a73f --- /dev/null +++ b/Pages/Info.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Logging; + +namespace c3stream.Pages { + public class InfoModel : PageModel { + private readonly ILogger _logger; + + public InfoModel(ILogger logger) => _logger = logger; + + public void OnGet() { } + } +} \ No newline at end of file diff --git a/wwwroot/js/site.js b/wwwroot/js/site.js index 708b846..99873cf 100644 --- a/wwwroot/js/site.js +++ b/wwwroot/js/site.js @@ -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() }); \ No newline at end of file