mirror of
https://github.com/SaphireLattice/quest-reader.git
synced 2026-11-12 18:40:36 -07:00
Get parsing working, and HTML generation from resulting objects
This commit is contained in:
9 files changed
+171
-146
No files matched your search
+16
-20
@@ -3,6 +3,7 @@
|
||||
@using System.Linq
|
||||
@using QuestReader.Models
|
||||
@using QuestReader.Services
|
||||
@using QuestReader.Extensions
|
||||
@inherits StandaloneTemplate<TemplateModel>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -17,7 +18,7 @@
|
||||
var autoDescription = $"Quest single-page archive. Generated {Model.Now} (UTC), {Model.Posts.Count} posts, {Model.Metadata.Chapters.Count} chapters";
|
||||
// A hack, tbh, should be something better instead..
|
||||
var description = Model.Metadata.Description ?? autoDescription;
|
||||
var preview = $"https://media.lunar.exchange{Model.BaseUrl}/{Model.Metadata.SocialPreview}";
|
||||
var preview = $"https://media.lunar.exchange{Model.AssetsPath}/{Model.Metadata.SocialPreview}";
|
||||
}
|
||||
<title>@title</title>
|
||||
<link rel="stylesheet" href="main.css">
|
||||
@@ -57,40 +58,35 @@
|
||||
</header>
|
||||
<main>
|
||||
@{
|
||||
Func<(ThreadPost, bool), object> makePost =
|
||||
@<article id="post-@item.Item1.Id" class="post@(item.Item1 is not null ? " image-post" : "")@(item.Item2 ? "" : " suggestion-post")">
|
||||
@if (item.Item1.Title is not null) {
|
||||
<h2 class="post-self-title">@item.Item1.Title</h2>
|
||||
Func<ThreadPost, object> makePost =
|
||||
@<article id="post-@item.Id" class="post@(item.File is not null ? " image-post" : "")@(item.AuthorPost ? "" : " suggestion-post")" data-postid="@item.Id">
|
||||
@if (item.Title is not null) {
|
||||
<h2 class="post-self-title">@item.Title</h2>
|
||||
}
|
||||
<h3 class="post-header"><a class="post-anchor" href="#post-@item.Item1.Id"><span class="post-anchor-mark">#</span>@item.Item1.Id</a> <span class="author">@item.Item1.Author</span> <time>@item.Item1.Date</time></h3>
|
||||
<h3 class="post-header"><a class="post-anchor" href="#post-@item.Id"><span class="post-anchor-mark">#</span>@item.Id</a> <span class="author">@item.Author</span> <time>@item.Date</time></h3>
|
||||
<div class="post-content">
|
||||
@if (item.Item1.File is not null) {
|
||||
@if (item.File is not null) {
|
||||
<figure class="post-image">
|
||||
<img src="@Model.BaseUrl/@item.Item1.File" alt="@item.Item1.Filename">
|
||||
<img src="@Model.AssetsPath/@item.File" alt="@item.Filename">
|
||||
</figure>
|
||||
}
|
||||
@if (item.Item1.RawHtml.Trim().Length > 0) {
|
||||
<div class="post-text">@Raw(item.Item1.RawHtml)</div>
|
||||
@if (item.RawHtml.Trim().Length > 0) {
|
||||
<div class="post-text">@Raw(item.ParsedContent!.RenderContentHtml(Model))</div>
|
||||
}
|
||||
</div>
|
||||
</article>;
|
||||
</article>
|
||||
;
|
||||
}
|
||||
@foreach (var item in Model.Posts)
|
||||
{
|
||||
@if (item.IsChapterAnnounce) {
|
||||
<h2 id="chapter-@item.Chapter.Id" class="chapter-announce">
|
||||
// This might nullref throw, but let's assume this bool is always set only when this is set too
|
||||
<h2 id="chapter-@item.Chapter!.Id" class="chapter-announce">
|
||||
<a class="chapter-anchor" href="#chapter-@item.Chapter.Id">#</a> <span class="chapter-name">@item.Chapter.Name</span> - <span class="chapter-subtitle">@item.Chapter.Subtitle</span>
|
||||
</h2>
|
||||
}
|
||||
if (item.RepliesTo is not null && item.RepliesTo.Count > 0)
|
||||
{
|
||||
@foreach (var replyId in item.RepliesTo)
|
||||
{
|
||||
@makePost((Model.AllPosts.First(p => p.Id == replyId), false))
|
||||
}
|
||||
}
|
||||
|
||||
@makePost((item, true));
|
||||
@makePost(item);
|
||||
}
|
||||
</main>
|
||||
<footer>
|
||||
|
||||
Reference in new issue
Block a user