aboutsummaryrefslogtreecommitdiffstats
path: root/src/Pages
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-12-02 04:04:42 +0100
committerivarlovlie <git@ivarlovlie.no>2022-12-02 04:04:42 +0100
commit623a45d1ec1f7e636defd139b35b615b1a64af91 (patch)
tree0e5c2d5f1e96cd6f4adb305ed3f35dd02f2485ee /src/Pages
parenta453135b470565c56df2fd319dc927db67e299c6 (diff)
downloadlettnytt-623a45d1ec1f7e636defd139b35b615b1a64af91.tar.xz
lettnytt-623a45d1ec1f7e636defd139b35b615b1a64af91.zip
feat: !WIP nrk radio
Diffstat (limited to 'src/Pages')
-rw-r--r--src/Pages/Index.cshtml82
-rw-r--r--src/Pages/Index.cshtml.cs10
-rw-r--r--src/Pages/NrkRadio.cshtml12
-rw-r--r--src/Pages/NrkRadio.cshtml.cs13
-rw-r--r--src/Pages/Shared/_Layout.cshtml7
5 files changed, 73 insertions, 51 deletions
diff --git a/src/Pages/Index.cshtml b/src/Pages/Index.cshtml
index 0501e3e..076e4f6 100644
--- a/src/Pages/Index.cshtml
+++ b/src/Pages/Index.cshtml
@@ -26,62 +26,64 @@
</small>
</p>
</footer>
- @section scripts {
- <script>
+@section scripts {
+ <script>
const ignoreSessionStorageKey = "frontpage_ignores";
function hide_article(el) {
const linkEl = el.closest(".news-link");
const ignoreLink = new URL(linkEl.querySelector("a").href).searchParams.get("url");
- const currentIgnores = sessionStorage.getItem(ignoreSessionStorageKey);
+ const currentIgnores = localStorage.getItem(ignoreSessionStorageKey);
let newIgnores = [];
if (currentIgnores) newIgnores = JSON.parse(currentIgnores);
newIgnores.push(ignoreLink)
- sessionStorage.setItem(ignoreSessionStorageKey, JSON.stringify(newIgnores));
+ localStorage.setItem(ignoreSessionStorageKey, JSON.stringify(newIgnores));
linkEl.remove()
}
- const ignores = sessionStorage.getItem(ignoreSessionStorageKey)
+ const ignores = localStorage.getItem(ignoreSessionStorageKey)
if (ignores) {
for (const ignore of JSON.parse(ignores)) {
- console.log(ignore)
- document.querySelector("a[href*='"+ignore+"']").closest(".news-link").remove();
+ document.querySelector("a[href*='" + ignore + "']").closest(".news-link").remove();
}
}
</script>
- }
- } else if (Model.Article != default) {
- <div id="art-header" style="display: flex; justify-content: space-between">
- <div>
- <h1>@Model.Article.Title</h1>
- <p>@Model.Article.Subtitle</p>
- </div>
- </div>
+}} else if (Model.Article != default) {
+ <details>
+ <summary>Detaljer</summary>
+ <div style="flex-direction:column">
+ @foreach (var author in Model.Article.Authors) {
+ <small style="white-space: nowrap"><b>@author.Name</b>: @author.Title</small>
+ <br/>
+ }
+ </div>
+ <div style="flex-direction: column">
+ @if (Model.Article.PublishedAt != default) {
+ <small style="white-space: nowrap">Publisert: @Model.Article.PublishedAt.ToString("dd-MM-yyyy hh:mm:ss")</small>
+ }
+ @if (Model.Article.UpdatedAt != default) {
+ <br/>
+ <small style="white-space: nowrap">Oppdatert: @Model.Article.UpdatedAt.ToString("dd-MM-yyyy hh:mm:ss")</small>
+ }
+ <br/>
+ <small>
+ <a href="@Model.Article.Href" no-interception>Les på nrk.no</a>
+ </small>
+ </div>
+ </details>
+ <div id="art-header" style="display: flex; justify-content: space-between">
+ <div>
+ <h1>@Model.Article.Title</h1>
+ <p>@Model.Article.Subtitle</p>
+ </div>
+ </div>
- <article id="art-body">
- @Html.Raw(Model.Article.Content)
- </article>
+ <article id="art-body">
+ @Html.Raw(Model.Article.Content)
+ </article>
- <footer>
- <div style="flex-direction:column">
- @foreach (var author in Model.Article.Authors) {
- <small style="white-space: nowrap"><b>@author.Name</b>: @author.Title</small>
- <br/>
- }
- </div>
- <div style="flex-direction: column">
- @if (Model.Article.PublishedAt != default) {
- <small style="white-space: nowrap">Publisert: @Model.Article.PublishedAt.ToString("dd-MM-yyyy hh:mm:ss")</small>
- }
- @if (Model.Article.UpdatedAt != default) {
- <br/>
- <small style="white-space: nowrap">Oppdatert: @Model.Article.UpdatedAt.ToString("dd-MM-yyyy hh:mm:ss")</small>
- }
- <br/>
- <small>
- <a href="@Model.Article.Href" no-interception>Les på nrk.no</a>
- </small>
- </div>
- </footer>
+ <footer>
+
+ </footer>
@section scripts {
<script>
@@ -91,4 +93,4 @@
});
})
</script>
-}} \ No newline at end of file
+} } \ No newline at end of file
diff --git a/src/Pages/Index.cshtml.cs b/src/Pages/Index.cshtml.cs
index 666c75e..bea663d 100644
--- a/src/Pages/Index.cshtml.cs
+++ b/src/Pages/Index.cshtml.cs
@@ -6,11 +6,11 @@ namespace I2R.LightNews.Pages;
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
- private readonly GrabberService _grabber;
+ private readonly NrkNewsService _nrkNews;
- public IndexModel(ILogger<IndexModel> logger, GrabberService grabber) {
+ public IndexModel(ILogger<IndexModel> logger, NrkNewsService nrkNews) {
_logger = logger;
- _grabber = grabber;
+ _nrkNews = nrkNews;
}
public NewsSource FrontPage { get; set; }
@@ -25,7 +25,7 @@ public class IndexModel : PageModel
if (url.IsNullOrWhiteSpace()) {
FrontPage = site switch {
- "nrk" => await _grabber.GrabNrkAsync(),
+ "nrk" => await _nrkNews.GrabNrkAsync(),
_ => default
};
@@ -34,7 +34,7 @@ public class IndexModel : PageModel
}
} else {
Article = site switch {
- "nrk" => await _grabber.GrabNrkArticleAsync(url),
+ "nrk" => await _nrkNews.GrabNrkArticleAsync(url),
_ => default
};
diff --git a/src/Pages/NrkRadio.cshtml b/src/Pages/NrkRadio.cshtml
new file mode 100644
index 0000000..4679c0f
--- /dev/null
+++ b/src/Pages/NrkRadio.cshtml
@@ -0,0 +1,12 @@
+@page "/nrk-radio"
+@model I2R.LightNews.Pages.NrkRadio
+@{
+ Layout = "_Layout";
+}
+
+<aside id="app-data" style="display: none" aria-hidden="true" data-json="@(Model.FrontPageDataJSON)"></aside>
+<div id="app"></div>
+
+@section Scripts {
+ <script asp-append-version="true" src="~/radio.js"></script>
+} \ No newline at end of file
diff --git a/src/Pages/NrkRadio.cshtml.cs b/src/Pages/NrkRadio.cshtml.cs
new file mode 100644
index 0000000..f536c19
--- /dev/null
+++ b/src/Pages/NrkRadio.cshtml.cs
@@ -0,0 +1,13 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
+namespace I2R.LightNews.Pages;
+
+public class NrkRadio : PageModel
+{
+ public string FrontPageDataJSON { get; set; }
+
+ public ActionResult OnGet() {
+ return Page();
+ }
+} \ No newline at end of file
diff --git a/src/Pages/Shared/_Layout.cshtml b/src/Pages/Shared/_Layout.cshtml
index c3ca817..d9022fc 100644
--- a/src/Pages/Shared/_Layout.cshtml
+++ b/src/Pages/Shared/_Layout.cshtml
@@ -12,12 +12,7 @@
<nav>
<div class="left">
<a href="/nrk" class="@(Context.Request.Path.StartsWithSegments("/nrk") ? "active" : "")">NRK</a>
- <a href="/dagbladet" class="@(Context.Request.Path.StartsWithSegments("/dagbladet") ? "active" : "")">Dagbladet</a>
- <a href="/aftenposten" class="@(Context.Request.Path.StartsWithSegments("/aftenposten") ? "active" : "")">Aftenposten</a>
- <a href="/vg" class="@(Context.Request.Path.StartsWithSegments("/vg") ? "active" : "")">VG</a>
- <a href="/dn" class="@(Context.Request.Path.StartsWithSegments("/dn") ? "active" : "")">DN</a>
- <a href="/e24" class="@(Context.Request.Path.StartsWithSegments("/e24") ? "active" : "")">E24</a>
- <a href="/kode24" class="@(Context.Request.Path.StartsWithSegments("/kode24") ? "active" : "")">Kode 24</a>
+ <a href="/nrk-radio" class="@(Context.Request.Path.StartsWithSegments("/nrk-radio") ? "active" : "")">NRK Radio</a>
</div>
<div class="right">
<a href="/om" class="@(Context.Request.Path.StartsWithSegments("/om") ? "active" : "")">Om lettnytt</a>