From d2d79da9295e1b68913f102fe259431387a3c00d Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 10 Apr 2024 09:50:49 +0800 Subject: [PATCH 001/227] patch .net --- src/Moonglade.Data.SqlServer/Moonglade.Data.SqlServer.csproj | 2 +- src/Moonglade.Data/Moonglade.Data.csproj | 2 +- src/Moonglade.Utils/Moonglade.Utils.csproj | 2 +- src/Moonglade.Web/Moonglade.Web.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Moonglade.Data.SqlServer/Moonglade.Data.SqlServer.csproj b/src/Moonglade.Data.SqlServer/Moonglade.Data.SqlServer.csproj index 048121024..4e2a69f1a 100644 --- a/src/Moonglade.Data.SqlServer/Moonglade.Data.SqlServer.csproj +++ b/src/Moonglade.Data.SqlServer/Moonglade.Data.SqlServer.csproj @@ -10,7 +10,7 @@ enable - + diff --git a/src/Moonglade.Data/Moonglade.Data.csproj b/src/Moonglade.Data/Moonglade.Data.csproj index a8bbb077c..a55db46fb 100644 --- a/src/Moonglade.Data/Moonglade.Data.csproj +++ b/src/Moonglade.Data/Moonglade.Data.csproj @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/src/Moonglade.Utils/Moonglade.Utils.csproj b/src/Moonglade.Utils/Moonglade.Utils.csproj index 7a70324e0..d22c03d1d 100644 --- a/src/Moonglade.Utils/Moonglade.Utils.csproj +++ b/src/Moonglade.Utils/Moonglade.Utils.csproj @@ -11,6 +11,6 @@ - + \ No newline at end of file diff --git a/src/Moonglade.Web/Moonglade.Web.csproj b/src/Moonglade.Web/Moonglade.Web.csproj index d0bf11fc8..5c5b0eb6c 100644 --- a/src/Moonglade.Web/Moonglade.Web.csproj +++ b/src/Moonglade.Web/Moonglade.Web.csproj @@ -38,7 +38,7 @@ - + From d37ea2d8c9aff8c78dab6843da4373b8c341452a Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 10 Apr 2024 09:51:12 +0800 Subject: [PATCH 002/227] bump version --- src/Directory.Build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ac92d6bf3..446681a21 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,8 +3,8 @@ Edi Wang edi.wang (C) 2024 edi.wang@outlook.com - 14.3.3.0 - 14.3.3.0 - 14.3.3 + 14.3.4.0 + 14.3.4.0 + 14.3.4 \ No newline at end of file From 661ba88f6bcc2ad42e9550e22d03f7deb95732e7 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Thu, 18 Apr 2024 14:57:34 +0800 Subject: [PATCH 003/227] Update PagedListRenderOptions.cs --- src/Moonglade.Web/PagedList/PagedListRenderOptions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Moonglade.Web/PagedList/PagedListRenderOptions.cs b/src/Moonglade.Web/PagedList/PagedListRenderOptions.cs index 1a2ede7a4..6738b1be2 100644 --- a/src/Moonglade.Web/PagedList/PagedListRenderOptions.cs +++ b/src/Moonglade.Web/PagedList/PagedListRenderOptions.cs @@ -25,10 +25,10 @@ public PagedListRenderOptions() ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}."; ItemSliceAndTotalPosition = ItemSliceAndTotalPosition.Start; FunctionToDisplayEachPageNumber = null; - ContainerDivClasses = new[] { "pagination-container" }; - UlElementClasses = new[] { "pagination" }; - LiElementClasses = new[] { "page-item" }; - PageClasses = new[] { "page-link" }; + ContainerDivClasses = ["pagination-container"]; + UlElementClasses = ["pagination"]; + LiElementClasses = ["page-item"]; + PageClasses = ["page-link"]; ActiveLiElementClass = "active"; EllipsesElementClass = "paged-list-ellipses"; PreviousElementClass = "PagedList-skip-to-previous"; From c616d5c14416ae88617c37064b885705b7cf147b Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Thu, 18 Apr 2024 15:09:59 +0800 Subject: [PATCH 004/227] minimal code refact --- src/Moonglade.Comments/Comment.cs | 2 +- src/Moonglade.Web/PagedList/HtmlHelperExtension.cs | 4 ++-- src/Moonglade.Web/Pages/Admin/Comments.cshtml | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Moonglade.Comments/Comment.cs b/src/Moonglade.Comments/Comment.cs index feaf008c5..06ef738f2 100644 --- a/src/Moonglade.Comments/Comment.cs +++ b/src/Moonglade.Comments/Comment.cs @@ -13,7 +13,7 @@ public class Comment public string CommentContent { get; set; } - public IReadOnlyList CommentReplies { get; set; } + public List CommentReplies { get; set; } } public class CommentDetailedItem : Comment diff --git a/src/Moonglade.Web/PagedList/HtmlHelperExtension.cs b/src/Moonglade.Web/PagedList/HtmlHelperExtension.cs index d1d7ef284..8fe96b64c 100644 --- a/src/Moonglade.Web/PagedList/HtmlHelperExtension.cs +++ b/src/Moonglade.Web/PagedList/HtmlHelperExtension.cs @@ -11,11 +11,11 @@ public static HtmlString PagedListPager(this IHtmlHelper html, Func generatePageUrl, PagedListRenderOptions options) { - var htmlHelper = new HtmlHelper(new TagBuilderFactory()); + var htmlHelper = new HtmlHelper(new()); var htmlString = htmlHelper.PagedListPager(list, generatePageUrl, options); htmlString = HttpUtility.HtmlDecode(htmlString); - return new HtmlString(htmlString); + return new(htmlString); } } \ No newline at end of file diff --git a/src/Moonglade.Web/Pages/Admin/Comments.cshtml b/src/Moonglade.Web/Pages/Admin/Comments.cshtml index 590f6ddb8..a8c060f2b 100644 --- a/src/Moonglade.Web/Pages/Admin/Comments.cshtml +++ b/src/Moonglade.Web/Pages/Admin/Comments.cshtml @@ -7,7 +7,7 @@ } @Html.AntiForgeryToken() -@section scripts{ +@section scripts { } -@section head{ +@section head { } -@section admintoolbar{ +@section admintoolbar {
@SharedLocalizer["Delete selected"] @@ -171,7 +171,7 @@ } } - @Html.PagedListPager(Model.CommentDetailedItems, page => $"?pageIndex={page}", new PagedListRenderOptions + @Html.PagedListPager(Model.CommentDetailedItems, page => $"?pageIndex={page}", new() { UlElementClasses = new[] { "pagination mt-3" }, DisplayEllipsesWhenNotShowingAllPageNumbers = false From 22ca3b35e02a92e5ed88cda39cbdb86a737009a0 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Thu, 18 Apr 2024 15:22:15 +0800 Subject: [PATCH 005/227] remove support for multiple local account phase 1 --- .../Controllers/LocalAccountController.cs | 41 ----- .../Pages/Admin/LocalAccount.cshtml | 140 ++++-------------- .../Pages/Shared/_AsideAdmin.cshtml | 2 +- .../Resources/Program.zh-Hans.resx | 2 +- .../Resources/Program.zh-Hant.resx | 2 +- 5 files changed, 30 insertions(+), 157 deletions(-) diff --git a/src/Moonglade.Web/Controllers/LocalAccountController.cs b/src/Moonglade.Web/Controllers/LocalAccountController.cs index ba900b590..4621e1901 100644 --- a/src/Moonglade.Web/Controllers/LocalAccountController.cs +++ b/src/Moonglade.Web/Controllers/LocalAccountController.cs @@ -9,47 +9,6 @@ namespace Moonglade.Web.Controllers; [Route("api/[controller]")] public class LocalAccountController(IMediator mediator) : ControllerBase { - [HttpPost] - [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status409Conflict)] - public async Task Create(CreateAccountCommand command) - { - if (await mediator.Send(new AccountExistsQuery(command.Username))) - { - ModelState.AddModelError("username", $"User '{command.Username}' already exist."); - return Conflict(ModelState); - } - - await mediator.Send(command); - return Ok(); - } - - [HttpDelete("{id:guid}")] - [ProducesResponseType(StatusCodes.Status204NoContent)] - [ProducesResponseType(StatusCodes.Status409Conflict)] - public async Task Delete([NotEmpty] Guid id) - { - var uidClaim = User.Claims.FirstOrDefault(c => c.Type == "uid"); - if (null == uidClaim || string.IsNullOrWhiteSpace(uidClaim.Value)) - { - return StatusCode(StatusCodes.Status500InternalServerError, "Can not get current uid."); - } - - if (id.ToString() == uidClaim.Value) - { - return Conflict("Can not delete current user."); - } - - var count = await mediator.Send(new CountAccountsQuery()); - if (count == 1) - { - return Conflict("Can not delete last account."); - } - - await mediator.Send(new DeleteAccountCommand(id)); - return NoContent(); - } - [HttpPut("{id:guid}/password")] [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status409Conflict)] diff --git a/src/Moonglade.Web/Pages/Admin/LocalAccount.cshtml b/src/Moonglade.Web/Pages/Admin/LocalAccount.cshtml index 4f4c795f7..5f7d6e032 100644 --- a/src/Moonglade.Web/Pages/Admin/LocalAccount.cshtml +++ b/src/Moonglade.Web/Pages/Admin/LocalAccount.cshtml @@ -5,57 +5,19 @@ var currentUidClaim = User.Claims.FirstOrDefault(c => c.Type == "uid"); } -@section scripts{ +@section scripts { } -@section admintoolbar{ +@section admintoolbar { } - @if (null != Model.Accounts && Model.Accounts.Any()) - { - - - - - - - - +@if (null != Model.Accounts && Model.Accounts.Any()) +{ +
@SharedLocalizer["Username"]@SharedLocalizer["Last Login IP"]@SharedLocalizer["Last Login Time (UTC)"]@SharedLocalizer["Create Time (UTC)"]@SharedLocalizer["Action"]
+ + + + + + + + + @foreach (var item in Model.Accounts.OrderBy(p => p.Username)) + { + + + + - - - @foreach (var item in Model.Accounts.OrderBy(p => p.Username)) - { - - - - - - - - } - -
@SharedLocalizer["Username"]@SharedLocalizer["Last Login IP"]@SharedLocalizer["Last Login Time (UTC)"]
@item.Username@(item.LastLoginIp ?? "N/A")@(null != item.LastLoginTimeUtc ? item.LastLoginTimeUtc.ToString() : "N/A")
@item.Username@(item.LastLoginIp ?? "N/A")@(null != item.LastLoginTimeUtc ? item.LastLoginTimeUtc.ToString() : "N/A")@item.CreateTimeUtc - - - - - @if (null != currentUidClaim && currentUidClaim.Value != item.Id.ToString()) - { - - } -
- } - -

Check out Microsoft Entra ID and empower your blog to achieve more!

- - - +

Check out Microsoft Entra ID and empower your blog to achieve more!