From 2f5391bd6c3cc65930dbb7d8ebfbaf067218c29d Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 2 Aug 2023 13:09:36 +0800 Subject: [PATCH 1/4] add CommentOrder settings model --- src/Moonglade.Configuration/ContentSettings.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Moonglade.Configuration/ContentSettings.cs b/src/Moonglade.Configuration/ContentSettings.cs index ebc5c4228..0e42d8f14 100644 --- a/src/Moonglade.Configuration/ContentSettings.cs +++ b/src/Moonglade.Configuration/ContentSettings.cs @@ -7,6 +7,9 @@ public class ContentSettings : IBlogSettings { [Display(Name = "Comment provider")] public CommentProvider CommentProvider { get; set; } + + [Display(Name = "Comments display order")] + public CommentOrder CommentOrder { get; set; } [Display(Name = "Post title alignment")] public PostTitleAlignment PostTitleAlignment { get; set; } = PostTitleAlignment.Left; @@ -91,6 +94,12 @@ public enum CommentProvider ThirdParty = 1 } +public enum CommentOrder +{ + OldToNew = 0, + NewToOld = 1 +} + public enum PostTitleAlignment { Left = 0, From 298393144a8c63c8bd287bbeeafb56ba5a44da41 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 2 Aug 2023 13:18:25 +0800 Subject: [PATCH 2/4] settings ui --- .../Pages/Settings/Content.cshtml | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Moonglade.Web/Pages/Settings/Content.cshtml b/src/Moonglade.Web/Pages/Settings/Content.cshtml index 7e90d4ba4..560733470 100644 --- a/src/Moonglade.Web/Pages/Settings/Content.cshtml +++ b/src/Moonglade.Web/Pages/Settings/Content.cshtml @@ -55,24 +55,43 @@
@Html.RadioButtonFor(model => settings.CommentProvider, CommentProvider.BuiltIn, new - { - id = CommentProvider.BuiltIn.ToString(), - @class = "form-check-input comment-provider-checkbox", - onchange = "window.toggleCommentSettingsUI()" - }) + { + id = CommentProvider.BuiltIn.ToString(), + @class = "form-check-input comment-provider-checkbox", + onchange = "window.toggleCommentSettingsUI()" + })
@Html.RadioButtonFor(model => settings.CommentProvider, CommentProvider.ThirdParty, new - { - id = CommentProvider.ThirdParty.ToString(), - @class = "form-check-input comment-provider-checkbox", - onchange = "window.toggleCommentSettingsUI()" - }) + { + id = CommentProvider.ThirdParty.ToString(), + @class = "form-check-input comment-provider-checkbox", + onchange = "window.toggleCommentSettingsUI()" + })
+ +
+
+ +
+
+ +
+
+
+ @Html.RadioButtonFor(model => settings.CommentOrder, CommentOrder.OldToNew, new { id = CommentOrder.OldToNew.ToString(), @class = "form-check-input" }) + +
+
+ @Html.RadioButtonFor(model => settings.CommentOrder, CommentOrder.NewToOld, new { id = CommentOrder.NewToOld.ToString(), @class = "form-check-input" }) + +
+
+
From 49a9b78b30f43e7f8423f2dbee75558cc0ee7ef2 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 2 Aug 2023 13:26:31 +0800 Subject: [PATCH 3/4] update icon --- src/Moonglade.Web/Pages/Settings/Content.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moonglade.Web/Pages/Settings/Content.cshtml b/src/Moonglade.Web/Pages/Settings/Content.cshtml index 560733470..104a7d9e3 100644 --- a/src/Moonglade.Web/Pages/Settings/Content.cshtml +++ b/src/Moonglade.Web/Pages/Settings/Content.cshtml @@ -76,7 +76,7 @@
- +
From 6d597bbe36eed865abc1140db17c08d84947ca27 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Wed, 2 Aug 2023 13:33:38 +0800 Subject: [PATCH 4/4] apply order --- .../Pages/Components/CommentList/Default.cshtml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml b/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml index 545c63b82..7924061f9 100644 --- a/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml +++ b/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml @@ -20,8 +20,13 @@ @if (null != Model && Model.Any()) { + var orderedList = + BlogConfig.ContentSettings.CommentOrder == CommentOrder.NewToOld ? + Model.OrderByDescending(m => m.CreateTimeUtc) : + Model.OrderBy(m => m.CreateTimeUtc); +
- @foreach (var item in Model.OrderBy(m => m.CreateTimeUtc)) + @foreach (var item in orderedList) {
@if (BlogConfig.ContentSettings.EnableGravatar && !string.IsNullOrWhiteSpace(item.Email)) @@ -56,9 +61,10 @@ @SharedLocalizer["Author"] - @SharedLocalizer["Replied at"] + + @SharedLocalizer["Replied at"] - +

@Html.Raw(ContentProcessor.MarkdownToContent(reply.ReplyContent, ContentProcessor.MarkdownConvertType.Html))