Code cleanup
This commit is contained in:
parent
11dc5352cb
commit
46cca10f2e
|
@ -8,8 +8,7 @@ namespace zotanpw_web;
|
|||
public static class Migrations {
|
||||
private const int DbVer = 1;
|
||||
|
||||
private static readonly List<Migration> _migrations = new() {
|
||||
};
|
||||
private static readonly List<Migration> _migrations = new();
|
||||
|
||||
public static void RunMigrations() {
|
||||
using var db = new Database.DbConn();
|
||||
|
|
|
@ -4,19 +4,16 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
|||
|
||||
namespace zotanpw_web.Pages;
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[IgnoreAntiforgeryToken]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true), IgnoreAntiforgeryToken]
|
||||
public class ErrorModel : PageModel {
|
||||
private readonly ILogger<ErrorModel> _logger;
|
||||
|
||||
public ErrorModel(ILogger<ErrorModel> logger) => _logger = logger;
|
||||
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
private readonly ILogger<ErrorModel> _logger;
|
||||
|
||||
public ErrorModel(ILogger<ErrorModel> logger) {
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnGet() {
|
||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||
}
|
||||
|
|
|
@ -158,5 +158,5 @@
|
|||
</ul>
|
||||
|
||||
@section postfooter {
|
||||
<img src="/files/help.svg" height=450rem title="Designed by someone I love, ~fr2">
|
||||
<img src="/files/help.svg" height="450rem" title="Designed by someone I love, ~fr2">
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace zotanpw_web.Pages;
|
||||
|
||||
public class IndexModel : PageModel {
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
|
||||
public IndexModel(ILogger<IndexModel> logger) {
|
||||
_logger = logger;
|
||||
}
|
||||
public IndexModel(ILogger<IndexModel> logger) => _logger = logger;
|
||||
|
||||
public void OnGet() { }
|
||||
}
|
|
@ -3,7 +3,5 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
|||
namespace zotanpw_web.Pages;
|
||||
|
||||
public class NowPlayingModel : PageModel {
|
||||
public void OnGet() {
|
||||
|
||||
}
|
||||
public void OnGet() { }
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
<h1>
|
||||
<a href="/">zotan.pw >> @ViewData["Title"]</a>
|
||||
</h1>
|
||||
@await RenderSectionAsync("head", required: false)
|
||||
@await RenderSectionAsync("head", false)
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
@ -27,9 +27,9 @@
|
|||
</div>
|
||||
|
||||
<div style="text-align: center;">
|
||||
@await RenderSectionAsync("prefooter", required: false)
|
||||
@await RenderSectionAsync("prefooter", false)
|
||||
<p style="color: #666666">--- Served by @Environment.MachineName running <a class="footerlink" href="https://git.ztn.sh/zotan/zotan.pw-web/commit/@Utils.LinkVersion" target="_blank">zotan.pw-web @Utils.Version</a> on .NET @Environment.Version ---</p>
|
||||
@await RenderSectionAsync("postfooter", required: false)
|
||||
@await RenderSectionAsync("postfooter", false)
|
||||
</div>
|
||||
<script src="~/js/site.js"></script>
|
||||
</body>
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<h1 id="posts">Posts</h1>
|
||||
<ul>
|
||||
@foreach (var post in BlogModel.Posts) {
|
||||
<li><strong>@post.PublishedOn.ToString("yyyy-MM-dd")</strong> <a href="/blog/@post.Shorthand">@post.Title</a></li>
|
||||
<li>
|
||||
<strong>@post.PublishedOn.ToString("yyyy-MM-dd")</strong> <a href="/blog/@post.Shorthand">@post.Title</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
|
@ -7,7 +7,7 @@ namespace zotanpw_web.Pages.blog;
|
|||
public class BlogModel : PageModel {
|
||||
public static readonly List<BlogPost> Posts = new() {
|
||||
new BlogPost("adhd-and-notes", "ADHD & Notetaking: an autistic perspective", DateOnly.Parse("2021-08-07")),
|
||||
new BlogPost("ipv6-networking", "IPv6-native networking: a project report", DateOnly.Parse("2021-08-23")),
|
||||
new BlogPost("ipv6-networking", "IPv6-native networking: a project report", DateOnly.Parse("2021-08-23"))
|
||||
};
|
||||
|
||||
static BlogModel() {
|
||||
|
@ -17,11 +17,11 @@ public class BlogModel : PageModel {
|
|||
public void OnGet() { }
|
||||
|
||||
public class BlogPost {
|
||||
public readonly string Title;
|
||||
public readonly string Shorthand;
|
||||
public readonly DateOnly PublishedOn;
|
||||
public int ReadTimeMinutes;
|
||||
public readonly string Shorthand;
|
||||
public readonly string Title;
|
||||
public string Content = "";
|
||||
public int ReadTimeMinutes;
|
||||
|
||||
public BlogPost(string shorthand, string title, DateOnly publishedOn) {
|
||||
Title = title;
|
||||
|
|
|
@ -7,7 +7,8 @@ probably give you answers ranging from "Oh I just have it all in my
|
|||
head" to "Just use a todo list / GTD system / bullet journal", both
|
||||
equally unhelpful to most neurodiverse folks I know.
|
||||
|
||||
Reading [this article](https://xeiaso.net/blog/gtd-on-paper-2021-06-13){target="_blank"} by Xe inspired me to tackle this
|
||||
Reading [this article](https://xeiaso.net/blog/gtd-on-paper-2021-06-13){target="_blank"} by Xe inspired me to tackle
|
||||
this
|
||||
problem for myself. (I highly encourage you to read the linked post
|
||||
along with the rest of their blog)
|
||||
|
||||
|
@ -82,6 +83,7 @@ project, to get something that offers creative freedom close to physical
|
|||
paper, without being convoluted to use.
|
||||
|
||||
### Putting it all together
|
||||
|
||||
So how does my setup look like exactly? Like
|
||||
[this](/files/blog/adhd-and-notes.png){target="_blank"}. Let me
|
||||
explain what you are looking at here. On the left there is a tree view
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
If you have reached this post, chances are you already know my [AS211579](https://zotan.network){target="_blank"} project.
|
||||
If you have reached this post, chances are you already know my [AS211579](https://zotan.network){target="_blank"}
|
||||
project.
|
||||
This post serves as a summary of the things I learnt and the roadblocks
|
||||
I had to overcome on the way to get the network to its current state.
|
||||
|
||||
### Goals and setup
|
||||
|
||||
For those who don't know the project, here's a quick recap. After having
|
||||
dabbled a bit with [DN42](https://dn42.eu){target="_blank"} last year during the first lockdown, I wanted to do the real thing, in
|
||||
dabbled a bit with [DN42](https://dn42.eu){target="_blank"} last year during the first lockdown, I wanted to do the real
|
||||
thing, in
|
||||
the same global routing system your ISP is using to reach this very web
|
||||
server. While this sounds unnecessarily convoluted and complicated to
|
||||
accomplish, it was actually pretty easy and not that expensive. The easy
|
||||
|
|
|
@ -5,8 +5,7 @@ using zotanpw_web.database.Tables;
|
|||
|
||||
namespace zotanpw_web.PlaybackHistory;
|
||||
|
||||
[ApiController]
|
||||
[Route("/np/log")]
|
||||
[ApiController, Route("/np/log")]
|
||||
public class LogPlayback : Controller {
|
||||
private static readonly string Token = System.IO.File.ReadAllLines(".bearer_token")[0];
|
||||
|
||||
|
@ -15,7 +14,7 @@ public class LogPlayback : Controller {
|
|||
var token = Request.Headers.Authorization;
|
||||
if (token == Token) {
|
||||
var db = new Database.DbConn();
|
||||
if (!db.AlbumHistory.Any(p => p.Title == rq.Title && p.Artist == rq.Artist && p.DateTime.Between(DateTime.Now - TimeSpan.FromHours(8), DateTime.Now))) {
|
||||
if (!db.AlbumHistory.Any(p => p.Title == rq.Title && p.Artist == rq.Artist && p.DateTime.Between(DateTime.Now - TimeSpan.FromHours(8), DateTime.Now)))
|
||||
if (!db.AlbumHistory.Any()
|
||||
|| !(db.AlbumHistory.OrderByDescending(p => p.EntryId).First().Artist == rq.Artist
|
||||
&& db.AlbumHistory.OrderByDescending(p => p.EntryId).First().Title == rq.Title)) {
|
||||
|
@ -31,7 +30,6 @@ public class LogPlayback : Controller {
|
|||
Response.StatusCode = 201;
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
Response.StatusCode = 202;
|
||||
return null!;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.Reflection;
|
||||
using LinqToDB.Data;
|
||||
using zotanpw_web;
|
||||
using zotanpw_web.database;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
|
|
|
@ -5,8 +5,7 @@ using zotanpw_web.database.Tables;
|
|||
|
||||
namespace zotanpw_web.Travelynx;
|
||||
|
||||
[ApiController]
|
||||
[Route("/travelynx")]
|
||||
[ApiController, Route("/travelynx")]
|
||||
public class Travelynx : Controller {
|
||||
private static readonly string TravelynxSecret = System.IO.File.ReadAllLines(".bearer_token")[0];
|
||||
|
||||
|
@ -15,9 +14,8 @@ public class Travelynx : Controller {
|
|||
var token = Request.Headers.Authorization;
|
||||
if (token == TravelynxSecret) {
|
||||
var db = new Database.DbConn();
|
||||
if (!db.TravelynxInfo.Any()) {
|
||||
if (!db.TravelynxInfo.Any())
|
||||
db.InsertWithIdentity(new TravelynxInfo { CheckedIn = false });
|
||||
}
|
||||
|
||||
var status = db.TravelynxInfo.First();
|
||||
status.CheckedIn = rq.Status.CheckedIn;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
namespace zotanpw_web.Travelynx {
|
||||
using System.Collections.Generic;
|
||||
namespace zotanpw_web.Travelynx;
|
||||
|
||||
public class WebhookRequest {
|
||||
public string Reason { get; set; }
|
||||
|
@ -40,4 +39,3 @@ namespace zotanpw_web.Travelynx {
|
|||
public string? No { get; set; }
|
||||
public string? Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LinqToDB.Mapping;
|
||||
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace zotanpw_web.database.Tables;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LinqToDB.Mapping;
|
||||
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace zotanpw_web.database.Tables;
|
||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 2 MiB After Width: | Height: | Size: 2.1 MiB |
Loading…
Reference in a new issue