Compare commits

...

2 commits

Author SHA1 Message Date
Laura Hausmann be1f02e1d9
Fix code style 2022-12-02 04:20:06 +01:00
Laura Hausmann e010feaaba
Refactor 2022-12-02 04:19:01 +01:00
16 changed files with 26 additions and 28 deletions

2
.gitignore vendored
View file

@ -186,4 +186,4 @@ Temporary Items
database.db
.bearer_token
Pages/blog/posts/drafts
Posts/drafts

View file

@ -41,4 +41,4 @@ app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
app.Run();
app.Run();

View file

@ -1,7 +1,7 @@
using System.ServiceModel.Syndication;
using Microsoft.AspNetCore.Mvc;
using zotanpw.Backend;
using zotanpw.Pages.blog;
using zotanpw.Pages;
namespace zotanpw.Controllers;

View file

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using zotanpw.Pages.blog;
using zotanpw.Pages;
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
namespace zotanpw.Controllers;

View file

@ -8,13 +8,13 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace zotanpw.Pages.blog;
namespace zotanpw.Pages;
public class BlogModel : PageModel {
public static readonly List<BlogPost> Posts = new();
static BlogModel() {
foreach (var file in Directory.EnumerateFiles("Pages/blog/posts"))
foreach (var file in Directory.EnumerateFiles("Posts"))
if (file.EndsWith(".md"))
Posts.Add(new BlogPost(Path.GetFileNameWithoutExtension(file)));
@ -37,7 +37,7 @@ public class BlogModel : PageModel {
}
public void UpdateContentAndMetadata() {
var markdownText = System.IO.File.ReadAllText($"Pages/blog/posts/{Shorthand}.md");
var markdownText = System.IO.File.ReadAllText($"Posts/{Shorthand}.md");
var parsed = ParseBlogPost(markdownText);
Title = parsed.metadata.Title!;

View file

@ -1,6 +1,6 @@
@page "/blog/{post}"
@model BlogPostModel
@using zotanpw.Backend
@model BlogPostModel
@{
if (Model.Post == null)

View file

@ -1,20 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace zotanpw.Pages.blog;
namespace zotanpw.Pages;
public class BlogPostModel : PageModel {
public BlogModel.BlogPost? Post;
public IActionResult OnGet() {
if (string.IsNullOrWhiteSpace((string)RouteData.Values["post"]!)) {
if (string.IsNullOrWhiteSpace((string)RouteData.Values["post"]!))
return NotFound();
}
Post = BlogModel.Posts.FirstOrDefault(p => p.Shorthand == (string)RouteData.Values["post"]!);
if (Post == null) {
if (Post == null)
return NotFound();
}
return Page();
}

View file

@ -24,4 +24,4 @@ else {
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
}

View file

@ -25,4 +25,4 @@
</td>
</tr>
}
</table>
</table>

View file

@ -57,4 +57,4 @@
@await RenderSectionAsync("postfooter", false)
</div>
</body>
</html>
</html>

View file

@ -8,28 +8,28 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="linq2db" Version="4.3.0" />
<PackageReference Include="Markdig" Version="0.30.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0" />
<PackageReference Include="System.Data.SQLite" Version="1.0.115" />
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0" />
<PackageReference Include="YamlDotNet" Version="12.0.2" />
<PackageReference Include="linq2db" Version="4.3.0"/>
<PackageReference Include="Markdig" Version="0.30.4"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0"/>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0"/>
<PackageReference Include="System.Data.SQLite" Version="1.0.115"/>
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0"/>
<PackageReference Include="YamlDotNet" Version="12.0.2"/>
</ItemGroup>
<ItemGroup>
<None Remove=".gitignore" />
<None Remove=".bearer_token" />
<None Remove="database.db" />
<None Remove=".gitignore"/>
<None Remove=".bearer_token"/>
<None Remove="database.db"/>
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Pages\ErrorPages\404.cshtml" />
<_ContentIncludedByDefault Remove="Pages\ErrorPages\404.cshtml"/>
</ItemGroup>
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
<Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="False">
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput" />
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput"/>
</Exec>
</Target>