Compare commits

..

No commits in common. "4e032c3aa5bc73000cfe8c8fd10eae0c6f24f9e7" and "26b022f7ba3190fa3bdc38a3b5604581b5452b4c" have entirely different histories.

6 changed files with 26 additions and 91 deletions

View File

@ -1,2 +0,0 @@
@page "/blog/{year:int}/{month:int}/{day:int}/{slug}/raw"
@model OliverBooth.Pages.Blog.RawArticle

View File

@ -1,52 +0,0 @@
using Cysharp.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using OliverBooth.Data.Blog;
using OliverBooth.Services;
namespace OliverBooth.Pages.Blog;
/// <summary>
/// Represents the page model for the <c>RawArticle</c> page.
/// </summary>
public class RawArticle : PageModel
{
private readonly BlogService _blogService;
/// <summary>
/// Initializes a new instance of the <see cref="RawArticle" /> class.
/// </summary>
/// <param name="blogService">The <see cref="BlogService" />.</param>
public RawArticle(BlogService blogService)
{
_blogService = blogService;
}
/// <summary>
/// Gets the requested blog post.
/// </summary>
/// <value>The requested blog post.</value>
public BlogPost Post { get; private set; } = null!;
public IActionResult OnGet(int year, int month, int day, string slug)
{
if (!_blogService.TryGetBlogPost(year, month, day, slug, out BlogPost? post))
{
Response.StatusCode = 404;
return NotFound();
}
using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder();
builder.AppendLine("# " + post.Title);
if (_blogService.TryGetAuthor(post, out Author? author))
builder.AppendLine($"Author: {author.Name}");
builder.AppendLine($"Published: {post.Published:R}");
if (post.Updated.HasValue)
builder.AppendLine($"Updated: {post.Updated:R}");
builder.AppendLine();
builder.AppendLine(post.Body);
return Content(builder.ToString(), "text/plain");
}
}

View File

@ -59,11 +59,7 @@
<footer class="footer text-muted"> <footer class="footer text-muted">
<div class="container text-center"> <div class="container text-center">
&copy; @DateTime.UtcNow.Year &copy; @DateTime.UtcNow.Year &bullet; <a asp-area="" asp-page="/privacy/index">Privacy</a>
&bullet;
<a asp-area="" asp-page="/privacy/index">Privacy</a>
&bullet;
<a href="https://mastodon.olivr.me/@@oliver" rel="me">Mastodon</a>
</div> </div>
</footer> </footer>

View File

@ -16,11 +16,19 @@ builder.Services.AddSingleton<ConfigurationService>();
builder.Services.AddSingleton<TemplateService>(); builder.Services.AddSingleton<TemplateService>();
builder.Services.AddSingleton(provider => new MarkdownPipelineBuilder() builder.Services.AddSingleton(provider => new MarkdownPipelineBuilder()
.Use(new TemplateExtension(provider.GetRequiredService<TemplateService>())) .UseAbbreviations()
.UseAdvancedExtensions() .UseAdvancedExtensions()
.UseBootstrap() .UseBootstrap()
.UseEmojiAndSmiley() .UseCitations()
.UseSmartyPants() .UseDiagrams()
.UseFigures()
.UseFooters()
.UseFootnotes()
.UseGlobalization()
.UseMathematics()
.UseAutoIdentifiers()
.UseAutoLinks()
.Use(new TemplateExtension(provider.GetRequiredService<TemplateService>()))
.Build()); .Build());
builder.Services.AddDbContextFactory<BlogContext>(); builder.Services.AddDbContextFactory<BlogContext>();

View File

@ -136,18 +136,6 @@ nav {
} }
article { article {
background: #333333;
padding: 20px;
*:last-child {
margin-bottom: 0;
}
blockquote {
border-left: 2px solid #f03;
padding-left: 10px;
}
p > img.img-fluid { p > img.img-fluid {
text-align: center; text-align: center;
} }
@ -161,11 +149,6 @@ article {
font-size: 32px; font-size: 32px;
margin: 50px 0; margin: 50px 0;
} }
abbr {
text-decoration: none;
border-bottom: 1px dotted #ffffff;
}
} }
.blog-card { .blog-card {
@ -174,11 +157,6 @@ article {
&:hover { &:hover {
transform: scale(1.05); transform: scale(1.05);
} }
article {
background: none;
padding: 0;
}
} }
pre { pre {
@ -202,6 +180,11 @@ code[class*="language-"] {
color-scheme: light; color-scheme: light;
} }
article blockquote {
border-left: 2px solid #f03;
padding-left: 10px;
}
div.alert *:last-child { div.alert *:last-child {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }

View File

@ -26,12 +26,14 @@ declare const katex: any;
const list = document.querySelectorAll('[data-bs-toggle="tooltip"]'); const list = document.querySelectorAll('[data-bs-toggle="tooltip"]');
list.forEach((el: Element) => new bootstrap.Tooltip(el)); list.forEach((el: Element) => new bootstrap.Tooltip(el));
const tex = document.getElementsByClassName("math"); window.onload = function () {
Array.prototype.forEach.call(tex, function (el) { const tex = document.getElementsByClassName("math");
let content = el.textContent.trim(); Array.prototype.forEach.call(tex, function (el) {
if (content.startsWith("\\[")) content = content.slice(2); let content = el.textContent.trim();
if (content.endsWith("\\]")) content = content.slice(0, -2); if (content.startsWith("\\[")) content = content.slice(2);
if (content.endsWith("\\]")) content = content.slice(0, -2);
katex.render(content, el); katex.render(content, el);
}); });
};
})(); })();