Compare commits
8 Commits
e939174040
...
9d46d6495e
Author | SHA1 | Date | |
---|---|---|---|
9d46d6495e | |||
d6c24d80c1 | |||
74e7187cba | |||
8dd4468c1a | |||
dcbc402bfb | |||
cf615e1e81 | |||
086a8a665c | |||
cf2a5c2ffb |
@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ts", "ts", "{BB9F76AC-292A-
|
|||||||
src\ts\Author.ts = src\ts\Author.ts
|
src\ts\Author.ts = src\ts\Author.ts
|
||||||
src\ts\TimeUtility.ts = src\ts\TimeUtility.ts
|
src\ts\TimeUtility.ts = src\ts\TimeUtility.ts
|
||||||
src\ts\UI.ts = src\ts\UI.ts
|
src\ts\UI.ts = src\ts\UI.ts
|
||||||
|
src\ts\Input.ts = src\ts\Input.ts
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
@ -29,7 +29,6 @@ public sealed class BlogApiController : ControllerBase
|
|||||||
if (take == -1) take = _blogService.AllPosts.Count;
|
if (take == -1) take = _blogService.AllPosts.Count;
|
||||||
|
|
||||||
var referer = Request.Headers["Referer"].ToString();
|
var referer = Request.Headers["Referer"].ToString();
|
||||||
Console.WriteLine($"Referer: {referer}");
|
|
||||||
if (!referer.StartsWith(Url.PageLink("/Blog/Index")!))
|
if (!referer.StartsWith(Url.PageLink("/Blog/Index")!))
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
@ -51,9 +50,9 @@ public sealed class BlogApiController : ControllerBase
|
|||||||
url = Url.Page("/Blog/Article",
|
url = Url.Page("/Blog/Article",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
year = post.Published.Year,
|
year = post.Published.ToString("yyyy"),
|
||||||
month = post.Published.Month,
|
month = post.Published.ToString("MM"),
|
||||||
day = post.Published.Day,
|
day = post.Published.ToString("dd"),
|
||||||
slug = post.Slug
|
slug = post.Slug
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
||||||
<PackageReference Include="Markdig" Version="0.32.0"/>
|
<PackageReference Include="Markdig" Version="0.32.0"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.9"/>
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.9"/>
|
||||||
<PackageReference Include="NLog" Version="5.2.3"/>
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.3"/>
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.3"/>
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0"/>
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0"/>
|
||||||
<PackageReference Include="SmartFormat.NET" Version="3.2.2"/>
|
<PackageReference Include="SmartFormat.NET" Version="3.2.2"/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using Markdig;
|
using Markdig;
|
||||||
using Markdig.Extensions.MediaLinks;
|
using NLog;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using OliverBooth.Data;
|
using OliverBooth.Data;
|
||||||
using OliverBooth.Markdown;
|
using OliverBooth.Markdown;
|
||||||
@ -53,3 +53,5 @@ app.MapRazorPages();
|
|||||||
app.MapRssFeed("/blog/feed");
|
app.MapRssFeed("/blog/feed");
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
|
LogManager.Shutdown();
|
||||||
|
33
src/ts/Input.ts
Normal file
33
src/ts/Input.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
class Input {
|
||||||
|
public static readonly KONAMI_CODE = [
|
||||||
|
"ArrowUp",
|
||||||
|
"ArrowUp",
|
||||||
|
"ArrowDown",
|
||||||
|
"ArrowDown",
|
||||||
|
"ArrowLeft",
|
||||||
|
"ArrowRight",
|
||||||
|
"ArrowLeft",
|
||||||
|
"ArrowRight",
|
||||||
|
"b",
|
||||||
|
"a",
|
||||||
|
"Enter"
|
||||||
|
];
|
||||||
|
|
||||||
|
public static registerShortcut(shortcut: string | string[], callback: Function) {
|
||||||
|
let keys: string[];
|
||||||
|
if (typeof shortcut === 'string') keys = shortcut.split(' ');
|
||||||
|
else keys = shortcut;
|
||||||
|
|
||||||
|
let sequence: string[] = [];
|
||||||
|
document.addEventListener('keydown', e => {
|
||||||
|
sequence.push(e.key);
|
||||||
|
|
||||||
|
if (sequence.slice(-keys.length).join(' ') === keys.join(' ')) {
|
||||||
|
callback();
|
||||||
|
sequence = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Input;
|
@ -193,6 +193,11 @@ class UI {
|
|||||||
element = element || document.body;
|
element = element || document.body;
|
||||||
element.querySelectorAll("pre code").forEach((block) => {
|
element.querySelectorAll("pre code").forEach((block) => {
|
||||||
let content = block.innerHTML;
|
let content = block.innerHTML;
|
||||||
|
|
||||||
|
// but ugly fucking hack. I hate this
|
||||||
|
content = content.replaceAll('<span class="token operator"><</span>mark<span class="token operator">></span>', "<mark>");
|
||||||
|
content = content.replaceAll('<span class="token operator"><</span><span class="token operator">/</span>mark<span class="token operator">></span>', "</mark>");
|
||||||
|
|
||||||
content = content.replaceAll("<mark>", "<mark>");
|
content = content.replaceAll("<mark>", "<mark>");
|
||||||
content = content.replaceAll("</mark>", "</mark>");
|
content = content.replaceAll("</mark>", "</mark>");
|
||||||
block.innerHTML = content;
|
block.innerHTML = content;
|
||||||
|
@ -1,9 +1,29 @@
|
|||||||
import API from "./API";
|
import API from "./API";
|
||||||
import UI from "./UI";
|
import UI from "./UI";
|
||||||
|
import Input from "./Input";
|
||||||
|
|
||||||
|
const pkg = require("../../package.json");
|
||||||
|
|
||||||
declare const Handlebars: any;
|
declare const Handlebars: any;
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
|
let isCtrl = false;
|
||||||
|
document.addEventListener('keyup', (e) => {
|
||||||
|
if (e.ctrlKey) isCtrl = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.ctrlKey) isCtrl = true;
|
||||||
|
if (isCtrl && e.key === "u") {
|
||||||
|
window.open(pkg.repository.url, "_blank");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Input.registerShortcut(Input.KONAMI_CODE, () => {
|
||||||
|
window.open("https://www.youtube.com/watch?v=dQw4w9WgXcQ", "_blank");
|
||||||
|
});
|
||||||
|
|
||||||
const blogPostContainer = UI.blogPostContainer;
|
const blogPostContainer = UI.blogPostContainer;
|
||||||
if (blogPostContainer) {
|
if (blogPostContainer) {
|
||||||
const template = Handlebars.compile(UI.blogPostTemplate.innerHTML);
|
const template = Handlebars.compile(UI.blogPostTemplate.innerHTML);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["ES2022", "DOM"],
|
"lib": ["ES2022", "DOM"],
|
||||||
"target": "ES2022"
|
"target": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user