From 67c72284d59e664ca963322131032b39fdec5746 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Thu, 16 Jan 2025 17:30:34 +0800 Subject: [PATCH 1/5] dev: rubbish --- .gitignore | 3 + YaeBlog.Core/Components/_Imports.razor | 8 - YaeBlog.Core/YaeBlog.Core.csproj | 25 - YaeBlog.sln | 6 - .../Abstraction}/IEssayContentService.cs | 4 +- .../Abstraction}/IEssayScanService.cs | 4 +- .../Abstraction}/IPostRenderProcessor.cs | 4 +- .../Abstraction}/IPreRenderProcessor.cs | 4 +- YaeBlog/Commands/Binders/BlogOptionsBinder.cs | 2 +- .../Binders/EssayScanServiceBinder.cs | 6 +- ...CommandExtensions.cs => YaeBlogCommand.cs} | 40 +- YaeBlog/Components/App.razor | 5 +- YaeBlog/Components/BlogInformationCard.razor | 6 +- YaeBlog/Components/EssayCard.razor | 2 +- YaeBlog/Components/LicenseDisclaimer.razor | 3 +- .../Exceptions/BlogFileException.cs | 0 YaeBlog/Exceptions/ProcessInteropException.cs | 12 + .../Extensions/ServiceCollectionExtensions.cs | 3 +- .../WebApplicationBuilderExtensions.cs | 23 +- .../Extensions/WebApplicationExtensions.cs | 10 +- YaeBlog/Layout/BlogLayout.razor | 77 +- YaeBlog/Layout/MainLayout.razor | 19 +- {YaeBlog.Core => YaeBlog}/Models/AboutInfo.cs | 2 +- .../Models/BlogContent.cs | 2 +- .../Models/BlogContents.cs | 2 +- {YaeBlog.Core => YaeBlog}/Models/BlogEssay.cs | 2 +- .../Models/BlogHeadline.cs | 2 +- .../Models/BlogOptions.cs | 2 +- {YaeBlog.Core => YaeBlog}/Models/EssayTag.cs | 2 +- .../Models/FriendLink.cs | 2 +- .../Models/ImageScanResult.cs | 2 +- .../Models/MarkdownMetadata.cs | 2 +- YaeBlog/Models/TailwindOptions.cs | 10 + YaeBlog/Pages/About.razor | 4 +- YaeBlog/Pages/Archives.razor | 4 +- YaeBlog/Pages/BlogIndex.razor | 4 +- YaeBlog/Pages/Essays.razor | 4 +- YaeBlog/Pages/Index.razor | 2 +- YaeBlog/Pages/Tags.razor | 4 +- .../CodeBlockPostRenderProcessor.cs | 6 +- .../Processors/HeadlinePostRenderProcessor.cs | 9 +- .../Processors/ImagePostRenderProcessor.cs | 9 +- .../Processors/TablePostRenderProcessor.cs | 6 +- YaeBlog/Program.cs | 13 +- .../Services/BlogChangeWatcher.cs | 7 +- .../Services/BlogHostedService.cs | 5 +- .../Services/BlogHotReloadService.cs | 6 +- .../Services/EssayContentService.cs | 6 +- .../Services/EssayScanService.cs | 7 +- YaeBlog/Services/ProcessInteropService.cs | 65 ++ .../Services/RendererService.cs | 7 +- YaeBlog/Services/TailwindRefreshService.cs | 46 + YaeBlog/YaeBlog.csproj | 34 +- YaeBlog/_Imports.razor | 1 - YaeBlog/appsettings.json | 4 + YaeBlog/package.json | 12 + YaeBlog/pnpm-lock.yaml | 836 ++++++++++++++++++ YaeBlog/tailwind.config.js | 9 + YaeBlog/wwwroot/bootstrap-icons.min.css | 5 - YaeBlog/wwwroot/bootstrap.bundle.min.js | 7 - YaeBlog/wwwroot/bootstrap.min.css | 6 - YaeBlog/wwwroot/globals.css | 75 -- YaeBlog/wwwroot/input.css | 3 + 63 files changed, 1179 insertions(+), 323 deletions(-) delete mode 100644 YaeBlog.Core/Components/_Imports.razor delete mode 100644 YaeBlog.Core/YaeBlog.Core.csproj rename {YaeBlog.Core/Abstractions => YaeBlog/Abstraction}/IEssayContentService.cs (89%) rename {YaeBlog.Core/Abstractions => YaeBlog/Abstraction}/IEssayScanService.cs (75%) rename {YaeBlog.Core/Abstractions => YaeBlog/Abstraction}/IPostRenderProcessor.cs (64%) rename {YaeBlog.Core/Abstractions => YaeBlog/Abstraction}/IPreRenderProcessor.cs (65%) rename YaeBlog/Commands/{CommandExtensions.cs => YaeBlogCommand.cs} (88%) rename {YaeBlog.Core => YaeBlog}/Exceptions/BlogFileException.cs (100%) create mode 100644 YaeBlog/Exceptions/ProcessInteropException.cs rename {YaeBlog.Core => YaeBlog}/Extensions/ServiceCollectionExtensions.cs (92%) rename {YaeBlog.Core => YaeBlog}/Extensions/WebApplicationBuilderExtensions.cs (71%) rename {YaeBlog.Core => YaeBlog}/Extensions/WebApplicationExtensions.cs (84%) rename {YaeBlog.Core => YaeBlog}/Models/AboutInfo.cs (84%) rename {YaeBlog.Core => YaeBlog}/Models/BlogContent.cs (85%) rename {YaeBlog.Core => YaeBlog}/Models/BlogContents.cs (89%) rename {YaeBlog.Core => YaeBlog}/Models/BlogEssay.cs (97%) rename {YaeBlog.Core => YaeBlog}/Models/BlogHeadline.cs (87%) rename {YaeBlog.Core => YaeBlog}/Models/BlogOptions.cs (94%) rename {YaeBlog.Core => YaeBlog}/Models/EssayTag.cs (93%) rename {YaeBlog.Core => YaeBlog}/Models/FriendLink.cs (93%) rename {YaeBlog.Core => YaeBlog}/Models/ImageScanResult.cs (74%) rename {YaeBlog.Core => YaeBlog}/Models/MarkdownMetadata.cs (82%) create mode 100644 YaeBlog/Models/TailwindOptions.cs rename {YaeBlog.Core => YaeBlog}/Processors/CodeBlockPostRenderProcessor.cs (88%) rename {YaeBlog.Core => YaeBlog}/Processors/HeadlinePostRenderProcessor.cs (95%) rename {YaeBlog.Core => YaeBlog}/Processors/ImagePostRenderProcessor.cs (89%) rename {YaeBlog.Core => YaeBlog}/Processors/TablePostRenderProcessor.cs (91%) rename {YaeBlog.Core => YaeBlog}/Services/BlogChangeWatcher.cs (93%) rename {YaeBlog.Core => YaeBlog}/Services/BlogHostedService.cs (81%) rename {YaeBlog.Core => YaeBlog}/Services/BlogHotReloadService.cs (87%) rename {YaeBlog.Core => YaeBlog}/Services/EssayContentService.cs (94%) rename {YaeBlog.Core => YaeBlog}/Services/EssayScanService.cs (98%) create mode 100644 YaeBlog/Services/ProcessInteropService.cs rename {YaeBlog.Core => YaeBlog}/Services/RendererService.cs (97%) create mode 100644 YaeBlog/Services/TailwindRefreshService.cs create mode 100644 YaeBlog/package.json create mode 100644 YaeBlog/pnpm-lock.yaml create mode 100644 YaeBlog/tailwind.config.js delete mode 100644 YaeBlog/wwwroot/bootstrap-icons.min.css delete mode 100644 YaeBlog/wwwroot/bootstrap.bundle.min.js delete mode 100644 YaeBlog/wwwroot/bootstrap.min.css create mode 100644 YaeBlog/wwwroot/input.css diff --git a/.gitignore b/.gitignore index 104b544..f606da8 100644 --- a/.gitignore +++ b/.gitignore @@ -482,3 +482,6 @@ $RECYCLE.BIN/ # Vim temporary swap files *.swp + +# Tailwind auto-generated stylesheet +output.css diff --git a/YaeBlog.Core/Components/_Imports.razor b/YaeBlog.Core/Components/_Imports.razor deleted file mode 100644 index d88eed9..0000000 --- a/YaeBlog.Core/Components/_Imports.razor +++ /dev/null @@ -1,8 +0,0 @@ -@using System.Net.Http -@using System.Net.Http.Json -@using Microsoft.AspNetCore.Components.Forms -@using Microsoft.AspNetCore.Components.Routing -@using Microsoft.AspNetCore.Components.Web -@using static Microsoft.AspNetCore.Components.Web.RenderMode -@using Microsoft.AspNetCore.Components.Web.Virtualization -@using Microsoft.JSInterop diff --git a/YaeBlog.Core/YaeBlog.Core.csproj b/YaeBlog.Core/YaeBlog.Core.csproj deleted file mode 100644 index 7089599..0000000 --- a/YaeBlog.Core/YaeBlog.Core.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net9.0 - enable - enable - - - - - - - - - - - - - - - - - - - diff --git a/YaeBlog.sln b/YaeBlog.sln index 78aae25..c4f8f9c 100644 --- a/YaeBlog.sln +++ b/YaeBlog.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YaeBlog.Core", "YaeBlog.Core\YaeBlog.Core.csproj", "{1671A8AE-78F6-4641-B97D-D8ABA5E9CBEF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YaeBlog", "YaeBlog\YaeBlog.csproj", "{20438EFD-8DDE-43AF-92E2-76495C29233C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".gitea", ".gitea", "{9B5AAA29-37D8-454A-8D8F-3E6B6BCF38E6}" @@ -29,10 +27,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1671A8AE-78F6-4641-B97D-D8ABA5E9CBEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1671A8AE-78F6-4641-B97D-D8ABA5E9CBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1671A8AE-78F6-4641-B97D-D8ABA5E9CBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1671A8AE-78F6-4641-B97D-D8ABA5E9CBEF}.Release|Any CPU.Build.0 = Release|Any CPU {20438EFD-8DDE-43AF-92E2-76495C29233C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {20438EFD-8DDE-43AF-92E2-76495C29233C}.Debug|Any CPU.Build.0 = Debug|Any CPU {20438EFD-8DDE-43AF-92E2-76495C29233C}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/YaeBlog.Core/Abstractions/IEssayContentService.cs b/YaeBlog/Abstraction/IEssayContentService.cs similarity index 89% rename from YaeBlog.Core/Abstractions/IEssayContentService.cs rename to YaeBlog/Abstraction/IEssayContentService.cs index 9be561c..2845c75 100644 --- a/YaeBlog.Core/Abstractions/IEssayContentService.cs +++ b/YaeBlog/Abstraction/IEssayContentService.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; -using YaeBlog.Core.Models; +using YaeBlog.Models; -namespace YaeBlog.Core.Abstractions; +namespace YaeBlog.Abstraction; public interface IEssayContentService { diff --git a/YaeBlog.Core/Abstractions/IEssayScanService.cs b/YaeBlog/Abstraction/IEssayScanService.cs similarity index 75% rename from YaeBlog.Core/Abstractions/IEssayScanService.cs rename to YaeBlog/Abstraction/IEssayScanService.cs index 5395b9a..f5aad84 100644 --- a/YaeBlog.Core/Abstractions/IEssayScanService.cs +++ b/YaeBlog/Abstraction/IEssayScanService.cs @@ -1,6 +1,6 @@ -using YaeBlog.Core.Models; +using YaeBlog.Models; -namespace YaeBlog.Core.Abstractions; +namespace YaeBlog.Abstraction; public interface IEssayScanService { diff --git a/YaeBlog.Core/Abstractions/IPostRenderProcessor.cs b/YaeBlog/Abstraction/IPostRenderProcessor.cs similarity index 64% rename from YaeBlog.Core/Abstractions/IPostRenderProcessor.cs rename to YaeBlog/Abstraction/IPostRenderProcessor.cs index 6117742..e7b4c2b 100644 --- a/YaeBlog.Core/Abstractions/IPostRenderProcessor.cs +++ b/YaeBlog/Abstraction/IPostRenderProcessor.cs @@ -1,6 +1,6 @@ -using YaeBlog.Core.Models; +using YaeBlog.Models; -namespace YaeBlog.Core.Abstractions; +namespace YaeBlog.Abstraction; public interface IPostRenderProcessor { diff --git a/YaeBlog.Core/Abstractions/IPreRenderProcessor.cs b/YaeBlog/Abstraction/IPreRenderProcessor.cs similarity index 65% rename from YaeBlog.Core/Abstractions/IPreRenderProcessor.cs rename to YaeBlog/Abstraction/IPreRenderProcessor.cs index ee3b7f2..a9b69f2 100644 --- a/YaeBlog.Core/Abstractions/IPreRenderProcessor.cs +++ b/YaeBlog/Abstraction/IPreRenderProcessor.cs @@ -1,6 +1,6 @@ -using YaeBlog.Core.Models; +using YaeBlog.Models; -namespace YaeBlog.Core.Abstractions; +namespace YaeBlog.Abstraction; public interface IPreRenderProcessor { diff --git a/YaeBlog/Commands/Binders/BlogOptionsBinder.cs b/YaeBlog/Commands/Binders/BlogOptionsBinder.cs index 9f3cb54..f6e4af6 100644 --- a/YaeBlog/Commands/Binders/BlogOptionsBinder.cs +++ b/YaeBlog/Commands/Binders/BlogOptionsBinder.cs @@ -1,7 +1,7 @@ using System.CommandLine.Binding; using System.Text.Json; using Microsoft.Extensions.Options; -using YaeBlog.Core.Models; +using YaeBlog.Models; namespace YaeBlog.Commands.Binders; diff --git a/YaeBlog/Commands/Binders/EssayScanServiceBinder.cs b/YaeBlog/Commands/Binders/EssayScanServiceBinder.cs index b0613c8..5d7e1d5 100644 --- a/YaeBlog/Commands/Binders/EssayScanServiceBinder.cs +++ b/YaeBlog/Commands/Binders/EssayScanServiceBinder.cs @@ -1,8 +1,8 @@ using System.CommandLine.Binding; using Microsoft.Extensions.Options; -using YaeBlog.Core.Abstractions; -using YaeBlog.Core.Models; -using YaeBlog.Core.Services; +using YaeBlog.Abstraction; +using YaeBlog.Models; +using YaeBlog.Services; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; diff --git a/YaeBlog/Commands/CommandExtensions.cs b/YaeBlog/Commands/YaeBlogCommand.cs similarity index 88% rename from YaeBlog/Commands/CommandExtensions.cs rename to YaeBlog/Commands/YaeBlogCommand.cs index bb7576d..88c4043 100644 --- a/YaeBlog/Commands/CommandExtensions.cs +++ b/YaeBlog/Commands/YaeBlogCommand.cs @@ -1,15 +1,32 @@ using System.CommandLine; using YaeBlog.Commands.Binders; using YaeBlog.Components; -using YaeBlog.Core.Extensions; -using YaeBlog.Core.Models; -using YaeBlog.Core.Services; +using YaeBlog.Extensions; +using YaeBlog.Models; +using YaeBlog.Services; namespace YaeBlog.Commands; -public static class CommandExtensions +public sealed class YaeBlogCommand { - public static void AddServeCommand(this RootCommand rootCommand) + private readonly RootCommand _rootCommand = new("YaeBlog Cli"); + + public YaeBlogCommand() + { + AddServeCommand(_rootCommand); + AddWatchCommand(_rootCommand); + AddListCommand(_rootCommand); + AddNewCommand(_rootCommand); + AddPublishCommand(_rootCommand); + AddScanCommand(_rootCommand); + } + + public Task RunAsync(string[] args) + { + return _rootCommand.InvokeAsync(args); + } + + private static void AddServeCommand(RootCommand rootCommand) { Command serveCommand = new("serve", "Start http server."); rootCommand.AddCommand(serveCommand); @@ -21,7 +38,6 @@ public static class CommandExtensions builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddControllers(); - builder.Services.AddBlazorBootstrap(); builder.AddYaeBlog(); builder.AddServer(); @@ -40,7 +56,7 @@ public static class CommandExtensions }); } - public static void AddWatchCommand(this RootCommand rootCommand) + private static void AddWatchCommand(RootCommand rootCommand) { Command command = new("watch", "Start a blog watcher that re-render when file changes."); rootCommand.AddCommand(command); @@ -52,9 +68,9 @@ public static class CommandExtensions builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddControllers(); - builder.Services.AddBlazorBootstrap(); builder.AddYaeBlog(); builder.AddWatcher(); + builder.AddTailwindWatcher(); WebApplication application = builder.Build(); @@ -71,7 +87,7 @@ public static class CommandExtensions }); } - public static void AddNewCommand(this RootCommand rootCommand) + private static void AddNewCommand(RootCommand rootCommand) { Command newCommand = new("new", "Create a new blog file and image directory."); rootCommand.AddCommand(newCommand); @@ -101,7 +117,7 @@ public static class CommandExtensions new EssayScanServiceBinder()); } - public static void AddListCommand(this RootCommand rootCommand) + private static void AddListCommand(RootCommand rootCommand) { Command command = new("list", "List all blogs"); rootCommand.AddCommand(command); @@ -124,7 +140,7 @@ public static class CommandExtensions }, new BlogOptionsBinder(), new LoggerBinder(), new EssayScanServiceBinder()); } - public static void AddScanCommand(this RootCommand rootCommand) + private static void AddScanCommand(RootCommand rootCommand) { Command command = new("scan", "Scan unused and not found images."); rootCommand.AddCommand(command); @@ -165,7 +181,7 @@ public static class CommandExtensions }, new BlogOptionsBinder(), new LoggerBinder(), new EssayScanServiceBinder(), removeOption); } - public static void AddPublishCommand(this RootCommand rootCommand) + private static void AddPublishCommand(RootCommand rootCommand) { Command command = new("publish", "Publish a new blog file."); rootCommand.AddCommand(command); diff --git a/YaeBlog/Components/App.razor b/YaeBlog/Components/App.razor index 3a96ded..a30f2cd 100644 --- a/YaeBlog/Components/App.razor +++ b/YaeBlog/Components/App.razor @@ -7,10 +7,8 @@ - - - + @@ -18,7 +16,6 @@ - - - + + diff --git a/YaeBlog/Components/BlogInformationCard.razor b/YaeBlog/Components/BlogInformationCard.razor index c14f1c7..b8b3383 100644 --- a/YaeBlog/Components/BlogInformationCard.razor +++ b/YaeBlog/Components/BlogInformationCard.razor @@ -4,54 +4,42 @@ @inject IEssayContentService Contents @inject BlogOptions Options -
-
-
- @* Ricardo's avatar *@ -
+
+
+ Ricardo's Avatar
-
-
- “奇奇怪怪东西的聚合地” -
+
+ “奇奇怪怪东西的聚合地”
-
-
+
+
文章
-
- - @(Contents.Essays.Count) - +
+ @(Contents.Essays.Count)
-
-
+
+
标签
-
- - @(Contents.Tags.Count) - +
+ @(Contents.Tags.Count)
-
-
- 广而告之 -
+
+ 广而告之
-
-
-

- @(Options.Announcement) -

-
+
+

+ @(Options.Announcement) +

diff --git a/YaeBlog/Components/EssayCard.razor b/YaeBlog/Components/EssayCard.razor index 092ad87..99cb3f1 100644 --- a/YaeBlog/Components/EssayCard.razor +++ b/YaeBlog/Components/EssayCard.razor @@ -1,19 +1,19 @@ @using System.Text.Encodings.Web @using YaeBlog.Models -
-
+
+ -
-
+
+
@(Essay.PublishTime.ToString("yyyy-MM-dd"))
@foreach (string key in Essay.Tags) { -
+
# @key @@ -21,20 +21,11 @@ }
-
-
- @(Essay.Description) -
-
- -
-
- -
+
+ @(Essay.Description)
@code { - [Parameter] - public required BlogEssay Essay { get; set; } + [Parameter] public required BlogEssay Essay { get; set; } } diff --git a/YaeBlog/Components/Foonter.razor b/YaeBlog/Components/Foonter.razor index d3f9910..8a5935b 100644 --- a/YaeBlog/Components/Foonter.razor +++ b/YaeBlog/Components/Foonter.razor @@ -1,14 +1,22 @@ -
-
-

- 2021 - @(DateTimeOffset.Now.Year) © Ricardo Ren, - 由 .NET @(Environment.Version) 驱动。 +

+
+

+ 2021 - @(DateTimeOffset.Now.Year) © + + ,由 + + 驱动。

- + +@code +{ + private string DotnetVersion => $".NET {Environment.Version}"; +} diff --git a/YaeBlog/Components/LicenseDisclaimer.razor b/YaeBlog/Components/LicenseDisclaimer.razor index 9095d31..a95ca67 100644 --- a/YaeBlog/Components/LicenseDisclaimer.razor +++ b/YaeBlog/Components/LicenseDisclaimer.razor @@ -1,30 +1,28 @@ @using YaeBlog.Models @inject BlogOptions Options -