From fad8890047eab7ca5df7e1cb3fe77fe352644cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 30 May 2022 11:57:21 +0300 Subject: [PATCH 01/60] First draft implementation for widgets --- .../Pages/CmsKitContentWidgetOptions.cs | 8 +++++ .../Components/Pages/ContentFragment.cs | 6 ++++ .../Shared/Components/Pages/ContentParser.cs | 21 +++++++++++ .../Components/Pages/ContentWidgetConfig.cs | 14 ++++++++ .../Shared/Components/Pages/Default.cshtml | 17 +++++++-- .../Pages/DefaultPageViewComponent.cs | 36 ++++++++----------- .../Shared/Components/Pages/IContentParser.cs | 9 +++++ .../Pages/MarkdownContentFragment.cs | 6 ++++ .../Shared/Components/Pages/PageViewModel.cs | 13 +++++++ .../Components/Pages/WidgetContentFragment.cs | 18 ++++++++++ 10 files changed, 124 insertions(+), 24 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs new file mode 100644 index 0000000000..a4aedbc158 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public class CmsKitContentWidgetOptions +{ + public Dictionary WidgetConfigs { get; } = new(); +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs new file mode 100644 index 0000000000..c5486903dd --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs @@ -0,0 +1,6 @@ +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public abstract class ContentFragment +{ + +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs new file mode 100644 index 0000000000..bfc0828821 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public class ContentParser : IContentParser, ITransientDependency +{ + public async Task> ParseAsync(string content) + { + return new List { + new MarkdownContentFragment { + Content = "**ABP Framework** is completely open source and developed in a community-driven manner." + }, + new WidgetContentFragment("CmsPoll") { Properties = { { "widgetName", "poll-right" } } }, + new MarkdownContentFragment { + Content = "Thanks _for_ *your* feedback." + } + }; + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs new file mode 100644 index 0000000000..647427b330 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs @@ -0,0 +1,14 @@ +using System; + +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public class ContentWidgetConfig +{ + public string Name { get; } + public Type ViewComponentType { get; set; } + + public ContentWidgetConfig(string name) + { + Name = name; + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 50104515c9..3ca57d6a05 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -2,6 +2,7 @@ @using Volo.CmsKit.Public.Web.Renderers @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs +@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages @inject IMarkdownToHtmlRenderer MarkdownRenderer @@ -9,9 +10,19 @@ - @if (!Model.Content.IsNullOrEmpty()) - { - @Html.Raw(await MarkdownRenderer.RenderAsync(Model.Content)) + @foreach (var contentFragment in Model.ContentFragments) + { + if (contentFragment is MarkdownContentFragment markdownContentFragment) + { + @Html.Raw(await MarkdownRenderer.RenderAsync(markdownContentFragment.Content)) + } + else if(contentFragment is WidgetContentFragment widgetContentFragment) + { + @await Component.InvokeAsync(widgetContentFragment.Name, new + { + widgetName = "poll-right" + }) + } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs index c5427af114..914001b073 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs @@ -2,8 +2,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; -using Volo.CmsKit.Public.Pages; -using Volo.CmsKit.Public.Web.Renderers; using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; @@ -12,43 +10,39 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; [Widget( StyleTypes = new[] { - typeof(HighlightJsStyleContributor) + typeof(HighlightJsStyleContributor) }, ScriptTypes = new[] { - typeof(HighlightJsScriptContributor) + typeof(HighlightJsScriptContributor) }, ScriptFiles = new[] { - "/Pages/Public/CmsKit/highlightOnLoad.js" + "/Pages/Public/CmsKit/highlightOnLoad.js" })] public class DefaultPageViewComponent : AbpViewComponent { - protected IPagePublicAppService PagePublicAppService { get; } + private readonly IContentParser _contentParser; - public DefaultPageViewComponent(IPagePublicAppService pagePublicAppService) + public DefaultPageViewComponent(IContentParser contentParser) { - PagePublicAppService = pagePublicAppService; + _contentParser = contentParser; } - - public virtual async Task InvokeAsync(Guid pageId, string title, string content) + + public virtual async Task InvokeAsync( + Guid pageId, + string title, + string content) { + var contentFragments = await _contentParser.ParseAsync(content); + var model = new PageViewModel { Id = pageId, Title = title, - Content = content + ContentFragments = contentFragments }; return View("~/Pages/CmsKit/Shared/Components/Pages/Default.cshtml", model); } -} - -public class PageViewModel -{ - public Guid Id { get; set; } - - public string Title { get; set; } - - public string Content { get; set; } -} +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs new file mode 100644 index 0000000000..03e54ea4bb --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public interface IContentParser +{ + Task> ParseAsync(string content); +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs new file mode 100644 index 0000000000..361a4b3973 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs @@ -0,0 +1,6 @@ +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public class MarkdownContentFragment : ContentFragment +{ + public string Content { get; set; } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs new file mode 100644 index 0000000000..eae24aeae4 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public class PageViewModel +{ + public Guid Id { get; set; } + + public string Title { get; set; } + + public List ContentFragments { get; set; } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs new file mode 100644 index 0000000000..125c48a72e --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; + +public class WidgetContentFragment : ContentFragment +{ + public string Name { get; } + + public string ViewComponentName { get; set; } + + public Dictionary Properties { get; } + + public WidgetContentFragment(string name) + { + Name = name; + Properties = new Dictionary(); + } +} \ No newline at end of file From c86db705397afb526eaf1f5f16cd24b37149c8b0 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 2 Jun 2022 16:46:58 +0300 Subject: [PATCH 02/60] Improved example --- .../Shared/Components/Pages/ContentParser.cs | 1 + .../Shared/Components/Pages/Default.cshtml | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs index bfc0828821..ebea7cfa7e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -13,6 +13,7 @@ public class ContentParser : IContentParser, ITransientDependency Content = "**ABP Framework** is completely open source and developed in a community-driven manner." }, new WidgetContentFragment("CmsPoll") { Properties = { { "widgetName", "poll-right" } } }, + new WidgetContentFragment("CmsPollByName") { Properties = { { "name", "poll-name" } } }, new MarkdownContentFragment { Content = "Thanks _for_ *your* feedback." } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 3ca57d6a05..17ac619aa3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -16,12 +16,23 @@ { @Html.Raw(await MarkdownRenderer.RenderAsync(markdownContentFragment.Content)) } - else if(contentFragment is WidgetContentFragment widgetContentFragment) + else if (contentFragment is WidgetContentFragment widgetContentFragment) { - @await Component.InvokeAsync(widgetContentFragment.Name, new + //TODO + if (widgetContentFragment.Name == "CmsPoll") { - widgetName = "poll-right" - }) + @await Component.InvokeAsync(widgetContentFragment.Name, new + { + widgetName = "poll-right" + }) + } + else + { + @await Component.InvokeAsync(widgetContentFragment.Name,new + { + name = "poll-name" + }) + } } } From 200ec20190c1eb1c1e0be9fa9b7760c9ebe6e0ab Mon Sep 17 00:00:00 2001 From: malik masis Date: Sat, 4 Jun 2022 18:41:16 +0300 Subject: [PATCH 03/60] Implemented widget options --- .../Components/Pages/CmsKitContentWidgetOptions.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs index a4aedbc158..d782299026 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs @@ -4,5 +4,15 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; public class CmsKitContentWidgetOptions { - public Dictionary WidgetConfigs { get; } = new(); + public Dictionary WidgetConfigs { get; } + + public CmsKitContentWidgetOptions() + { + WidgetConfigs = new(); + } + + public void AddWidgetConfig(string name, ContentWidgetConfig contentWidgetConfig) + { + WidgetConfigs.Add(name, contentWidgetConfig); + } } \ No newline at end of file From 6057f2a12d272c6eec13588eb525256139e02337 Mon Sep 17 00:00:00 2001 From: malik masis Date: Mon, 6 Jun 2022 12:04:16 +0300 Subject: [PATCH 04/60] Converted widget name to the actual vc --- .../Shared/Components/Pages/ContentParser.cs | 16 ++++++++++++++-- .../Shared/Components/Pages/Default.cshtml | 17 +++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs index ebea7cfa7e..d9156e5a58 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -1,19 +1,31 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; public class ContentParser : IContentParser, ITransientDependency { + private readonly CmsKitContentWidgetOptions _options; + public ContentParser(IOptions options) + { + _options = options.Value; + } + public async Task> ParseAsync(string content) { + var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; return new List { new MarkdownContentFragment { Content = "**ABP Framework** is completely open source and developed in a community-driven manner." }, - new WidgetContentFragment("CmsPoll") { Properties = { { "widgetName", "poll-right" } } }, - new WidgetContentFragment("CmsPollByName") { Properties = { { "name", "poll-name" } } }, + new WidgetContentFragment(name) { + Properties = { + { "name", "poll-name" } + } + }, new MarkdownContentFragment { Content = "Thanks _for_ *your* feedback." } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 17ac619aa3..ece75e5422 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -18,21 +18,10 @@ } else if (contentFragment is WidgetContentFragment widgetContentFragment) { - //TODO - if (widgetContentFragment.Name == "CmsPoll") + @await Component.InvokeAsync(widgetContentFragment.Name, new { - @await Component.InvokeAsync(widgetContentFragment.Name, new - { - widgetName = "poll-right" - }) - } - else - { - @await Component.InvokeAsync(widgetContentFragment.Name,new - { - name = "poll-name" - }) - } + name = "poll-name" + }) } } From 53b8669d3dad837ee883757486bc349af66d9936 Mon Sep 17 00:00:00 2001 From: malik masis Date: Mon, 6 Jun 2022 13:20:20 +0300 Subject: [PATCH 05/60] Added missed fact attribute --- .../Pages/PageManager_Test.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs index 92dac10caf..208de3817f 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Pages/PageManager_Test.cs @@ -1,9 +1,6 @@ -using Shouldly; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; +using Shouldly; +using Xunit; namespace Volo.CmsKit.Pages; @@ -20,6 +17,7 @@ public class PageManager_Test : CmsKitDomainTestBase pageRepository = GetRequiredService(); } + [Fact] public async Task CreateAsync_ShouldWorkProperly_WithNonExistingSlug() { var title = "My awesome page"; @@ -34,6 +32,7 @@ public class PageManager_Test : CmsKitDomainTestBase page.Content.ShouldBe(content); } + [Fact] public async Task CreateAsync_ShouldThrowException_WithExistingSlug() { var title = "My awesome page"; @@ -46,6 +45,7 @@ public class PageManager_Test : CmsKitDomainTestBase exception.ShouldNotBeNull(); } + [Fact] public async Task SetSlugAsync_ShouldWorkProperly_WithNonExistingSlug() { var newSlug = "freshly-generated-new-slug"; @@ -56,6 +56,7 @@ public class PageManager_Test : CmsKitDomainTestBase page.Slug.ShouldBe(newSlug); } + [Fact] public async Task SetSlugAsync_ShouldThrowException_WithExistingSlug() { var newSlug = testData.Page_2_Slug; From c3eef7a06a9495d5d0c860911ea0e916faafbcd2 Mon Sep 17 00:00:00 2001 From: malik masis Date: Mon, 6 Jun 2022 18:34:40 +0300 Subject: [PATCH 06/60] Splitted MarkdownContentFragment still need development --- .../Shared/Components/Pages/ContentParser.cs | 51 ++++++++++++++----- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs index d9156e5a58..f91e6d22b7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -16,19 +18,44 @@ public class ContentParser : IContentParser, ITransientDependency public async Task> ParseAsync(string content) { + if (!_options.WidgetConfigs.Any()) + { + return new List() + { + new MarkdownContentFragment() { Content = content } + }; + } + + MatchCollection mc = Regex.Matches(content, @"(?<=\[Wid)(.*?)(?=\])");//(?<=X)(.*?)(?=Y) + + string split = "-----"; + + var polls = new List(); + foreach (Match m in mc) + { + polls.Add("[Wid" + m + "]"); + content = content.Replace("[Wid" + m + "]", split); + } + + var splittedContent = content.Split(split, StringSplitOptions.RemoveEmptyEntries); + + var contentFragments = new List(); var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; - return new List { - new MarkdownContentFragment { - Content = "**ABP Framework** is completely open source and developed in a community-driven manner." - }, - new WidgetContentFragment(name) { - Properties = { - { "name", "poll-name" } - } - }, - new MarkdownContentFragment { - Content = "Thanks _for_ *your* feedback." + for (int b = 0; b < splittedContent.Length; b++) + { + contentFragments.Add(new MarkdownContentFragment() { Content = splittedContent[b] }); + if (b != splittedContent.Length - 1) + { + contentFragments.Add(new WidgetContentFragment(name) + { + Properties = + { + { "name", "poll-name" } + } + }); } - }; + } + + return contentFragments; } } \ No newline at end of file From a2d9f457fc3cbca52f17859ea4b7da8db8af05bc Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 7 Jun 2022 23:06:33 +0300 Subject: [PATCH 07/60] created the first dynamic poll --- .../CmsKit/Shared/Components/Pages/ContentParser.cs | 11 +++++++---- .../CmsKit/Shared/Components/Pages/Default.cshtml | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs index f91e6d22b7..7c84b75917 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -28,6 +28,9 @@ public class ContentParser : IContentParser, ITransientDependency MatchCollection mc = Regex.Matches(content, @"(?<=\[Wid)(.*?)(?=\])");//(?<=X)(.*?)(?=Y) + MatchCollection mcPollName = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")"); + var pollNames = mcPollName.Select(p => p.Value).ToList(); + string split = "-----"; var polls = new List(); @@ -41,16 +44,16 @@ public class ContentParser : IContentParser, ITransientDependency var contentFragments = new List(); var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; - for (int b = 0; b < splittedContent.Length; b++) + for (int i = 0; i < splittedContent.Length; i++) { - contentFragments.Add(new MarkdownContentFragment() { Content = splittedContent[b] }); - if (b != splittedContent.Length - 1) + contentFragments.Add(new MarkdownContentFragment() { Content = splittedContent[i] }); + if (i != splittedContent.Length - 1) { contentFragments.Add(new WidgetContentFragment(name) { Properties = { - { "name", "poll-name" } + { "name", pollNames[i] } } }); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index ece75e5422..45720013b6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -20,7 +20,7 @@ { @await Component.InvokeAsync(widgetContentFragment.Name, new { - name = "poll-name" + name = widgetContentFragment.Properties.FirstOrDefault().Value }) } } From 6edfcdf0e0931e131f97fdb4bc21b3aa78e20dc2 Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 8 Jun 2022 10:39:44 +0300 Subject: [PATCH 08/60] Improved parsing the poll widget for the different cases --- .../Shared/Components/Pages/ContentParser.cs | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs index 7c84b75917..8019ae3ac2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -26,37 +26,65 @@ public class ContentParser : IContentParser, ITransientDependency }; } - MatchCollection mc = Regex.Matches(content, @"(?<=\[Wid)(.*?)(?=\])");//(?<=X)(.*?)(?=Y) + string delimeter = "----"; + var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); - MatchCollection mcPollName = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")"); - var pollNames = mcPollName.Select(p => p.Value).ToList(); + var parsedList = new List(); - string split = "-----"; + if (!replacedText.Contains(delimeter)) + { + parsedList.Add(replacedText); + } - var polls = new List(); - foreach (Match m in mc) + while (replacedText.Contains(delimeter)) { - polls.Add("[Wid" + m + "]"); - content = content.Replace("[Wid" + m + "]", split); + //For parsing delimeter + var index = replacedText.IndexOf(delimeter); + if (index != 0) + { + parsedList.Add(replacedText.Substring(0, index)); + replacedText = replacedText.Substring(index, replacedText.Length - index); + index = 0; + } + + parsedList.Add(replacedText.Substring(index, delimeter.Length)); + replacedText = replacedText.Substring(delimeter.Length, replacedText.Length - delimeter.Length); + + //for parsing the other side + index = replacedText.IndexOf(delimeter); + if (index != -1) + { + parsedList.Add(replacedText.Substring(0, index)); + replacedText = replacedText.Substring(index, replacedText.Length - index); + + } + else + { + parsedList.Add(replacedText); + } } - var splittedContent = content.Split(split, StringSplitOptions.RemoveEmptyEntries); + var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; + + var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Select(p => p.Value).ToList(); var contentFragments = new List(); - var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; - for (int i = 0; i < splittedContent.Length; i++) + for (int i = 0, k = 0; i < parsedList.Count; i++) { - contentFragments.Add(new MarkdownContentFragment() { Content = splittedContent[i] }); - if (i != splittedContent.Length - 1) + if (parsedList[i] == delimeter) { contentFragments.Add(new WidgetContentFragment(name) { Properties = { - { "name", pollNames[i] } + { "name", pollNames[k++] } } }); } + else + { + contentFragments.Add(new MarkdownContentFragment() { Content = parsedList[i] }); + } } return contentFragments; From b8e98d6917c82f68c86d4f3ef8ace88e00dcabe0 Mon Sep 17 00:00:00 2001 From: MagicalConch <37917403+git102347501@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:07:10 +0800 Subject: [PATCH 09/60] Update Redis-Cache.md --- docs/zh-Hans/Redis-Cache.md | 46 ++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/docs/zh-Hans/Redis-Cache.md b/docs/zh-Hans/Redis-Cache.md index cb82a640d5..c9a0d020dd 100644 --- a/docs/zh-Hans/Redis-Cache.md +++ b/docs/zh-Hans/Redis-Cache.md @@ -1 +1,45 @@ -TODO... \ No newline at end of file +# Redis 缓存 + +ABP Framework [缓存系统](Caching.md) 拓展了 [ASP.NET Core 分布式缓存](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed). 因此, 标准 ASP.NET Core 分布式缓存支持的 **任何提供程序** 都可以在您的应用程序中使用,并且可以像 **微软文档** 那样进行配置. + +不过, ABP为 Redis Cache 还提供了一个集成包: [Volo.Abp.Caching.StackExchangeRedis](https://www.nuget.org/packages/Volo.Abp.Caching.StackExchangeRedis). +为何使用中这个包而不是标准的[Microsoft.Extensions.Caching.StackExchangeRedis](https://www.nuget.org/packages/Microsoft.Extensions.Caching.StackExchangeRedis/)包有两个原因. + +1. 它实现 `SetManyAsync` 和 `GetManyAsync` 方法. 这些都不是 Microsoft 缓存库的标准方法,而是由ABP框架[缓存](Caching.md)系统添加的. 当您需要通过单个方法调用设置/获取多个缓存项时,它们**显着提高了性能**. +2. 它 **简化** 了 Redis 缓存 **配置** (将在下面解释). + +> Volo.Abp.Caching.StackExchangeRedis 已经使用了 Microsoft.Extensions.Caching.StackExchangeRedis 包,但对其进行了扩展和改进. +## 安装 + +> 如果使用Redis,则此软件包已安装在应用程序启动模板中. +在项目`.csproj`的文件夹中打开命令行窗口并输入命令: + +````bash +abp add-package Volo.Abp.Caching.StackExchangeRedis +```` + +## 配置 + +Volo.Abp.Caching.StackExchangeRedis 包自动从`IConfiguration`获取Redis[配置](Configuration.md). 因此,您可以在以下位置设置配置 `appsettings.json`: + +````js +"Redis": { + "IsEnabled": "true", + "Configuration": "127.0.0.1" +} +```` +设置`IsEnabled`为可选的,如果未设置将默认视为`true`. + + +或者,您可以[模块](Module-Development-Basics.md)的方法中配置标准的[RedisCacheOptions](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.stackexchangeredis.rediscacheoptions)类: `ConfigureServices` + +````csharp +Configure(options => +{ + //... +}); +```` + +## 另请参阅 + +* [缓存](Caching.md) From d48a0715310b99aab44d19fb5cd36edebd05b7dc Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 8 Jun 2022 16:04:17 +0300 Subject: [PATCH 10/60] set properties dynamically --- .../Shared/Components/Pages/ContentParser.cs | 23 +++++++++++-------- .../Shared/Components/Pages/Default.cshtml | 5 +--- .../Components/Pages/WidgetContentFragment.cs | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs index 8019ae3ac2..e0d53e1b6e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; @@ -10,6 +9,7 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; public class ContentParser : IContentParser, ITransientDependency { + private const string delimeter = "----"; private readonly CmsKitContentWidgetOptions _options; public ContentParser(IOptions options) { @@ -26,7 +26,6 @@ public class ContentParser : IContentParser, ITransientDependency }; } - string delimeter = "----"; var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); var parsedList = new List(); @@ -56,7 +55,6 @@ public class ContentParser : IContentParser, ITransientDependency { parsedList.Add(replacedText.Substring(0, index)); replacedText = replacedText.Substring(index, replacedText.Length - index); - } else { @@ -64,22 +62,27 @@ public class ContentParser : IContentParser, ITransientDependency } } - var name = _options.WidgetConfigs.FirstOrDefault(p => p.Key == "Poll").Value?.Name; - var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Select(p => p.Value).ToList(); + var polls = Regex.Matches(content, @"(?<=Widget Type="")(.*?)(?="")").Select(p => p.Value).ToList(); var contentFragments = new List(); + for (int i = 0, k = 0; i < parsedList.Count; i++) { if (parsedList[i] == delimeter) { - contentFragments.Add(new WidgetContentFragment(name) + var name = _options.WidgetConfigs.Where(p => p.Key == polls[k]).Select(p => p.Value.Name).FirstOrDefault(); + if (name is not null) { - Properties = + contentFragments.Add(new WidgetContentFragment(name) { - { "name", pollNames[k++] } - } - }); + Properties = + { + { "Name", pollNames[k]} + } + }); + } + k++; } else { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 45720013b6..3b6e6f0f8c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -18,10 +18,7 @@ } else if (contentFragment is WidgetContentFragment widgetContentFragment) { - @await Component.InvokeAsync(widgetContentFragment.Name, new - { - name = widgetContentFragment.Properties.FirstOrDefault().Value - }) + @await Component.InvokeAsync(widgetContentFragment.Name, widgetContentFragment.Properties) } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs index 125c48a72e..8dea303b0e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs @@ -8,11 +8,11 @@ public class WidgetContentFragment : ContentFragment public string ViewComponentName { get; set; } - public Dictionary Properties { get; } + public IDictionary Properties { get; } public WidgetContentFragment(string name) { Name = name; - Properties = new Dictionary(); + Properties = new Dictionary(); } } \ No newline at end of file From 349471af5eed33320eac502c4cf6bdbe5dd261d0 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 9 Jun 2022 13:39:08 +0300 Subject: [PATCH 11/60] Added poll for blogpost as well It will be made refactor --- .../CmsKit/Public/Blogs/BlogPostPublicDto.cs | 3 + .../CmsKit/Public/Blogs/ContentFragment.cs | 6 ++ .../Public/Blogs/MarkdownContentFragment.cs | 6 ++ .../Public/Blogs/WidgetContentFragment.cs | 18 ++++ .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 14 ++- .../Public/CmsKit/Blogs/BlogPost.cshtml.cs | 17 ++-- .../Blogs/CmsKitContentWidgetOptions.cs | 18 ++++ .../Public/CmsKit/Blogs/ContentParser.cs | 96 +++++++++++++++++++ .../CmsKit/Blogs/ContentWidgetConfig.cs | 15 +++ .../Public/CmsKit/Blogs/IContentParser.cs | 10 ++ 10 files changed, 192 insertions(+), 11 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs index 8c6a6a01e9..3ce3c3457a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Volo.Abp.Application.Dtos; using Volo.CmsKit.Users; @@ -15,6 +16,8 @@ public class BlogPostPublicDto : AuditedEntityDto public string ShortDescription { get; set; } + public List ContentFragments { get; set; } + public string Content { get; set; } public Guid? CoverImageMediaId { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs new file mode 100644 index 0000000000..e46316399c --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs @@ -0,0 +1,6 @@ +namespace Volo.CmsKit.Public.Blogs; + +public abstract class ContentFragment +{ + +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs new file mode 100644 index 0000000000..79cacf4575 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs @@ -0,0 +1,6 @@ +namespace Volo.CmsKit.Public.Blogs; + +public class MarkdownContentFragment : ContentFragment +{ + public string Content { get; set; } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs new file mode 100644 index 0000000000..11acbf4324 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace Volo.CmsKit.Public.Blogs; + +public class WidgetContentFragment : ContentFragment +{ + public string Name { get; } + + public string ViewComponentName { get; set; } + + public IDictionary Properties { get; } + + public WidgetContentFragment(string name) + { + Name = name; + Properties = new Dictionary(); + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index 9d8680e96c..2347e1cfc4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -1,5 +1,6 @@ @page +@using Volo.CmsKit.Public.Blogs @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment @using Volo.CmsKit.Public.Web.Pages @using Volo.Abp.GlobalFeatures @@ -65,11 +66,18 @@ @Model.BlogPost.CreationTime

- @if (!Model.BlogPost.Content.IsNullOrEmpty()) + @foreach (var contentFragment in Model.BlogPost.ContentFragments) { - @Html.Raw(await MarkdownRenderer.RenderAsync(Model.BlogPost.Content)) + if (contentFragment is MarkdownContentFragment markdownContentFragment) + { + @Html.Raw(await MarkdownRenderer.RenderAsync(markdownContentFragment.Content)) + } + else if (contentFragment is WidgetContentFragment widgetContentFragment) + { + @await Component.InvokeAsync(widgetContentFragment.Name, widgetContentFragment.Properties) + } } - +

@if (Model.BlogPost.LastModificationTime != null) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs index dcefb976a4..e1eda83bb7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs @@ -1,11 +1,5 @@ -using Markdig; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; @@ -37,17 +31,24 @@ public class BlogPostModel : CmsKitPublicPageModelBase protected IBlogFeatureAppService BlogFeatureAppService { get; } + private readonly IContentParser _contentParser; + + public BlogPostModel( IBlogPostPublicAppService blogPostPublicAppService, - IBlogFeatureAppService blogFeaturePublicAppService) + IBlogFeatureAppService blogFeaturePublicAppService +, + IContentParser contentParser) { BlogPostPublicAppService = blogPostPublicAppService; BlogFeatureAppService = blogFeaturePublicAppService; + _contentParser = contentParser; } public virtual async Task OnGetAsync() { BlogPost = await BlogPostPublicAppService.GetAsync(BlogSlug, BlogPostSlug); + BlogPost.ContentFragments = await _contentParser.ParseAsync(BlogPost.Content); if (GlobalFeatureManager.Instance.IsEnabled()) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs new file mode 100644 index 0000000000..7a8cc195be --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; + +public class CmsKitContentWidgetOptions +{ + public Dictionary WidgetConfigs { get; } + + public CmsKitContentWidgetOptions() + { + WidgetConfigs = new(); + } + + public void AddWidgetConfig(string name, ContentWidgetConfig contentWidgetConfig) + { + WidgetConfigs.Add(name, contentWidgetConfig); + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs new file mode 100644 index 0000000000..56439d9d7b --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs @@ -0,0 +1,96 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Microsoft.Extensions.Options; +using Volo.Abp.DependencyInjection; +using Volo.CmsKit.Public.Blogs; + +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; + +public class ContentParser : IContentParser, ITransientDependency +{ + private const string delimeter = "----"; + private readonly CmsKitContentWidgetOptions _options; + public ContentParser(IOptions options) + { + _options = options.Value; + } + + public async Task> ParseAsync(string content) + { + if (!_options.WidgetConfigs.Any()) + { + return new List() + { + new MarkdownContentFragment() { Content = content } + }; + } + + var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); + + var parsedList = new List(); + + if (!replacedText.Contains(delimeter)) + { + parsedList.Add(replacedText); + } + + while (replacedText.Contains(delimeter)) + { + //For parsing delimeter + var index = replacedText.IndexOf(delimeter); + if (index != 0) + { + parsedList.Add(replacedText.Substring(0, index)); + replacedText = replacedText.Substring(index, replacedText.Length - index); + index = 0; + } + + parsedList.Add(replacedText.Substring(index, delimeter.Length)); + replacedText = replacedText.Substring(delimeter.Length, replacedText.Length - delimeter.Length); + + //for parsing the other side + index = replacedText.IndexOf(delimeter); + if (index != -1) + { + parsedList.Add(replacedText.Substring(0, index)); + replacedText = replacedText.Substring(index, replacedText.Length - index); + } + else + { + parsedList.Add(replacedText); + } + } + + var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Select(p => p.Value).ToList(); + var polls = Regex.Matches(content, @"(?<=Widget Type="")(.*?)(?="")").Select(p => p.Value).ToList(); + + var contentFragments = new List(); + + for (int i = 0, k = 0; i < parsedList.Count; i++) + { + if (parsedList[i] == delimeter) + { + var name = _options.WidgetConfigs.Where(p => p.Key == polls[k]).Select(p => p.Value.Name).FirstOrDefault(); + if (name is not null) + { + contentFragments.Add(new WidgetContentFragment(name) + { + Properties = + { + { "Name", pollNames[k]} + } + }); + } + k++; + } + else + { + contentFragments.Add(new MarkdownContentFragment() { Content = parsedList[i] }); + } + } + + return contentFragments; + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs new file mode 100644 index 0000000000..7f3e40eac4 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs @@ -0,0 +1,15 @@ +using System; + + +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; + +public class ContentWidgetConfig +{ + public string Name { get; } + public Type ViewComponentType { get; set; } + + public ContentWidgetConfig(string name) + { + Name = name; + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs new file mode 100644 index 0000000000..6ea786f70f --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.CmsKit.Public.Blogs; + +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; + +public interface IContentParser +{ + Task> ParseAsync(string content); +} \ No newline at end of file From 7b3442ae5fb4a5c591d5e4b542c31c4cca25c33b Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 9 Jun 2022 17:43:48 +0300 Subject: [PATCH 12/60] Removed duplication and moved to the domain --- .../Volo/CmsKit/Blogs/BlogPostConsts.cs | 4 +- .../Volo/CmsKit/Polls/ContentFragment.cs | 5 + .../Volo/CmsKit/Polls}/IContentParser.cs | 4 +- .../CmsKit/Polls}/MarkdownContentFragment.cs | 4 +- .../Volo/CmsKit/Polls/PollConsts.cs | 5 + .../CmsKit/Polls}/WidgetContentFragment.cs | 9 +- .../Polls}/CmsKitContentWidgetOptions.cs | 4 +- .../Volo/CmsKit/Polls}/ContentParser.cs | 8 +- .../Volo/CmsKit/Polls}/ContentWidgetConfig.cs | 7 +- .../CmsKit/Polls/PollViewComponentManager.cs | 19 ++++ .../CmsKit/Public/Blogs/BlogPostPublicDto.cs | 1 + .../CmsKit/Public/Blogs/ContentFragment.cs | 6 -- .../Polls/IPollViewComponentAppService.cs | 11 +++ .../Polls/PollViewComponentAppService.cs | 20 ++++ .../PollViewComponentClientProxy.Generated.cs | 27 ++++++ .../PollViewComponentClientProxy.cs | 7 ++ .../ClientProxies/cms-kit-generate-proxy.json | 63 ++++++++++++ .../Polls/PollViewComponentController.cs | 27 ++++++ .../Pages/CmsKitContentWidgetOptions.cs | 18 ---- .../Components/Pages/ContentFragment.cs | 6 -- .../Components/Pages/ContentWidgetConfig.cs | 14 --- .../Shared/Components/Pages/Default.cshtml | 2 +- .../Pages/DefaultPageViewComponent.cs | 13 +-- .../Pages/MarkdownContentFragment.cs | 6 -- .../Shared/Components/Pages/PageViewModel.cs | 1 + .../Components/Pages/WidgetContentFragment.cs | 18 ---- .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 1 + .../Public/CmsKit/Blogs/BlogPost.cshtml.cs | 12 +-- .../Public/CmsKit/Blogs/ContentParser.cs | 96 ------------------- .../Public/CmsKit/Blogs/IContentParser.cs | 10 -- 30 files changed, 219 insertions(+), 209 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs rename modules/cms-kit/src/{Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages => Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls}/IContentParser.cs (54%) rename modules/cms-kit/src/{Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs => Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls}/MarkdownContentFragment.cs (72%) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs rename modules/cms-kit/src/{Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs => Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls}/WidgetContentFragment.cs (81%) rename modules/cms-kit/src/{Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs => Volo.CmsKit.Domain/Volo/CmsKit/Polls}/CmsKitContentWidgetOptions.cs (84%) rename modules/cms-kit/src/{Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages => Volo.CmsKit.Domain/Volo/CmsKit/Polls}/ContentParser.cs (93%) rename modules/cms-kit/src/{Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs => Volo.CmsKit.Domain/Volo/CmsKit/Polls}/ContentWidgetConfig.cs (70%) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs index 94a0456c66..99e6ed5b34 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs @@ -1,6 +1,4 @@ -using Volo.CmsKit.GlobalFeatures; - -namespace Volo.CmsKit.Blogs; +namespace Volo.CmsKit.Blogs; public static class BlogPostConsts { diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs new file mode 100644 index 0000000000..403bff4f64 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs @@ -0,0 +1,5 @@ +namespace Volo.CmsKit.Polls; +public abstract class ContentFragment +{ + +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs similarity index 54% rename from modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs index 03e54ea4bb..25bc2e8f64 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/IContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; +namespace Volo.CmsKit.Polls; public interface IContentParser { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/MarkdownContentFragment.cs similarity index 72% rename from modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/MarkdownContentFragment.cs index 79cacf4575..0768f325f2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/MarkdownContentFragment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/MarkdownContentFragment.cs @@ -1,6 +1,6 @@ -namespace Volo.CmsKit.Public.Blogs; +namespace Volo.CmsKit.Polls; public class MarkdownContentFragment : ContentFragment { public string Content { get; set; } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs new file mode 100644 index 0000000000..8f8ab97073 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs @@ -0,0 +1,5 @@ +namespace Volo.CmsKit.Polls; +public static class PollConsts +{ + public static string Delimeter { get; } = "----"; +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs similarity index 81% rename from modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs index 11acbf4324..9d0d8c9761 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/WidgetContentFragment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs @@ -1,11 +1,10 @@ -using System.Collections.Generic; - -namespace Volo.CmsKit.Public.Blogs; +using System.Collections.Generic; +namespace Volo.CmsKit.Polls; public class WidgetContentFragment : ContentFragment { public string Name { get; } - + public string ViewComponentName { get; set; } public IDictionary Properties { get; } @@ -15,4 +14,4 @@ public class WidgetContentFragment : ContentFragment Name = name; Properties = new Dictionary(); } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/CmsKitContentWidgetOptions.cs similarity index 84% rename from modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/CmsKitContentWidgetOptions.cs index 7a8cc195be..251cbe463c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/CmsKitContentWidgetOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/CmsKitContentWidgetOptions.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; +namespace Volo.CmsKit.Polls; public class CmsKitContentWidgetOptions { - public Dictionary WidgetConfigs { get; } + public Dictionary WidgetConfigs { get; } public CmsKitContentWidgetOptions() { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs similarity index 93% rename from modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs index e0d53e1b6e..09bc778021 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; +namespace Volo.CmsKit.Polls; public class ContentParser : IContentParser, ITransientDependency { @@ -62,8 +62,8 @@ public class ContentParser : IContentParser, ITransientDependency } } - var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Select(p => p.Value).ToList(); - var polls = Regex.Matches(content, @"(?<=Widget Type="")(.*?)(?="")").Select(p => p.Value).ToList(); + var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); + var polls = Regex.Matches(content, @"(?<=Widget Type="")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); var contentFragments = new List(); diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentWidgetConfig.cs similarity index 70% rename from modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentWidgetConfig.cs index 7f3e40eac4..eb9c6a0656 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentWidgetConfig.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentWidgetConfig.cs @@ -1,13 +1,12 @@ -using System; +using System; - -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; +namespace Volo.CmsKit.Polls; public class ContentWidgetConfig { public string Name { get; } public Type ViewComponentType { get; set; } - + public ContentWidgetConfig(string name) { Name = name; diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs new file mode 100644 index 0000000000..f110597702 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Domain.Services; + +namespace Volo.CmsKit.Polls; +public class PollViewComponentManager : DomainService +{ + protected IContentParser ContentParser { get; set; } + public PollViewComponentManager(IContentParser contentParser) + { + ContentParser = contentParser; + } + + public virtual async Task> ParseAsync(string content) + { + return await ContentParser.ParseAsync(content); + } + +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs index 3ce3c3457a..22fb257d62 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Volo.Abp.Application.Dtos; +using Volo.CmsKit.Polls; using Volo.CmsKit.Users; namespace Volo.CmsKit.Public.Blogs; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs deleted file mode 100644 index e46316399c..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/ContentFragment.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.CmsKit.Public.Blogs; - -public abstract class ContentFragment -{ - -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs new file mode 100644 index 0000000000..994158e008 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.CmsKit.Polls; + +namespace Volo.CmsKit.Public.Polls; + +public interface IPollViewComponentAppService : IApplicationService +{ + Task> ParseAsync(string content); +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs new file mode 100644 index 0000000000..24f30d6173 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.CmsKit.Polls; + +namespace Volo.CmsKit.Public.Polls; + +public class PollViewComponentAppService : CmsKitPublicAppServiceBase, IPollViewComponentAppService +{ + protected PollViewComponentManager PollViewComponentManager { get; set; } + + public PollViewComponentAppService(PollViewComponentManager pollViewComponentManager) + { + PollViewComponentManager = pollViewComponentManager; + } + + public virtual async Task> ParseAsync(string content) + { + return await PollViewComponentManager.ParseAsync(content); + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs new file mode 100644 index 0000000000..cb841663e7 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs @@ -0,0 +1,27 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Modeling; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.CmsKit.Public.Polls; +using System.Collections.Generic; +using Volo.CmsKit.Polls; + +// ReSharper disable once CheckNamespace +namespace Volo.CmsKit.Public.Polls.ClientProxies; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IPollViewComponentAppService), typeof(PollViewComponentClientProxy))] +public partial class PollViewComponentClientProxy : ClientProxyBase, IPollViewComponentAppService +{ + public virtual async Task> ParseAsync(string content) + { + return await RequestAsync>(nameof(ParseAsync), new ClientProxyRequestTypeValue + { + { typeof(string), content } + }); + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs new file mode 100644 index 0000000000..b3ba894b58 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of PollViewComponentClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.CmsKit.Public.Polls.ClientProxies; + +public partial class PollViewComponentClientProxy +{ +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json index d39e795845..626dce7ff2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json @@ -505,6 +505,57 @@ } } }, + "Volo.CmsKit.Public.Polls.PollViewComponentController": { + "controllerName": "PollViewComponent", + "controllerGroupName": "PollViewComponent", + "isRemoteService": true, + "apiVersion": null, + "type": "Volo.CmsKit.Public.Polls.PollViewComponentController", + "interfaces": [ + { + "type": "Volo.CmsKit.Public.Polls.IPollViewComponentAppService" + } + ], + "actions": { + "ParseAsyncByContent": { + "uniqueName": "ParseAsyncByContent", + "name": "ParseAsync", + "httpMethod": "GET", + "url": "api/cms-kit-public/polls/{content}", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "content", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "content", + "name": "content", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": [], + "bindingSourceId": "Path", + "descriptorName": "" + } + ], + "returnValue": { + "type": "System.Collections.Generic.List", + "typeSimple": "[Volo.CmsKit.Polls.ContentFragment]" + }, + "allowAnonymous": null, + "implementFrom": "Volo.CmsKit.Public.Polls.IPollViewComponentAppService" + } + } + }, "Volo.CmsKit.Public.Pages.PagesPublicController": { "controllerName": "PagesPublic", "controllerGroupName": "PagesPublic", @@ -989,6 +1040,18 @@ "bindingSourceId": "ModelBinding", "descriptorName": "input" }, + { + "nameOnMethod": "input", + "name": "TagId", + "jsonName": null, + "type": "System.Guid?", + "typeSimple": "string?", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, { "nameOnMethod": "input", "name": "Sorting", diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs new file mode 100644 index 0000000000..021040fee6 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.CmsKit.Polls; + +namespace Volo.CmsKit.Public.Polls; + +[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] +[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] +[Route("api/cms-kit-public/polls")] +public class PollViewComponentController : CmsKitPublicControllerBase, IPollViewComponentAppService +{ + protected IPollViewComponentAppService PollViewComponentAppService { get; } + + public PollViewComponentController(IPollViewComponentAppService pollViewComponentAppService) + { + PollViewComponentAppService = pollViewComponentAppService; + } + + [HttpGet] + [Route("{content}")] + public virtual Task> ParseAsync(string content) + { + return PollViewComponentAppService.ParseAsync(content); + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs deleted file mode 100644 index d782299026..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/CmsKitContentWidgetOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; - -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; - -public class CmsKitContentWidgetOptions -{ - public Dictionary WidgetConfigs { get; } - - public CmsKitContentWidgetOptions() - { - WidgetConfigs = new(); - } - - public void AddWidgetConfig(string name, ContentWidgetConfig contentWidgetConfig) - { - WidgetConfigs.Add(name, contentWidgetConfig); - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs deleted file mode 100644 index c5486903dd..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentFragment.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; - -public abstract class ContentFragment -{ - -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs deleted file mode 100644 index 647427b330..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/ContentWidgetConfig.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; - -public class ContentWidgetConfig -{ - public string Name { get; } - public Type ViewComponentType { get; set; } - - public ContentWidgetConfig(string name) - { - Name = name; - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 3b6e6f0f8c..2a437dd8fb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -1,8 +1,8 @@ @addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@using Volo.CmsKit.Polls @using Volo.CmsKit.Public.Web.Renderers @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs -@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages @inject IMarkdownToHtmlRenderer MarkdownRenderer diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs index 914001b073..7449d0329e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; +using Volo.CmsKit.Public.Polls; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; @@ -22,20 +23,20 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; })] public class DefaultPageViewComponent : AbpViewComponent { - private readonly IContentParser _contentParser; + protected IPollViewComponentAppService PollViewComponentAppService { get; set; } - public DefaultPageViewComponent(IContentParser contentParser) + public DefaultPageViewComponent(IPollViewComponentAppService pollViewComponentAppService) { - _contentParser = contentParser; + PollViewComponentAppService = pollViewComponentAppService; } - + public virtual async Task InvokeAsync( Guid pageId, string title, string content) { - var contentFragments = await _contentParser.ParseAsync(content); - + var contentFragments = await PollViewComponentAppService.ParseAsync(content); + var model = new PageViewModel { Id = pageId, diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs deleted file mode 100644 index 361a4b3973..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/MarkdownContentFragment.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; - -public class MarkdownContentFragment : ContentFragment -{ - public string Content { get; set; } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs index eae24aeae4..a8dfd40458 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Volo.CmsKit.Polls; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs deleted file mode 100644 index 8dea303b0e..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/WidgetContentFragment.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; - -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; - -public class WidgetContentFragment : ContentFragment -{ - public string Name { get; } - - public string ViewComponentName { get; set; } - - public IDictionary Properties { get; } - - public WidgetContentFragment(string name) - { - Name = name; - Properties = new Dictionary(); - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index 2347e1cfc4..6115f33676 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -1,5 +1,6 @@ @page +@using Volo.CmsKit.Polls @using Volo.CmsKit.Public.Blogs @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment @using Volo.CmsKit.Public.Web.Pages diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs index e1eda83bb7..beea823f79 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs @@ -4,6 +4,7 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Public.Blogs; +using Volo.CmsKit.Public.Polls; namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; @@ -31,24 +32,23 @@ public class BlogPostModel : CmsKitPublicPageModelBase protected IBlogFeatureAppService BlogFeatureAppService { get; } - private readonly IContentParser _contentParser; + protected IPollViewComponentAppService PollViewComponentAppService { get; } public BlogPostModel( IBlogPostPublicAppService blogPostPublicAppService, - IBlogFeatureAppService blogFeaturePublicAppService -, - IContentParser contentParser) + IBlogFeatureAppService blogFeaturePublicAppService, + IPollViewComponentAppService pollViewComponentAppService) { BlogPostPublicAppService = blogPostPublicAppService; BlogFeatureAppService = blogFeaturePublicAppService; - _contentParser = contentParser; + PollViewComponentAppService = pollViewComponentAppService; } public virtual async Task OnGetAsync() { BlogPost = await BlogPostPublicAppService.GetAsync(BlogSlug, BlogPostSlug); - BlogPost.ContentFragments = await _contentParser.ParseAsync(BlogPost.Content); + BlogPost.ContentFragments = await PollViewComponentAppService.ParseAsync(BlogPost.Content); if (GlobalFeatureManager.Instance.IsEnabled()) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs deleted file mode 100644 index 56439d9d7b..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/ContentParser.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Microsoft.Extensions.Options; -using Volo.Abp.DependencyInjection; -using Volo.CmsKit.Public.Blogs; - -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; - -public class ContentParser : IContentParser, ITransientDependency -{ - private const string delimeter = "----"; - private readonly CmsKitContentWidgetOptions _options; - public ContentParser(IOptions options) - { - _options = options.Value; - } - - public async Task> ParseAsync(string content) - { - if (!_options.WidgetConfigs.Any()) - { - return new List() - { - new MarkdownContentFragment() { Content = content } - }; - } - - var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); - - var parsedList = new List(); - - if (!replacedText.Contains(delimeter)) - { - parsedList.Add(replacedText); - } - - while (replacedText.Contains(delimeter)) - { - //For parsing delimeter - var index = replacedText.IndexOf(delimeter); - if (index != 0) - { - parsedList.Add(replacedText.Substring(0, index)); - replacedText = replacedText.Substring(index, replacedText.Length - index); - index = 0; - } - - parsedList.Add(replacedText.Substring(index, delimeter.Length)); - replacedText = replacedText.Substring(delimeter.Length, replacedText.Length - delimeter.Length); - - //for parsing the other side - index = replacedText.IndexOf(delimeter); - if (index != -1) - { - parsedList.Add(replacedText.Substring(0, index)); - replacedText = replacedText.Substring(index, replacedText.Length - index); - } - else - { - parsedList.Add(replacedText); - } - } - - var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Select(p => p.Value).ToList(); - var polls = Regex.Matches(content, @"(?<=Widget Type="")(.*?)(?="")").Select(p => p.Value).ToList(); - - var contentFragments = new List(); - - for (int i = 0, k = 0; i < parsedList.Count; i++) - { - if (parsedList[i] == delimeter) - { - var name = _options.WidgetConfigs.Where(p => p.Key == polls[k]).Select(p => p.Value.Name).FirstOrDefault(); - if (name is not null) - { - contentFragments.Add(new WidgetContentFragment(name) - { - Properties = - { - { "Name", pollNames[k]} - } - }); - } - k++; - } - else - { - contentFragments.Add(new MarkdownContentFragment() { Content = parsedList[i] }); - } - } - - return contentFragments; - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs deleted file mode 100644 index 6ea786f70f..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/IContentParser.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.CmsKit.Public.Blogs; - -namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; - -public interface IContentParser -{ - Task> ParseAsync(string content); -} \ No newline at end of file From 4ad65e239af718c2712ebd87867847927e1f0953 Mon Sep 17 00:00:00 2001 From: malik masis Date: Fri, 10 Jun 2022 09:56:18 +0300 Subject: [PATCH 13/60] Fixed optional whitespace char issue --- .../src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs index 09bc778021..b586ff80fa 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs @@ -62,8 +62,8 @@ public class ContentParser : IContentParser, ITransientDependency } } - var pollNames = Regex.Matches(content, @"(?<=PollName="")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); - var polls = Regex.Matches(content, @"(?<=Widget Type="")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); + var pollNames = Regex.Matches(content, @"(?<=PollName\s*=\s*"")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); + var polls = Regex.Matches(content, @"(?<=Widget Type\s*=\s*"")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); var contentFragments = new List(); From f727afaa093c4b6dae4a192c20e3539cee8562b9 Mon Sep 17 00:00:00 2001 From: malik masis Date: Fri, 10 Jun 2022 14:36:24 +0300 Subject: [PATCH 14/60] Checked string length --- .../src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs index b586ff80fa..5bbd5a9b24 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs @@ -56,7 +56,7 @@ public class ContentParser : IContentParser, ITransientDependency parsedList.Add(replacedText.Substring(0, index)); replacedText = replacedText.Substring(index, replacedText.Length - index); } - else + else if (replacedText.Length > 0) { parsedList.Add(replacedText); } From 47c809885dcc14c248f74b256a4f89f0132caeec Mon Sep 17 00:00:00 2001 From: malik masis Date: Fri, 10 Jun 2022 14:56:19 +0300 Subject: [PATCH 15/60] Checked range of arrays --- .../Volo/CmsKit/Polls/ContentParser.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs index 5bbd5a9b24..38c0737012 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs @@ -71,16 +71,19 @@ public class ContentParser : IContentParser, ITransientDependency { if (parsedList[i] == delimeter) { - var name = _options.WidgetConfigs.Where(p => p.Key == polls[k]).Select(p => p.Value.Name).FirstOrDefault(); - if (name is not null) + if (polls.Count > k) { - contentFragments.Add(new WidgetContentFragment(name) + var name = _options.WidgetConfigs.Where(p => p.Key == polls[k]).Select(p => p.Value.Name).FirstOrDefault(); + if (name is not null && pollNames.Count > k) { - Properties = + contentFragments.Add(new WidgetContentFragment(name) { - { "Name", pollNames[k]} - } - }); + Properties = + { + { "Name", pollNames[k]} + } + }); + } } k++; } From 5aca43a2b58ca441c7ff8e568786c8c9c7efb151 Mon Sep 17 00:00:00 2001 From: malik masis Date: Fri, 10 Jun 2022 14:58:51 +0300 Subject: [PATCH 16/60] Added PollViewComponentManager_Test --- .../Polls/PollViewComponentManager_Test.cs | 123 ++++++++++++++++++ .../Volo.CmsKit.TestBase/CmsKitTestData.cs | 4 + 2 files changed, 127 insertions(+) create mode 100644 modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs new file mode 100644 index 0000000000..67ae5982f1 --- /dev/null +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.Extensions.Options; +using Shouldly; +using Xunit; + +namespace Volo.CmsKit.Polls; + +public class PollViewComponentManager_Test : CmsKitDomainTestBase +{ + private readonly PollViewComponentManager pollManager; + private readonly CmsKitTestData testData; + private readonly IOptions _options; + + public PollViewComponentManager_Test() + { + pollManager = GetRequiredService(); + testData = GetRequiredService(); + _options = GetRequiredService>(); + } + + [Fact] + public async Task ParseAsync_ShouldWorkWithoutConfigOptions() + { + var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Type= ""Poll"" PollName =""poll-name""] + Thanks _for_ *your * feedback."; + + var page = await pollManager.ParseAsync(content); + + page.ShouldNotBeNull(); + page.Count.ShouldBe(1);//Ignored Widget + } + + [Fact] + public async Task ParseAsync_ShouldWorkWithWrongConfigOptions() + { + _options.Value.AddWidgetConfig(testData.WidgetName, new ContentWidgetConfig(testData.PollName)); + + var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Type= ""Poll"" PollName =""poll-name""] + Thanks _for_ *your * feedback."; + + var page = await pollManager.ParseAsync(content); + + page.ShouldNotBeNull(); + page.Count.ShouldBe(2); + } + + [Fact] + public async Task ParseAsync_ShouldWorkWithWrongWidgetType() + { + _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + + var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Wrong Type= ""Poll"" PollName =""poll-name""] + Thanks _for_ *your * feedback."; + + var page = await pollManager.ParseAsync(content); + + page.ShouldNotBeNull(); + page.Count.ShouldBe(2); + } + + [Fact] + public async Task ParseAsync_ShouldWorkWithWrongPollName() + { + _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + + var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Type= ""Poll"" PollWrongName =""poll-name""] + Thanks _for_ *your * feedback."; + + var page = await pollManager.ParseAsync(content); + + page.ShouldNotBeNull(); + page.Count.ShouldBe(2); + } + + [Theory] + [MemberData(nameof(ExampleData))] + public async Task ParseAsync_ShouldWorkProperlyWithCorrectInputs(string content, int expectedLine) + { + _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + + var page = await pollManager.ParseAsync(content); + + page.ShouldNotBeNull(); + page.Count.ShouldBe(expectedLine); + } + + public static IEnumerable ExampleData => + new List + { + new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Type=""Poll"" PollName=""poll-name""] + Thanks _for_ *your * feedback.", 3}, + + new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Type=""Poll"" PollName=""poll-name""] + Thanks _for_ *your * feedback. + [Widget Type=""Poll"" PollName=""poll-name1""]", 4 }, + + new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner. + Thanks _for_ *your * feedback. + [Widget Type=""Poll"" PollName=""poll-name""]", 2 }, + + new object[] { @"[Widget Type=""Poll"" PollName=""poll-name""] gg [Widget Type=""Poll"" PollName=""poll-name1""]**ABP Framework** is completely open source and developed in a community-driven manner. + Thanks _for_ *your * feedback. + Thanks _for_ *your * feedback.", 4}, + + new object[] { @"Thanks _for_ *your * feedback. + Thanks _for_ *your * feedback.", 1} + }; + +} + + + + + + diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs index d47f139560..6445fb86f4 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs @@ -127,4 +127,8 @@ public class CmsKitTestData : ISingletonDependency public string MenuItem_3_Name { get; } = "Products"; public string MenuItem_3_Url { get; } = "/products"; + + public string PollName { get; } = "Poll"; + + public string WidgetName { get; } = "CmsPollByName"; } From 4c7e4c8e2e578b3e5fafb0b23620b4701f9aa8bc Mon Sep 17 00:00:00 2001 From: malik masis Date: Sun, 12 Jun 2022 00:22:53 +0300 Subject: [PATCH 17/60] Fixed typo of the variable name --- .../Polls/PollViewComponentManager_Test.cs | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs index 67ae5982f1..dbe91f2f14 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Options; using Shouldly; @@ -27,10 +26,10 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var page = await pollManager.ParseAsync(content); + var poll = await pollManager.ParseAsync(content); - page.ShouldNotBeNull(); - page.Count.ShouldBe(1);//Ignored Widget + poll.ShouldNotBeNull(); + poll.Count.ShouldBe(1);//Ignored Widget } [Fact] @@ -42,10 +41,10 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var page = await pollManager.ParseAsync(content); + var poll = await pollManager.ParseAsync(content); - page.ShouldNotBeNull(); - page.Count.ShouldBe(2); + poll.ShouldNotBeNull(); + poll.Count.ShouldBe(2); } [Fact] @@ -57,10 +56,10 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Wrong Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var page = await pollManager.ParseAsync(content); + var poll = await pollManager.ParseAsync(content); - page.ShouldNotBeNull(); - page.Count.ShouldBe(2); + poll.ShouldNotBeNull(); + poll.Count.ShouldBe(2); } [Fact] @@ -72,22 +71,22 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollWrongName =""poll-name""] Thanks _for_ *your * feedback."; - var page = await pollManager.ParseAsync(content); + var poll = await pollManager.ParseAsync(content); - page.ShouldNotBeNull(); - page.Count.ShouldBe(2); + poll.ShouldNotBeNull(); + poll.Count.ShouldBe(2); } [Theory] - [MemberData(nameof(ExampleData))] + [MemberData(nameof(ExampleData))] public async Task ParseAsync_ShouldWorkProperlyWithCorrectInputs(string content, int expectedLine) { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); - var page = await pollManager.ParseAsync(content); + var poll = await pollManager.ParseAsync(content); - page.ShouldNotBeNull(); - page.Count.ShouldBe(expectedLine); + poll.ShouldNotBeNull(); + poll.Count.ShouldBe(expectedLine); } public static IEnumerable ExampleData => From 57ec03370a2fdf22d0cb43f93904b1895de4ba84 Mon Sep 17 00:00:00 2001 From: malik masis Date: Mon, 13 Jun 2022 15:20:49 +0300 Subject: [PATCH 18/60] Changed the widget structure --- .../CmsKit/Polls/WidgetContentFragment.cs | 2 +- .../Volo/CmsKit/Polls/ContentParser.cs | 43 +++++++++++++++---- .../Polls/PollViewComponentManager_Test.cs | 17 ++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs index 9d0d8c9761..115e69e134 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs @@ -7,7 +7,7 @@ public class WidgetContentFragment : ContentFragment public string ViewComponentName { get; set; } - public IDictionary Properties { get; } + public IDictionary Properties { get; set; } public WidgetContentFragment(string name) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs index 38c0737012..b207a4731a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs @@ -62,8 +62,9 @@ public class ContentParser : IContentParser, ITransientDependency } } - var pollNames = Regex.Matches(content, @"(?<=PollName\s*=\s*"")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); - var polls = Regex.Matches(content, @"(?<=Widget Type\s*=\s*"")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); + + Dictionary>> parsedWidgets = new(); + ParseWidgets(content, parsedWidgets); var contentFragments = new List(); @@ -71,17 +72,23 @@ public class ContentParser : IContentParser, ITransientDependency { if (parsedList[i] == delimeter) { - if (polls.Count > k) + var values = parsedWidgets.GetOrDefault($"{k}.Widget").Select(p => p.Value).ToList(); + var keys = parsedWidgets.GetOrDefault($"{k}.Widget").Select(p => p.Key).ToList(); + + if (parsedWidgets.Count > k) { - var name = _options.WidgetConfigs.Where(p => p.Key == polls[k]).Select(p => p.Value.Name).FirstOrDefault(); - if (name is not null && pollNames.Count > k) + var name = _options.WidgetConfigs.Where(p => p.Key == values[0]).Select(p => p.Value.Name).FirstOrDefault(); + if (name is not null && parsedWidgets.Count > k) { + var properties = new Dictionary(); + for (int kv = 0; kv < values.Count; kv++) + { + properties.Add(keys[kv], values[kv]); + } + contentFragments.Add(new WidgetContentFragment(name) { - Properties = - { - { "Name", pollNames[k]} - } + Properties = properties }); } } @@ -95,4 +102,22 @@ public class ContentParser : IContentParser, ITransientDependency return contentFragments; } + + private void ParseWidgets(string content, Dictionary>> parsedWidgets) + { + var widgets = Regex.Matches(content, @"(?<=\[Widget)(.*?)(?=\])").Cast().Select(p => p.Value).ToList(); + for (int p = 0; p < widgets.Count; p++) + { + var preparedContent = string.Join("", widgets[p]); + var keys = Regex.Matches(preparedContent, @"(?<=[\[Widget]?\s)(.*?)(?=="")").Cast().Select(p => p.Value).Where(p => p != string.Empty).ToList(); + var values = Regex.Matches(preparedContent, @"(?<=\s*[a-zA-Z]*=\s*"")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); + + var list = new List>(); + for (int kv = 0; kv < keys.Count; kv++) + { + list.Add(new KeyValuePair(keys[kv], values[kv])); + } + parsedWidgets.Add($"{p}.Widget", list); + } + } } \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs index dbe91f2f14..3b0c4aee14 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs @@ -19,6 +19,23 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase _options = GetRequiredService>(); } + [Fact] + public async Task AA_ParseAsync_ShouldWorkMoreDynamically() + { + _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + _options.Value.AddWidgetConfig("ImageGallery", new ContentWidgetConfig("ImageGallery"));//test + + var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. + [Widget Type=""Poll"" PollName =""poll-name""] + Thanks _for_ *your * feedback. + [Widget Type=""ImageGallery"" GalleryName=""Xyz"" Source=""GoogleDrive""]"; + + var poll = await pollManager.ParseAsync(content); + + poll.ShouldNotBeNull(); + poll.Count.ShouldBe(4); + } + [Fact] public async Task ParseAsync_ShouldWorkWithoutConfigOptions() { From 16f753270cdbebc6e96ee64052bbcf14d4740101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 13 Jun 2022 16:07:06 +0300 Subject: [PATCH 19/60] Revised content fragments --- .../Volo/CmsKit/Contents/ContentFragment.cs | 10 +++++++ .../Volo/CmsKit/Contents}/ContentParser.cs | 22 ++++++++++++--- .../Contents}/MarkdownContentFragment.cs | 2 +- .../CmsKit/Contents}/WidgetContentFragment.cs | 2 +- .../Volo/CmsKit/Polls/ContentFragment.cs | 5 ---- .../Volo/CmsKit/Polls/IContentParser.cs | 9 ------- .../CmsKit/Polls/PollViewComponentManager.cs | 19 ------------- .../CmsKit/Public/Blogs/BlogPostPublicDto.cs | 1 + .../Volo/CmsKit/Public/Pages/PageDto.cs | 4 +++ .../Polls/IPollViewComponentAppService.cs | 11 -------- .../Public/Blogs/BlogPostPublicAppService.cs | 14 +++++++--- .../Public/Pages/PagePublicAppService.cs | 9 +++++-- .../Polls/PollViewComponentAppService.cs | 20 -------------- .../PublicApplicationAutoMapperProfile.cs | 3 ++- .../PollViewComponentClientProxy.Generated.cs | 27 ------------------- .../PollViewComponentClientProxy.cs | 7 ----- .../Polls/PollViewComponentController.cs | 27 ------------------- .../Shared/Components/Pages/Default.cshtml | 14 +++++----- .../Pages/DefaultPageViewComponent.cs | 17 ++++-------- .../Shared/Components/Pages/PageViewModel.cs | 1 + .../Public/CmsKit/Blogs/BlogPost.cshtml.cs | 9 +------ .../Pages/Public/CmsKit/Pages/Index.cshtml | 4 ++- .../Polls/PollViewComponentManager_Test.cs | 5 ++-- 23 files changed, 74 insertions(+), 168 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentFragment.cs rename modules/cms-kit/src/{Volo.CmsKit.Domain/Volo/CmsKit/Polls => Volo.CmsKit.Common.Application/Volo/CmsKit/Contents}/ContentParser.cs (84%) rename modules/cms-kit/src/{Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls => Volo.CmsKit.Common.Application/Volo/CmsKit/Contents}/MarkdownContentFragment.cs (74%) rename modules/cms-kit/src/{Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls => Volo.CmsKit.Common.Application/Volo/CmsKit/Contents}/WidgetContentFragment.cs (92%) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentFragment.cs new file mode 100644 index 0000000000..20574f830c --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentFragment.cs @@ -0,0 +1,10 @@ +using System; +using Volo.Abp.ObjectExtending; + +namespace Volo.CmsKit.Contents; + +[Serializable] +public class ContentFragment : ExtensibleObject +{ + public string Type { get; set; } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs similarity index 84% rename from modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs rename to modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index b207a4731a..c4da64a986 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -3,14 +3,17 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.Extensions.Options; +using Volo.Abp.Data; using Volo.Abp.DependencyInjection; +using Volo.CmsKit.Polls; -namespace Volo.CmsKit.Polls; +namespace Volo.CmsKit.Contents; -public class ContentParser : IContentParser, ITransientDependency +public class ContentParser : ITransientDependency { private const string delimeter = "----"; private readonly CmsKitContentWidgetOptions _options; + public ContentParser(IOptions options) { _options = options.Value; @@ -18,6 +21,13 @@ public class ContentParser : IContentParser, ITransientDependency public async Task> ParseAsync(string content) { + return new List { + new ContentFragment() { Type = "Markdown" }.SetProperty("Content", "This is *a markdown* text."), + new ContentFragment() { Type = "Widget" }.SetProperty("Type", "Poll").SetProperty("Code", "6dhah8dd"), + new ContentFragment() { Type = "Markdown" }.SetProperty("Content", "This is *another markdown* text.") + }; + + /* if (!_options.WidgetConfigs.Any()) { return new List() @@ -101,6 +111,7 @@ public class ContentParser : IContentParser, ITransientDependency } return contentFragments; + */ } private void ParseWidgets(string content, Dictionary>> parsedWidgets) @@ -109,14 +120,17 @@ public class ContentParser : IContentParser, ITransientDependency for (int p = 0; p < widgets.Count; p++) { var preparedContent = string.Join("", widgets[p]); - var keys = Regex.Matches(preparedContent, @"(?<=[\[Widget]?\s)(.*?)(?=="")").Cast().Select(p => p.Value).Where(p => p != string.Empty).ToList(); - var values = Regex.Matches(preparedContent, @"(?<=\s*[a-zA-Z]*=\s*"")(.*?)(?="")").Cast().Select(p => p.Value).ToList(); + var keys = Regex.Matches(preparedContent, @"(?<=[\[Widget]?\s)(.*?)(?=="")").Cast() + .Select(p => p.Value).Where(p => p != string.Empty).ToList(); + var values = Regex.Matches(preparedContent, @"(?<=\s*[a-zA-Z]*=\s*"")(.*?)(?="")").Cast() + .Select(p => p.Value).ToList(); var list = new List>(); for (int kv = 0; kv < keys.Count; kv++) { list.Add(new KeyValuePair(keys[kv], values[kv])); } + parsedWidgets.Add($"{p}.Widget", list); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/MarkdownContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs similarity index 74% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/MarkdownContentFragment.cs rename to modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs index 0768f325f2..6aeaa323ba 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/MarkdownContentFragment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs @@ -1,4 +1,4 @@ -namespace Volo.CmsKit.Polls; +namespace Volo.CmsKit.Contents; public class MarkdownContentFragment : ContentFragment { diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs similarity index 92% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs rename to modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs index 115e69e134..8b5e697418 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/WidgetContentFragment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Volo.CmsKit.Polls; +namespace Volo.CmsKit.Contents; public class WidgetContentFragment : ContentFragment { public string Name { get; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs deleted file mode 100644 index 403bff4f64..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/ContentFragment.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Volo.CmsKit.Polls; -public abstract class ContentFragment -{ - -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs deleted file mode 100644 index 25bc2e8f64..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/IContentParser.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Volo.CmsKit.Polls; - -public interface IContentParser -{ - Task> ParseAsync(string content); -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs deleted file mode 100644 index f110597702..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/PollViewComponentManager.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace Volo.CmsKit.Polls; -public class PollViewComponentManager : DomainService -{ - protected IContentParser ContentParser { get; set; } - public PollViewComponentManager(IContentParser contentParser) - { - ContentParser = contentParser; - } - - public virtual async Task> ParseAsync(string content) - { - return await ContentParser.ParseAsync(content); - } - -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs index 22fb257d62..06e7eec7a5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Volo.Abp.Application.Dtos; +using Volo.CmsKit.Contents; using Volo.CmsKit.Polls; using Volo.CmsKit.Users; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs index 64175d0f18..a336844289 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using Volo.Abp.Application.Dtos; +using Volo.CmsKit.Contents; namespace Volo.CmsKit.Public.Pages; @@ -11,6 +13,8 @@ public class PageDto : EntityDto public string Slug { get; set; } public string Content { get; set; } + + public List ContentFragments { get; set; } public string Script { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs deleted file mode 100644 index 994158e008..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Polls/IPollViewComponentAppService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.Application.Services; -using Volo.CmsKit.Polls; - -namespace Volo.CmsKit.Public.Polls; - -public interface IPollViewComponentAppService : IApplicationService -{ - Task> ParseAsync(string content); -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs index 65e6c6fa20..ebdda3d293 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Blogs; +using Volo.CmsKit.Contents; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Users; @@ -16,22 +17,29 @@ public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPub protected IBlogRepository BlogRepository { get; } protected IBlogPostRepository BlogPostRepository { get; } + protected ContentParser ContentParser { get; } public BlogPostPublicAppService( IBlogRepository blogRepository, - IBlogPostRepository blogPostRepository) + IBlogPostRepository blogPostRepository, + ContentParser contentParser) { BlogRepository = blogRepository; BlogPostRepository = blogPostRepository; + ContentParser = contentParser; } - public virtual async Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug) + public virtual async Task GetAsync( + [NotNull] string blogSlug, [NotNull] string blogPostSlug) { var blog = await BlogRepository.GetBySlugAsync(blogSlug); var blogPost = await BlogPostRepository.GetBySlugAsync(blog.Id, blogPostSlug); - return ObjectMapper.Map(blogPost); + var blogPostDto = ObjectMapper.Map(blogPost); + blogPostDto.ContentFragments = await ContentParser.ParseAsync(blogPost.Content); + + return blogPostDto; } public virtual async Task> GetListAsync([NotNull] string blogSlug, BlogPostGetListInput input) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs index 258ef935ed..2bae7c350f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PagePublicAppService.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Volo.Abp.GlobalFeatures; +using Volo.CmsKit.Contents; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Pages; @@ -9,10 +10,12 @@ namespace Volo.CmsKit.Public.Pages; public class PagePublicAppService : CmsKitPublicAppServiceBase, IPagePublicAppService { protected IPageRepository PageRepository { get; } + protected ContentParser ContentParser { get; } - public PagePublicAppService(IPageRepository pageRepository) + public PagePublicAppService(IPageRepository pageRepository, ContentParser contentParser) { PageRepository = pageRepository; + ContentParser = contentParser; } public virtual async Task FindBySlugAsync(string slug) @@ -24,6 +27,8 @@ public class PagePublicAppService : CmsKitPublicAppServiceBase, IPagePublicAppSe return null; } - return ObjectMapper.Map(page); + var pageDto = ObjectMapper.Map(page); + pageDto.ContentFragments = await ContentParser.ParseAsync(page.Content); + return pageDto; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs deleted file mode 100644 index 24f30d6173..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Polls/PollViewComponentAppService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.CmsKit.Polls; - -namespace Volo.CmsKit.Public.Polls; - -public class PollViewComponentAppService : CmsKitPublicAppServiceBase, IPollViewComponentAppService -{ - protected PollViewComponentManager PollViewComponentManager { get; set; } - - public PollViewComponentAppService(PollViewComponentManager pollViewComponentManager) - { - PollViewComponentManager = pollViewComponentManager; - } - - public virtual async Task> ParseAsync(string content) - { - return await PollViewComponentManager.ParseAsync(content); - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs index a6b7e497ac..a242e28c3b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs @@ -32,7 +32,8 @@ public class PublicApplicationAutoMapperProfile : Profile CreateMap(); - CreateMap(MemberList.None); + CreateMap(MemberList.None) //TODO: Remove MemberList.None (enable validation) + .Ignore(x => x.ContentFragments); CreateMap(); diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs deleted file mode 100644 index cb841663e7..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.Generated.cs +++ /dev/null @@ -1,27 +0,0 @@ -// This file is automatically generated by ABP framework to use MVC Controllers from CSharp -using System; -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Http.Client; -using Volo.Abp.Http.Modeling; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Http.Client.ClientProxying; -using Volo.CmsKit.Public.Polls; -using System.Collections.Generic; -using Volo.CmsKit.Polls; - -// ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Polls.ClientProxies; - -[Dependency(ReplaceServices = true)] -[ExposeServices(typeof(IPollViewComponentAppService), typeof(PollViewComponentClientProxy))] -public partial class PollViewComponentClientProxy : ClientProxyBase, IPollViewComponentAppService -{ - public virtual async Task> ParseAsync(string content) - { - return await RequestAsync>(nameof(ParseAsync), new ClientProxyRequestTypeValue - { - { typeof(string), content } - }); - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs deleted file mode 100644 index b3ba894b58..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/PollViewComponentClientProxy.cs +++ /dev/null @@ -1,7 +0,0 @@ -// This file is part of PollViewComponentClientProxy, you can customize it here -// ReSharper disable once CheckNamespace -namespace Volo.CmsKit.Public.Polls.ClientProxies; - -public partial class PollViewComponentClientProxy -{ -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs deleted file mode 100644 index 021040fee6..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Polls/PollViewComponentController.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Volo.Abp; -using Volo.CmsKit.Polls; - -namespace Volo.CmsKit.Public.Polls; - -[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)] -[Area(CmsKitPublicRemoteServiceConsts.ModuleName)] -[Route("api/cms-kit-public/polls")] -public class PollViewComponentController : CmsKitPublicControllerBase, IPollViewComponentAppService -{ - protected IPollViewComponentAppService PollViewComponentAppService { get; } - - public PollViewComponentController(IPollViewComponentAppService pollViewComponentAppService) - { - PollViewComponentAppService = pollViewComponentAppService; - } - - [HttpGet] - [Route("{content}")] - public virtual Task> ParseAsync(string content) - { - return PollViewComponentAppService.ParseAsync(content); - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 2a437dd8fb..a7a6d70766 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -1,8 +1,8 @@ @addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap -@using Volo.CmsKit.Polls @using Volo.CmsKit.Public.Web.Renderers -@using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs +@using Volo.Abp.Data +@using Volo.CmsKit.Contents @inject IMarkdownToHtmlRenderer MarkdownRenderer @@ -10,15 +10,15 @@ - @foreach (var contentFragment in Model.ContentFragments) + @foreach (ContentFragment contentFragment in Model.ContentFragments) { - if (contentFragment is MarkdownContentFragment markdownContentFragment) + if (contentFragment.Type == "Markdown") //TODO: Constant { - @Html.Raw(await MarkdownRenderer.RenderAsync(markdownContentFragment.Content)) + @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) } - else if (contentFragment is WidgetContentFragment widgetContentFragment) + else if (contentFragment.Type == "Widget") //TODO: Constant { - @await Component.InvokeAsync(widgetContentFragment.Name, widgetContentFragment.Properties) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties) } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs index 7449d0329e..43706cee56 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs @@ -1,10 +1,11 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -using Volo.CmsKit.Public.Polls; +using Volo.CmsKit.Contents; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; @@ -21,22 +22,14 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; { "/Pages/Public/CmsKit/highlightOnLoad.js" })] -public class DefaultPageViewComponent : AbpViewComponent +public class DefaultPageViewComponent : AbpViewComponent //TODO: Remove component, directly render in the page { - protected IPollViewComponentAppService PollViewComponentAppService { get; set; } - - public DefaultPageViewComponent(IPollViewComponentAppService pollViewComponentAppService) - { - PollViewComponentAppService = pollViewComponentAppService; - } - public virtual async Task InvokeAsync( Guid pageId, string title, - string content) + string content, + List contentFragments) { - var contentFragments = await PollViewComponentAppService.ParseAsync(content); - var model = new PageViewModel { Id = pageId, diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs index a8dfd40458..acd5ed2447 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Volo.CmsKit.Contents; using Volo.CmsKit.Polls; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs index beea823f79..6227190ab8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml.cs @@ -4,7 +4,6 @@ using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Blogs; using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Public.Blogs; -using Volo.CmsKit.Public.Polls; namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; @@ -32,23 +31,17 @@ public class BlogPostModel : CmsKitPublicPageModelBase protected IBlogFeatureAppService BlogFeatureAppService { get; } - protected IPollViewComponentAppService PollViewComponentAppService { get; } - - public BlogPostModel( IBlogPostPublicAppService blogPostPublicAppService, - IBlogFeatureAppService blogFeaturePublicAppService, - IPollViewComponentAppService pollViewComponentAppService) + IBlogFeatureAppService blogFeaturePublicAppService) { BlogPostPublicAppService = blogPostPublicAppService; BlogFeatureAppService = blogFeaturePublicAppService; - PollViewComponentAppService = pollViewComponentAppService; } public virtual async Task OnGetAsync() { BlogPost = await BlogPostPublicAppService.GetAsync(BlogSlug, BlogPostSlug); - BlogPost.ContentFragments = await PollViewComponentAppService.ParseAsync(BlogPost.Content); if (GlobalFeatureManager.Instance.IsEnabled()) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml index a3f1d0c95e..5296315e1c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml @@ -1,5 +1,6 @@ @page @using Microsoft.AspNetCore.Mvc.Localization +@using Volo.CmsKit.Contents @using Volo.CmsKit.Localization @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages @@ -27,5 +28,6 @@ { pageId = Model.Page.Id, title = Model.Page.Title, - content = Model.Page.Content + content = Model.Page.Content, + contentFragments = Model.Page.ContentFragments }) \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs index 3b0c4aee14..272821cb9e 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs @@ -8,17 +8,16 @@ namespace Volo.CmsKit.Polls; public class PollViewComponentManager_Test : CmsKitDomainTestBase { - private readonly PollViewComponentManager pollManager; private readonly CmsKitTestData testData; private readonly IOptions _options; public PollViewComponentManager_Test() { - pollManager = GetRequiredService(); testData = GetRequiredService(); _options = GetRequiredService>(); } + /* TODO: Enable again [Fact] public async Task AA_ParseAsync_ShouldWorkMoreDynamically() { @@ -129,7 +128,7 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase new object[] { @"Thanks _for_ *your * feedback. Thanks _for_ *your * feedback.", 1} }; - +*/ } From 0fc407f723db73149fd06a6badc3133fba38797d Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 10:18:51 +0300 Subject: [PATCH 20/60] Moved unit test to app layer --- .../Contents/ContentParser_Test.cs} | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) rename modules/cms-kit/test/{Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs => Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs} (87%) diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs similarity index 87% rename from modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs rename to modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs index 272821cb9e..f1b877bac8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Polls/PollViewComponentManager_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs @@ -2,22 +2,23 @@ using System.Threading.Tasks; using Microsoft.Extensions.Options; using Shouldly; +using Volo.CmsKit.Polls; using Xunit; -namespace Volo.CmsKit.Polls; - -public class PollViewComponentManager_Test : CmsKitDomainTestBase +namespace Volo.CmsKit.Contents; +public class ContentParser_Test : CmsKitDomainTestBase { private readonly CmsKitTestData testData; private readonly IOptions _options; + private readonly ContentParser contentParser; - public PollViewComponentManager_Test() + public ContentParser_Test() { testData = GetRequiredService(); _options = GetRequiredService>(); + contentParser = GetRequiredService(); } - /* TODO: Enable again [Fact] public async Task AA_ParseAsync_ShouldWorkMoreDynamically() { @@ -29,10 +30,10 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase Thanks _for_ *your * feedback. [Widget Type=""ImageGallery"" GalleryName=""Xyz"" Source=""GoogleDrive""]"; - var poll = await pollManager.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(4); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(4); } [Fact] @@ -42,7 +43,7 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await pollManager.ParseAsync(content); + var poll = await contentParser.ParseAsync(content); poll.ShouldNotBeNull(); poll.Count.ShouldBe(1);//Ignored Widget @@ -57,7 +58,7 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await pollManager.ParseAsync(content); + var poll = await contentParser.ParseAsync(content); poll.ShouldNotBeNull(); poll.Count.ShouldBe(2); @@ -72,7 +73,7 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Wrong Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await pollManager.ParseAsync(content); + var poll = await contentParser.ParseAsync(content); poll.ShouldNotBeNull(); poll.Count.ShouldBe(2); @@ -87,7 +88,7 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollWrongName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await pollManager.ParseAsync(content); + var poll = await contentParser.ParseAsync(content); poll.ShouldNotBeNull(); poll.Count.ShouldBe(2); @@ -99,7 +100,7 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); - var poll = await pollManager.ParseAsync(content); + var poll = await contentParser.ParseAsync(content); poll.ShouldNotBeNull(); poll.Count.ShouldBe(expectedLine); @@ -128,11 +129,4 @@ public class PollViewComponentManager_Test : CmsKitDomainTestBase new object[] { @"Thanks _for_ *your * feedback. Thanks _for_ *your * feedback.", 1} }; -*/ } - - - - - - From 69c0a539a20aaad3093a70e59cb501e53b112622 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 10:19:58 +0300 Subject: [PATCH 21/60] Fixed unbuildable code --- .../Volo/CmsKit/Polls/PollConsts.cs | 5 ----- .../Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs | 1 - .../CmsKit/Shared/Components/Pages/PageViewModel.cs | 1 - .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 10 +++++----- 4 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs deleted file mode 100644 index 8f8ab97073..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Polls/PollConsts.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Volo.CmsKit.Polls; -public static class PollConsts -{ - public static string Delimeter { get; } = "----"; -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs index 06e7eec7a5..695f50836e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Volo.Abp.Application.Dtos; using Volo.CmsKit.Contents; -using Volo.CmsKit.Polls; using Volo.CmsKit.Users; namespace Volo.CmsKit.Public.Blogs; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs index acd5ed2447..8dcc71c3b2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using Volo.CmsKit.Contents; -using Volo.CmsKit.Polls; namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index 6115f33676..c6fabf0f81 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -1,6 +1,6 @@ @page -@using Volo.CmsKit.Polls +@using Volo.Abp.Data @using Volo.CmsKit.Public.Blogs @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment @using Volo.CmsKit.Public.Web.Pages @@ -69,13 +69,13 @@

@foreach (var contentFragment in Model.BlogPost.ContentFragments) { - if (contentFragment is MarkdownContentFragment markdownContentFragment) + if (contentFragment.Type == "Markdown") //TODO: Constant { - @Html.Raw(await MarkdownRenderer.RenderAsync(markdownContentFragment.Content)) + @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) } - else if (contentFragment is WidgetContentFragment widgetContentFragment) + else if (contentFragment.Type == "Widget") //TODO: Constant { - @await Component.InvokeAsync(widgetContentFragment.Name, widgetContentFragment.Properties) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties) } } From 9fba0fa717ee98839c13a6a6bb860f091eb0383b Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 10:28:20 +0300 Subject: [PATCH 22/60] Fixed creating instance wrongly --- .../Contents/ContentParser_Test.cs | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs index f1b877bac8..00dc4c184e 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs @@ -10,13 +10,12 @@ public class ContentParser_Test : CmsKitDomainTestBase { private readonly CmsKitTestData testData; private readonly IOptions _options; - private readonly ContentParser contentParser; + private ContentParser contentParser; public ContentParser_Test() { testData = GetRequiredService(); _options = GetRequiredService>(); - contentParser = GetRequiredService(); } [Fact] @@ -24,6 +23,7 @@ public class ContentParser_Test : CmsKitDomainTestBase { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); _options.Value.AddWidgetConfig("ImageGallery", new ContentWidgetConfig("ImageGallery"));//test + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Type=""Poll"" PollName =""poll-name""] @@ -43,55 +43,58 @@ public class ContentParser_Test : CmsKitDomainTestBase [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(1);//Ignored Widget + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(1);//Ignored Widget } [Fact] public async Task ParseAsync_ShouldWorkWithWrongConfigOptions() { _options.Value.AddWidgetConfig(testData.WidgetName, new ContentWidgetConfig(testData.PollName)); + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(2); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(2); } [Fact] public async Task ParseAsync_ShouldWorkWithWrongWidgetType() { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Wrong Type= ""Poll"" PollName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(2); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(2); } [Fact] public async Task ParseAsync_ShouldWorkWithWrongPollName() { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. [Widget Type= ""Poll"" PollWrongName =""poll-name""] Thanks _for_ *your * feedback."; - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(2); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(2); } [Theory] @@ -99,11 +102,12 @@ public class ContentParser_Test : CmsKitDomainTestBase public async Task ParseAsync_ShouldWorkProperlyWithCorrectInputs(string content, int expectedLine) { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + contentParser = new ContentParser(_options); - var poll = await contentParser.ParseAsync(content); + var widgets = await contentParser.ParseAsync(content); - poll.ShouldNotBeNull(); - poll.Count.ShouldBe(expectedLine); + widgets.ShouldNotBeNull(); + widgets.Count.ShouldBe(expectedLine); } public static IEnumerable ExampleData => From 5058d57ec3839b99b127680b540671dd25ad56c8 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 10:37:45 +0300 Subject: [PATCH 23/60] Fixed the auto mapper issue --- .../CmsKit/Public/PublicApplicationAutoMapperProfile.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs index a242e28c3b..704a03778c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs @@ -30,10 +30,11 @@ public class PublicApplicationAutoMapperProfile : Profile CreateMap(); - CreateMap(); + CreateMap() + .Ignore(x => x.ContentFragments); - CreateMap(MemberList.None) //TODO: Remove MemberList.None (enable validation) - .Ignore(x => x.ContentFragments); + CreateMap() + .Ignore(x => x.ContentFragments); CreateMap(); From c056c4918e86e63accc9bb56ef3465e909128617 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 13:02:15 +0300 Subject: [PATCH 24/60] Removed unnecessary classes --- .../CmsKit/Contents/MarkdownContentFragment.cs | 6 ------ .../CmsKit/Contents/WidgetContentFragment.cs | 17 ----------------- 2 files changed, 23 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs deleted file mode 100644 index 6aeaa323ba..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/MarkdownContentFragment.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.CmsKit.Contents; - -public class MarkdownContentFragment : ContentFragment -{ - public string Content { get; set; } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs deleted file mode 100644 index 8b5e697418..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/WidgetContentFragment.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; - -namespace Volo.CmsKit.Contents; -public class WidgetContentFragment : ContentFragment -{ - public string Name { get; } - - public string ViewComponentName { get; set; } - - public IDictionary Properties { get; set; } - - public WidgetContentFragment(string name) - { - Name = name; - Properties = new Dictionary(); - } -} From 0ea5554fb7187a7bce9ac0e43f6e7cbd6372558b Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 13:02:59 +0300 Subject: [PATCH 25/60] Worked properly with hard-coded content parser --- .../CmsKit/Shared/Components/Pages/Default.cshtml | 10 +++++++--- .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index a7a6d70766..edb6f1dbec 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -17,9 +17,13 @@ @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) } else if (contentFragment.Type == "Widget") //TODO: Constant - { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties) + { + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), new + { + extraProperties = contentFragment.ExtraProperties + } + ) + } } - } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index c6fabf0f81..eac43e41fc 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -75,10 +75,13 @@ } else if (contentFragment.Type == "Widget") //TODO: Constant { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), new + { + extraProperties = contentFragment.ExtraProperties + } + ) } } -

@if (Model.BlogPost.LastModificationTime != null) { From a07eaf4c4536b23e37a3692990d27acbec80e1bd Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 14:45:42 +0300 Subject: [PATCH 26/60] Used dynamic values instead of hard-coded in ContentParser --- .../Volo/CmsKit/Contents/ContentParser.cs | 31 +++++++------------ .../Shared/Components/Pages/Default.cshtml | 14 ++++----- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index c4da64a986..3b34c66346 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -21,18 +21,11 @@ public class ContentParser : ITransientDependency public async Task> ParseAsync(string content) { - return new List { - new ContentFragment() { Type = "Markdown" }.SetProperty("Content", "This is *a markdown* text."), - new ContentFragment() { Type = "Widget" }.SetProperty("Type", "Poll").SetProperty("Code", "6dhah8dd"), - new ContentFragment() { Type = "Markdown" }.SetProperty("Content", "This is *another markdown* text.") - }; - - /* if (!_options.WidgetConfigs.Any()) { - return new List() + return new List { - new MarkdownContentFragment() { Content = content } + new ContentFragment() { Type = "Markdown" }.SetProperty("Content", content), }; } @@ -87,31 +80,31 @@ public class ContentParser : ITransientDependency if (parsedWidgets.Count > k) { - var name = _options.WidgetConfigs.Where(p => p.Key == values[0]).Select(p => p.Value.Name).FirstOrDefault(); + var widgetType = values[0]; + var name = _options.WidgetConfigs.Where(p => p.Key == widgetType).Select(p => p.Value.Name).FirstOrDefault(); if (name is not null && parsedWidgets.Count > k) { - var properties = new Dictionary(); + values[0] = name; + var contentFragment = new ContentFragment() { Type = "Widget" }; + contentFragments.Add(contentFragment); for (int kv = 0; kv < values.Count; kv++) { - properties.Add(keys[kv], values[kv]); + + contentFragments.FindLast(p=>p == contentFragment) + .SetProperty(keys[kv], values[kv]); } - - contentFragments.Add(new WidgetContentFragment(name) - { - Properties = properties - }); } } k++; } else { - contentFragments.Add(new MarkdownContentFragment() { Content = parsedList[i] }); + contentFragments.Add(new ContentFragment() { Type = "Markdown" } + .SetProperty("Content", parsedList[i])); } } return contentFragments; - */ } private void ParseWidgets(string content, Dictionary>> parsedWidgets) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index edb6f1dbec..396628ae66 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -17,13 +17,13 @@ @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) } else if (contentFragment.Type == "Widget") //TODO: Constant - { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), new - { - extraProperties = contentFragment.ExtraProperties - } - ) - } + { + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), new + { + extraProperties = contentFragment.ExtraProperties + } + ) } + } From 09b59e220ae64f315350f45c6a94f8a2b92d158b Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 16:47:46 +0300 Subject: [PATCH 27/60] Refactored ContentParser --- .../Volo/CmsKit/Contents/ContentParser.cs | 86 +++++++++---------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index 3b34c66346..9badeab8d3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -19,20 +19,28 @@ public class ContentParser : ITransientDependency _options = options.Value; } - public async Task> ParseAsync(string content) + public Task> ParseAsync(string content) { if (!_options.WidgetConfigs.Any()) { - return new List + return Task.FromResult(new List { new ContentFragment() { Type = "Markdown" }.SetProperty("Content", content), - }; + }); } - var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); - var parsedList = new List(); + ParseContent(content, parsedList); + + var contentFragments = new List(); + FillContentFragment(content, parsedList, contentFragments); + return Task.FromResult(contentFragments); + } + + private void ParseContent(string content, List parsedList) + { + var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); if (!replacedText.Contains(delimeter)) { parsedList.Add(replacedText); @@ -64,34 +72,40 @@ public class ContentParser : ITransientDependency parsedList.Add(replacedText); } } + } - - Dictionary>> parsedWidgets = new(); - ParseWidgets(content, parsedWidgets); - - var contentFragments = new List(); - + private void FillContentFragment(string content, List parsedList, List contentFragments) + { + content = Regex.Replace(content, @"=\s*""", @"="""); + content = Regex.Replace(content, @"""\s*=", @"""="); + var widgets = Regex.Matches(content, @"(?<=\[Widget)(.*?)(?=\])").Cast().Select(p => p.Value).ToList(); for (int i = 0, k = 0; i < parsedList.Count; i++) { if (parsedList[i] == delimeter) { - var values = parsedWidgets.GetOrDefault($"{k}.Widget").Select(p => p.Value).ToList(); - var keys = parsedWidgets.GetOrDefault($"{k}.Widget").Select(p => p.Key).ToList(); - - if (parsedWidgets.Count > k) + if (widgets.Count > k) { - var widgetType = values[0]; - var name = _options.WidgetConfigs.Where(p => p.Key == widgetType).Select(p => p.Value.Name).FirstOrDefault(); - if (name is not null && parsedWidgets.Count > k) + var preparedContent = string.Join("", widgets[k]); + var keys = Regex.Matches(preparedContent, @"(?<=\s)(.*?)(?==\s*"")").Cast() + .Select(p => p.Value).Where(p => p != string.Empty).ToList(); + var values = Regex.Matches(preparedContent, @"(?<=\s*[a-zA-Z]*=\s*"")(.*?)(?="")").Cast() + .Select(p => p.Value).ToList(); + + var widgetTypeIndex = keys.IndexOf("Type"); + if (widgetTypeIndex != -1) { - values[0] = name; - var contentFragment = new ContentFragment() { Type = "Widget" }; - contentFragments.Add(contentFragment); - for (int kv = 0; kv < values.Count; kv++) + var widgetType = values[widgetTypeIndex]; + var name = _options.WidgetConfigs.Where(p => p.Key == widgetType).Select(p => p.Value.Name).FirstOrDefault(); + if (name is not null && widgets.Count > k) { - - contentFragments.FindLast(p=>p == contentFragment) - .SetProperty(keys[kv], values[kv]); + values[0] = name; + var contentFragment = new ContentFragment() { Type = "Widget" }; + contentFragments.Add(contentFragment); + for (int kv = 0; kv < values.Count; kv++) + { + contentFragments.FindLast(p => p == contentFragment) + .SetProperty(keys[kv], values[kv]); + } } } } @@ -103,28 +117,6 @@ public class ContentParser : ITransientDependency .SetProperty("Content", parsedList[i])); } } - - return contentFragments; } - private void ParseWidgets(string content, Dictionary>> parsedWidgets) - { - var widgets = Regex.Matches(content, @"(?<=\[Widget)(.*?)(?=\])").Cast().Select(p => p.Value).ToList(); - for (int p = 0; p < widgets.Count; p++) - { - var preparedContent = string.Join("", widgets[p]); - var keys = Regex.Matches(preparedContent, @"(?<=[\[Widget]?\s)(.*?)(?=="")").Cast() - .Select(p => p.Value).Where(p => p != string.Empty).ToList(); - var values = Regex.Matches(preparedContent, @"(?<=\s*[a-zA-Z]*=\s*"")(.*?)(?="")").Cast() - .Select(p => p.Value).ToList(); - - var list = new List>(); - for (int kv = 0; kv < keys.Count; kv++) - { - list.Add(new KeyValuePair(keys[kv], values[kv])); - } - - parsedWidgets.Add($"{p}.Widget", list); - } - } } \ No newline at end of file From 05ef73658f1bb6cccb9152ccae797d951a6f5069 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 14 Jun 2022 16:48:34 +0300 Subject: [PATCH 28/60] Run all cases of the unit tests successfully --- .../Contents/ContentParser_Test.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs index 00dc4c184e..4a51206a15 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs @@ -19,30 +19,33 @@ public class ContentParser_Test : CmsKitDomainTestBase } [Fact] - public async Task AA_ParseAsync_ShouldWorkMoreDynamically() + public async Task ParseAsync_ShouldWorkWithDifferentWidgetTypes() { _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); _options.Value.AddWidgetConfig("ImageGallery", new ContentWidgetConfig("ImageGallery"));//test contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Type=""Poll"" PollName =""poll-name""] + [Widget Type=""Poll"" Code=""poll-name""] Thanks _for_ *your * feedback. - [Widget Type=""ImageGallery"" GalleryName=""Xyz"" Source=""GoogleDrive""]"; + [Widget GalleryName=""Xyz"" Type=""ImageGallery"" Source=""GoogleDrive""]"; var widgets = await contentParser.ParseAsync(content); widgets.ShouldNotBeNull(); widgets.Count.ShouldBe(4); + widgets[1].ExtraProperties.Count.ShouldBe(2); + widgets[3].ExtraProperties.Count.ShouldBe(3); } [Fact] public async Task ParseAsync_ShouldWorkWithoutConfigOptions() { var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Type= ""Poll"" PollName =""poll-name""] + [Widget Type= ""Poll"" Code =""poll-name""] Thanks _for_ *your * feedback."; + contentParser = new ContentParser(_options); var widgets = await contentParser.ParseAsync(content); widgets.ShouldNotBeNull(); @@ -56,7 +59,7 @@ public class ContentParser_Test : CmsKitDomainTestBase contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Type= ""Poll"" PollName =""poll-name""] + [Widget Type= ""Poll"" Code =""poll-name""] Thanks _for_ *your * feedback."; var widgets = await contentParser.ParseAsync(content); @@ -72,7 +75,7 @@ public class ContentParser_Test : CmsKitDomainTestBase contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Wrong Type= ""Poll"" PollName =""poll-name""] + [Widget Wrong Type= ""Poll"" Code =""poll-name""] Thanks _for_ *your * feedback."; var widgets = await contentParser.ParseAsync(content); @@ -88,13 +91,13 @@ public class ContentParser_Test : CmsKitDomainTestBase contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Type= ""Poll"" PollWrongName =""poll-name""] + [Widget Type= ""Poll"" PollWrongName =""poll-name""] Thanks _for_ *your * feedback."; var widgets = await contentParser.ParseAsync(content); widgets.ShouldNotBeNull(); - widgets.Count.ShouldBe(2); + widgets.Count.ShouldBe(3); } [Theory] @@ -114,19 +117,19 @@ public class ContentParser_Test : CmsKitDomainTestBase new List { new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Type=""Poll"" PollName=""poll-name""] + [Widget Type=""Poll"" Code=""poll-name""] Thanks _for_ *your * feedback.", 3}, new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner. - [Widget Type=""Poll"" PollName=""poll-name""] + [Widget Type=""Poll"" Code=""poll-name""] Thanks _for_ *your * feedback. - [Widget Type=""Poll"" PollName=""poll-name1""]", 4 }, + [Widget Type=""Poll"" Code=""poll-name1""]", 4 }, new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner. Thanks _for_ *your * feedback. - [Widget Type=""Poll"" PollName=""poll-name""]", 2 }, + [Widget Type=""Poll"" Code=""poll-name""]", 2 }, - new object[] { @"[Widget Type=""Poll"" PollName=""poll-name""] gg [Widget Type=""Poll"" PollName=""poll-name1""]**ABP Framework** is completely open source and developed in a community-driven manner. + new object[] { @"[Widget Type=""Poll"" Code=""poll-name""] gg [Widget Type=""Poll"" Code=""poll-name1""]**ABP Framework** is completely open source and developed in a community-driven manner. Thanks _for_ *your * feedback. Thanks _for_ *your * feedback.", 4}, From 237fa5756650601605ffa44f3027a8e375e4a2f0 Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 15 Jun 2022 11:49:21 +0300 Subject: [PATCH 29/60] Moved options from domain to application layer --- .../Volo/CmsKit/Contents}/CmsKitContentWidgetOptions.cs | 2 +- .../Volo/CmsKit/Contents/ContentParser.cs | 1 - .../Volo/CmsKit/Contents}/ContentWidgetConfig.cs | 2 +- .../Contents/ContentParser_Test.cs | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) rename modules/cms-kit/src/{Volo.CmsKit.Domain/Volo/CmsKit/Polls => Volo.CmsKit.Common.Application/Volo/CmsKit/Contents}/CmsKitContentWidgetOptions.cs (92%) rename modules/cms-kit/src/{Volo.CmsKit.Domain/Volo/CmsKit/Polls => Volo.CmsKit.Common.Application/Volo/CmsKit/Contents}/ContentWidgetConfig.cs (86%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs similarity index 92% rename from modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/CmsKitContentWidgetOptions.cs rename to modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs index 251cbe463c..2d2ed68302 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/CmsKitContentWidgetOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Volo.CmsKit.Polls; +namespace Volo.CmsKit.Contents; public class CmsKitContentWidgetOptions { diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index 9badeab8d3..3c239207cd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; -using Volo.CmsKit.Polls; namespace Volo.CmsKit.Contents; diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs similarity index 86% rename from modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentWidgetConfig.cs rename to modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs index eb9c6a0656..634b44fde2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Polls/ContentWidgetConfig.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs @@ -1,6 +1,6 @@ using System; -namespace Volo.CmsKit.Polls; +namespace Volo.CmsKit.Contents; public class ContentWidgetConfig { diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs index 4a51206a15..7deeff2a80 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.Options; using Shouldly; -using Volo.CmsKit.Polls; using Xunit; namespace Volo.CmsKit.Contents; From f751f89d89fd618d02b3c1be5af1341e3f0225bf Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 15 Jun 2022 13:19:11 +0300 Subject: [PATCH 30/60] Converted ExtraProperties to a dynamic object --- .../Shared/Components/Pages/Default.cshtml | 25 +++++++++++++++---- .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 24 ++++++++++++++---- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml index 396628ae66..d79e809c47 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml @@ -1,5 +1,6 @@ @addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@using System.Dynamic @using Volo.CmsKit.Public.Web.Renderers @using Volo.Abp.Data @using Volo.CmsKit.Contents @@ -18,12 +19,26 @@ } else if (contentFragment.Type == "Widget") //TODO: Constant { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), new - { - extraProperties = contentFragment.ExtraProperties - } - ) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) } } + + +@{ + dynamic ConvertToDynamicObject(Dictionary dict) + { + var eo = new ExpandoObject(); + var eoColl = (ICollection>)eo; + + foreach (var kvp in dict) + { + eoColl.Add(kvp); + } + + dynamic eoDynamic = eo; + + return eoDynamic; + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index eac43e41fc..b7ead0592a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -1,5 +1,6 @@ @page +@using System.Dynamic @using Volo.Abp.Data @using Volo.CmsKit.Public.Blogs @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment @@ -75,11 +76,7 @@ } else if (contentFragment.Type == "Widget") //TODO: Constant { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), new - { - extraProperties = contentFragment.ExtraProperties - } - ) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) } }

@@ -167,4 +164,21 @@ entityId = Model.BlogPost.Id.ToString() }) } +} + +@{ + dynamic ConvertToDynamicObject(Dictionary dict) + { + var eo = new ExpandoObject(); + var eoColl = (ICollection>)eo; + + foreach (var kvp in dict) + { + eoColl.Add(kvp); + } + + dynamic eoDynamic = eo; + + return eoDynamic; + } } \ No newline at end of file From 0cdc2cf4b06847396eaf5a1ea172715c848b6423 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 16 Jun 2022 15:12:01 +0300 Subject: [PATCH 31/60] Removed the unnecessary PageVC --- .../Shared/Components/Pages/Default.cshtml | 44 -------------- .../Pages/DefaultPageViewComponent.cs | 42 -------------- .../Components/Tags/TagViewComponent.cs | 7 +-- .../Pages/Public/CmsKit/Pages/Index.cshtml | 58 ++++++++++++++----- .../Pages/Public/CmsKit/Pages/Index.cshtml.cs | 8 +-- .../CmsKit}/Pages/PageViewModel.cs | 2 +- .../Volo.CmsKit.TestBase/CmsKitTestData.cs | 2 +- 7 files changed, 52 insertions(+), 111 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs rename modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/{CmsKit/Shared/Components => Public/CmsKit}/Pages/PageViewModel.cs (77%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml deleted file mode 100644 index d79e809c47..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml +++ /dev/null @@ -1,44 +0,0 @@ -@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap - -@using System.Dynamic -@using Volo.CmsKit.Public.Web.Renderers -@using Volo.Abp.Data -@using Volo.CmsKit.Contents - -@inject IMarkdownToHtmlRenderer MarkdownRenderer - -@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages.PageViewModel - - - - @foreach (ContentFragment contentFragment in Model.ContentFragments) - { - if (contentFragment.Type == "Markdown") //TODO: Constant - { - @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) - } - else if (contentFragment.Type == "Widget") //TODO: Constant - { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) - } - } - - - - -@{ - dynamic ConvertToDynamicObject(Dictionary dict) - { - var eo = new ExpandoObject(); - var eoColl = (ICollection>)eo; - - foreach (var kvp in dict) - { - eoColl.Add(kvp); - } - - dynamic eoDynamic = eo; - - return eoDynamic; - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs deleted file mode 100644 index 43706cee56..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; -using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -using Volo.CmsKit.Contents; - -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; - -[Widget( - StyleTypes = new[] - { - typeof(HighlightJsStyleContributor) - }, - ScriptTypes = new[] - { - typeof(HighlightJsScriptContributor) - }, - ScriptFiles = new[] - { - "/Pages/Public/CmsKit/highlightOnLoad.js" - })] -public class DefaultPageViewComponent : AbpViewComponent //TODO: Remove component, directly render in the page -{ - public virtual async Task InvokeAsync( - Guid pageId, - string title, - string content, - List contentFragments) - { - var model = new PageViewModel - { - Id = pageId, - Title = title, - ContentFragments = contentFragments - }; - - return View("~/Pages/CmsKit/Shared/Components/Pages/Default.cshtml", model); - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs index a3dc23c61a..0e550a6ade 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs @@ -1,9 +1,6 @@ -using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.CmsKit.Tags; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml index 5296315e1c..498569c222 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml @@ -1,33 +1,63 @@ -@page -@using Microsoft.AspNetCore.Mvc.Localization + +@page +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap @using Volo.CmsKit.Contents -@using Volo.CmsKit.Localization -@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages +@using System.Dynamic +@using Volo.CmsKit.Public.Web.Renderers +@using Volo.Abp.Data +@using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; +@using Volo.Abp.AspNetCore.Mvc.UI.Widgets; + +@inject IMarkdownToHtmlRenderer MarkdownRenderer + @model Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel -@inject IHtmlLocalizer L @section styles{ } @section scripts{ } -@await Component.InvokeAsync(typeof(DefaultPageViewComponent), - new + + + @foreach (ContentFragment contentFragment in Model.PageDto.ContentFragments) + { + if (contentFragment.Type == "Markdown") //TODO: Constant + { + @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) + } + else if (contentFragment.Type == "Widget") //TODO: Constant + { + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) + } + } + + + +@{ + dynamic ConvertToDynamicObject(Dictionary dict) { - pageId = Model.Page.Id, - title = Model.Page.Title, - content = Model.Page.Content, - contentFragments = Model.Page.ContentFragments - }) \ No newline at end of file + var eo = new ExpandoObject(); + var eoColl = (ICollection>)eo; + + foreach (var kvp in dict) + { + eoColl.Add(kvp); + } + + dynamic eoDynamic = eo; + + return eoDynamic; + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs index 6eeac638cf..1434eccb4b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml.cs @@ -12,18 +12,18 @@ public class IndexModel : CommonPageModel protected IPagePublicAppService PagePublicAppService { get; } - public PageDto Page; + public PageDto PageDto{ get; private set; } - public IndexModel(IPagePublicAppService pagePublicAppService) +public IndexModel(IPagePublicAppService pagePublicAppService) { PagePublicAppService = pagePublicAppService; } public async Task OnGetAsync() { - Page = await PagePublicAppService.FindBySlugAsync(Slug); + PageDto = await PagePublicAppService.FindBySlugAsync(Slug); - if (Page == null) + if (PageDto == null) { return NotFound(); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/PageViewModel.cs similarity index 77% rename from modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs rename to modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/PageViewModel.cs index 8dcc71c3b2..5e5df3e917 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/PageViewModel.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/PageViewModel.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using Volo.CmsKit.Contents; -namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages; +namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages; public class PageViewModel { diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs index 6445fb86f4..cfa54d2e55 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs @@ -130,5 +130,5 @@ public class CmsKitTestData : ISingletonDependency public string PollName { get; } = "Poll"; - public string WidgetName { get; } = "CmsPollByName"; + public string WidgetName { get; } = "CmsPollByCode"; } From 591fa1b6ab31dda52307f0aaaf980dcb4cda6e1d Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 16 Jun 2022 15:49:10 +0300 Subject: [PATCH 32/60] Moved values into the const file --- .../Volo/CmsKit/Contents/ContentConsts.cs | 7 ++++++ .../Volo/CmsKit/Contents/ContentParser.cs | 22 +++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs new file mode 100644 index 0000000000..bf58fb8f99 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.CmsKit.Contents; +public static class ContentConsts +{ + public static string Delimeter { get; set; } = "----"; + public static string Widget { get; set; } = "Widget"; + public static string Markdown { get; set; } = "Markdown"; +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index 3c239207cd..369f6aef84 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -5,12 +5,12 @@ using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; +using static Volo.CmsKit.Contents.ContentConsts; namespace Volo.CmsKit.Contents; public class ContentParser : ITransientDependency { - private const string delimeter = "----"; private readonly CmsKitContentWidgetOptions _options; public ContentParser(IOptions options) @@ -39,16 +39,16 @@ public class ContentParser : ITransientDependency private void ParseContent(string content, List parsedList) { - var replacedText = Regex.Replace(content, @"\[.*?\]", delimeter); - if (!replacedText.Contains(delimeter)) + var replacedText = Regex.Replace(content, @"\[.*?\]", Delimeter); + if (!replacedText.Contains(Delimeter)) { parsedList.Add(replacedText); } - while (replacedText.Contains(delimeter)) + while (replacedText.Contains(Delimeter)) { //For parsing delimeter - var index = replacedText.IndexOf(delimeter); + var index = replacedText.IndexOf(Delimeter); if (index != 0) { parsedList.Add(replacedText.Substring(0, index)); @@ -56,11 +56,11 @@ public class ContentParser : ITransientDependency index = 0; } - parsedList.Add(replacedText.Substring(index, delimeter.Length)); - replacedText = replacedText.Substring(delimeter.Length, replacedText.Length - delimeter.Length); + parsedList.Add(replacedText.Substring(index, Delimeter.Length)); + replacedText = replacedText.Substring(Delimeter.Length, replacedText.Length - Delimeter.Length); //for parsing the other side - index = replacedText.IndexOf(delimeter); + index = replacedText.IndexOf(Delimeter); if (index != -1) { parsedList.Add(replacedText.Substring(0, index)); @@ -80,7 +80,7 @@ public class ContentParser : ITransientDependency var widgets = Regex.Matches(content, @"(?<=\[Widget)(.*?)(?=\])").Cast().Select(p => p.Value).ToList(); for (int i = 0, k = 0; i < parsedList.Count; i++) { - if (parsedList[i] == delimeter) + if (parsedList[i] == Delimeter) { if (widgets.Count > k) { @@ -98,7 +98,7 @@ public class ContentParser : ITransientDependency if (name is not null && widgets.Count > k) { values[0] = name; - var contentFragment = new ContentFragment() { Type = "Widget" }; + var contentFragment = new ContentFragment() { Type = Widget }; contentFragments.Add(contentFragment); for (int kv = 0; kv < values.Count; kv++) { @@ -112,7 +112,7 @@ public class ContentParser : ITransientDependency } else { - contentFragments.Add(new ContentFragment() { Type = "Markdown" } + contentFragments.Add(new ContentFragment() { Type = Markdown } .SetProperty("Content", parsedList[i])); } } From 3de1f919d8b4a0daafc5f6fa69bfa76311cb9aa1 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 16 Jun 2022 15:49:56 +0300 Subject: [PATCH 33/60] Removed duplication --- .../Volo.CmsKit.Common.Web/Contents/Helper.cs | 23 ++++ .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 109 ++++++++---------- .../Pages/Public/CmsKit/Pages/Index.cshtml | 24 +--- 3 files changed, 75 insertions(+), 81 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs new file mode 100644 index 0000000000..3d653e2351 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Dynamic; + +namespace Volo.CmsKit.Web.Contents; + +public static class Helper +{ + public static dynamic ConvertToDynamicObject(this Dictionary dict) + { + var eo = new ExpandoObject(); + var eoColl = (ICollection>)eo; + + foreach (var kvp in dict) + { + eoColl.Add(kvp); + } + + dynamic eoDynamic = eo; + + return eoDynamic; + } +} + diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index b7ead0592a..f104551911 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -12,6 +12,8 @@ @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Tags @using Volo.CmsKit.Public.Web.Renderers @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs +@using Volo.CmsKit.Contents +@using Volo.CmsKit.Web.Contents; @inherits CmsKitPublicPageBase @@ -26,57 +28,57 @@ } @section styles{ - @if (isScrollIndexEnabled) - { - - - - } + @if (isScrollIndexEnabled) + { + + + + } - - + + } -@section scripts{ + @section scripts{ @if (isScrollIndexEnabled) { - - + + } - - + + } -

-
- - - - -
-

@Model.BlogPost.Title

-

- - @@@Model.BlogPost.Author?.UserName - - @Model.BlogPost.CreationTime -

- @foreach (var contentFragment in Model.BlogPost.ContentFragments) +
+
+ + + + +
+

@Model.BlogPost.Title

+

+ + @@@Model.BlogPost.Author?.UserName + + @Model.BlogPost.CreationTime +

+ @foreach (var contentFragment in Model.BlogPost.ContentFragments) { - if (contentFragment.Type == "Markdown") //TODO: Constant + if (contentFragment.Type == ContentConsts.Markdown) { @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) } - else if (contentFragment.Type == "Widget") //TODO: Constant + else if (contentFragment.Type == ContentConsts.Widget) { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) } }

@@ -85,18 +87,18 @@ @L["LastModification"].Value : @Model.BlogPost.LastModificationTime }

-
+
@if (GlobalFeatureManager.Instance.IsEnabled()) { if (Model.TagsFeature?.IsEnabled == true) { @await Component.InvokeAsync(typeof(TagViewComponent), new - { - entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, - entityId = Model.BlogPost.Id.ToString(), - urlFormat = $"/blogs/{Model.BlogSlug}?tagId={{TagId}}" - }) + { + entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, + entityId = Model.BlogPost.Id.ToString(), + urlFormat = $"/blogs/{Model.BlogSlug}?tagId={{TagId}}" + }) } }
@@ -109,10 +111,10 @@ if (Model.ReactionsFeature?.IsEnabled == true) { @await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new - { - entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, - entityId = Model.BlogPost.Id.ToString() - }) + { + entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, + entityId = Model.BlogPost.Id.ToString() + }) } } @@ -122,10 +124,10 @@ if (Model.RatingsFeature?.IsEnabled == true) { @await Component.InvokeAsync(typeof(RatingViewComponent), new - { - entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, - entityId = Model.BlogPost.Id.ToString() - }) + { + entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, + entityId = Model.BlogPost.Id.ToString() + }) } } @@ -164,21 +166,4 @@ entityId = Model.BlogPost.Id.ToString() }) } -} - -@{ - dynamic ConvertToDynamicObject(Dictionary dict) - { - var eo = new ExpandoObject(); - var eoColl = (ICollection>)eo; - - foreach (var kvp in dict) - { - eoColl.Add(kvp); - } - - dynamic eoDynamic = eo; - - return eoDynamic; - } } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml index 498569c222..17045c4575 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml @@ -7,6 +7,8 @@ @using Volo.Abp.Data @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; @using Volo.Abp.AspNetCore.Mvc.UI.Widgets; +@using Volo.CmsKit.Web.Contents; + @inject IMarkdownToHtmlRenderer MarkdownRenderer @@ -33,31 +35,15 @@ @foreach (ContentFragment contentFragment in Model.PageDto.ContentFragments) { - if (contentFragment.Type == "Markdown") //TODO: Constant + if (contentFragment.Type == ContentConsts.Markdown) { @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) } - else if (contentFragment.Type == "Widget") //TODO: Constant + else if (contentFragment.Type == ContentConsts.Widget) { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) } }
-@{ - dynamic ConvertToDynamicObject(Dictionary dict) - { - var eo = new ExpandoObject(); - var eoColl = (ICollection>)eo; - - foreach (var kvp in dict) - { - eoColl.Add(kvp); - } - - dynamic eoDynamic = eo; - - return eoDynamic; - } -} \ No newline at end of file From e5d0521e2a1497663778004e25223facf51ff0ca Mon Sep 17 00:00:00 2001 From: malik masis Date: Fri, 17 Jun 2022 10:57:01 +0300 Subject: [PATCH 34/60] Removed the missed hard-coded --- .../Volo/CmsKit/Contents/ContentConsts.cs | 1 + .../Volo/CmsKit/Contents/ContentParser.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs index bf58fb8f99..8caaa7a03a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentConsts.cs @@ -4,4 +4,5 @@ public static class ContentConsts public static string Delimeter { get; set; } = "----"; public static string Widget { get; set; } = "Widget"; public static string Markdown { get; set; } = "Markdown"; + public static string Content { get; set; } = "Content"; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index 369f6aef84..b5716be9df 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -24,7 +24,7 @@ public class ContentParser : ITransientDependency { return Task.FromResult(new List { - new ContentFragment() { Type = "Markdown" }.SetProperty("Content", content), + new ContentFragment() { Type = Markdown }.SetProperty(Content, content), }); } @@ -113,7 +113,7 @@ public class ContentParser : ITransientDependency else { contentFragments.Add(new ContentFragment() { Type = Markdown } - .SetProperty("Content", parsedList[i])); + .SetProperty(Content, parsedList[i])); } } } From 96a521a55b521d9f505b467409f89c51271778ce Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 20 Jun 2022 11:31:47 +0300 Subject: [PATCH 35/60] Cli: Build the project if needed when generating code with Suite --- .../Volo/Abp/Cli/Commands/SuiteCommand.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs index 6ee6a74a47..060262eb93 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs @@ -116,6 +116,18 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency return; } + var IsSolutionBuiltResponse = await client.GetAsync( + $"{AbpSuiteHost}/api/abpSuite/solutions/{solutionId.ToString()}/is-built" + ); + + var IsSolutionBuilt = Convert.ToBoolean(await IsSolutionBuiltResponse.Content.ReadAsStringAsync()); + + if (!IsSolutionBuilt) + { + Logger.LogInformation("Building the solution..."); + CmdHelper.RunCmd("dotnet build", Path.GetDirectoryName(solutionFile)); + } + var entityContent = new StringContent( File.ReadAllText(entityFile), Encoding.UTF8, From 14966dfc5d6e71643de0f508e8924faa813d575f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 20 Jun 2022 15:03:00 +0300 Subject: [PATCH 36/60] Review notes --- .../Volo.CmsKit.Web.Unified/appsettings.json | 2 +- .../Volo/CmsKit/Contents/ContentParser.cs | 3 +- .../CmsKit/Contents/ContentWidgetConfig.cs | 4 +- .../Volo.CmsKit.Common.Web/Contents/Helper.cs | 12 ++--- .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 48 +++++++++---------- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/appsettings.json b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/appsettings.json index 3c872decbe..fcf428bab3 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/appsettings.json +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/appsettings.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "Default": "Server=(localdb)\\.\\MSSQLLocalDB;Database=CmsKit_Unified;Trusted_Connection=True" + "Default": "Server=(localdb)\\MSSQLLocalDB;Database=CmsKit_Unified;Trusted_Connection=True" } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs index b5716be9df..7fe9fe5b60 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentParser.cs @@ -24,7 +24,7 @@ public class ContentParser : ITransientDependency { return Task.FromResult(new List { - new ContentFragment() { Type = Markdown }.SetProperty(Content, content), + new ContentFragment { Type = Markdown }.SetProperty(Content, content), }); } @@ -117,5 +117,4 @@ public class ContentParser : ITransientDependency } } } - } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs index 634b44fde2..8dc1f5d29f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs @@ -5,9 +5,9 @@ namespace Volo.CmsKit.Contents; public class ContentWidgetConfig { public string Name { get; } - public Type ViewComponentType { get; set; } + public Type ViewComponentType { get; set; } //TODO: Remove this - public ContentWidgetConfig(string name) + public ContentWidgetConfig(string name) //TODO: widgetName { Name = name; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs index 3d653e2351..d61c5f418a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs @@ -3,21 +3,19 @@ using System.Dynamic; namespace Volo.CmsKit.Web.Contents; -public static class Helper +public static class DictionaryDynamicExtensions { - public static dynamic ConvertToDynamicObject(this Dictionary dict) + public static dynamic ConvertToDynamicObject(this Dictionary dict) //TODO: Move to AbpDictionaryExtensions { - var eo = new ExpandoObject(); - var eoColl = (ICollection>)eo; + var expandoObject = new ExpandoObject(); + var eoColl = (ICollection>)expandoObject; foreach (var kvp in dict) { eoColl.Add(kvp); } - dynamic eoDynamic = eo; - - return eoDynamic; + return expandoObject; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index f104551911..d9211ed04c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -71,34 +71,34 @@ @Model.BlogPost.CreationTime

@foreach (var contentFragment in Model.BlogPost.ContentFragments) - { - if (contentFragment.Type == ContentConsts.Markdown) - { - @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) - } - else if (contentFragment.Type == ContentConsts.Widget) - { - @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) - } - } -

- @if (Model.BlogPost.LastModificationTime != null) { - @L["LastModification"].Value : @Model.BlogPost.LastModificationTime + if (contentFragment.Type == ContentConsts.Markdown) + { + @Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty("Content"))) + } + else if (contentFragment.Type == ContentConsts.Widget) + { + @await Component.InvokeAsync(contentFragment.GetProperty("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) + } } -

-
+

+ @if (Model.BlogPost.LastModificationTime != null) + { + @L["LastModification"].Value : @Model.BlogPost.LastModificationTime + } +

+
- @if (GlobalFeatureManager.Instance.IsEnabled()) - { - if (Model.TagsFeature?.IsEnabled == true) + @if (GlobalFeatureManager.Instance.IsEnabled()) { - @await Component.InvokeAsync(typeof(TagViewComponent), new - { - entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, - entityId = Model.BlogPost.Id.ToString(), - urlFormat = $"/blogs/{Model.BlogSlug}?tagId={{TagId}}" - }) + if (Model.TagsFeature?.IsEnabled == true) + { + @await Component.InvokeAsync(typeof(TagViewComponent), new + { + entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, + entityId = Model.BlogPost.Id.ToString(), + urlFormat = $"/blogs/{Model.BlogSlug}?tagId={{TagId}}" + }) } }
From 5e3bfecd8bdb7e6d14fdfa4531c4589d56eab288 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 20 Jun 2022 17:08:21 +0300 Subject: [PATCH 37/60] Update OpenIddictDataSeedContributor.cs --- .../OpenIddict/OpenIddictDataSeedContributor.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs index add52f7437..9505c467c0 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs @@ -10,6 +10,7 @@ using Volo.Abp; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; +using Volo.Abp.OpenIddict.Applications; using Volo.Abp.PermissionManagement; using Volo.Abp.Uow; @@ -21,14 +22,14 @@ namespace MyCompanyName.MyProjectName.OpenIddict; public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency { private readonly IConfiguration _configuration; - private readonly IOpenIddictApplicationManager _applicationManager; + private readonly IAbpApplicationManager _applicationManager; private readonly IOpenIddictScopeManager _scopeManager; private readonly IPermissionDataSeeder _permissionDataSeeder; private readonly IStringLocalizer L; public OpenIddictDataSeedContributor( IConfiguration configuration, - IOpenIddictApplicationManager applicationManager, + IAbpApplicationManager applicationManager, IOpenIddictScopeManager scopeManager, IPermissionDataSeeder permissionDataSeeder, IStringLocalizer l) @@ -201,6 +202,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep string secret, List grantTypes, List scopes, + string clientUri = null, string redirectUri = null, string postLogoutRedirectUri = null, List permissions = null) @@ -224,13 +226,14 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep var client = await _applicationManager.FindByClientIdAsync(name); if (client == null) { - var application = new OpenIddictApplicationDescriptor + var application = new AbpApplicationDescriptor { ClientId = name, Type = type, ClientSecret = secret, ConsentType = consentType, - DisplayName = displayName + DisplayName = displayName, + ClientUri = clientUri, }; Check.NotNullOrEmpty(grantTypes, nameof(grantTypes)); From 0b3319b8d9b861a4ae08cde74d6b03b327797323 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 21 Jun 2022 10:04:07 +0300 Subject: [PATCH 38/60] Removed ViewComponentType --- .../CmsKit/Contents/CmsKitContentWidgetOptions.cs | 4 ++-- .../Volo/CmsKit/Contents/ContentWidgetConfig.cs | 9 +++------ .../Contents/ContentParser_Test.cs | 12 ++++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs index 2d2ed68302..1f9dae60ab 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/CmsKitContentWidgetOptions.cs @@ -11,8 +11,8 @@ public class CmsKitContentWidgetOptions WidgetConfigs = new(); } - public void AddWidgetConfig(string name, ContentWidgetConfig contentWidgetConfig) + public void AddWidget(string widgetName, string widgetKey) { - WidgetConfigs.Add(name, contentWidgetConfig); + WidgetConfigs.Add(widgetName, new ContentWidgetConfig(widgetKey)); } } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs index 8dc1f5d29f..a5eab5930a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentWidgetConfig.cs @@ -1,14 +1,11 @@ -using System; - -namespace Volo.CmsKit.Contents; +namespace Volo.CmsKit.Contents; public class ContentWidgetConfig { public string Name { get; } - public Type ViewComponentType { get; set; } //TODO: Remove this - public ContentWidgetConfig(string name) //TODO: widgetName + public ContentWidgetConfig(string widgetName) { - Name = name; + Name = widgetName; } } \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs index 7deeff2a80..108d883a70 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentParser_Test.cs @@ -20,8 +20,8 @@ public class ContentParser_Test : CmsKitDomainTestBase [Fact] public async Task ParseAsync_ShouldWorkWithDifferentWidgetTypes() { - _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); - _options.Value.AddWidgetConfig("ImageGallery", new ContentWidgetConfig("ImageGallery"));//test + _options.Value.AddWidget(testData.PollName, testData.WidgetName); + _options.Value.AddWidget("ImageGallery", "ImageGallery"); contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. @@ -54,7 +54,7 @@ public class ContentParser_Test : CmsKitDomainTestBase [Fact] public async Task ParseAsync_ShouldWorkWithWrongConfigOptions() { - _options.Value.AddWidgetConfig(testData.WidgetName, new ContentWidgetConfig(testData.PollName)); + _options.Value.AddWidget(testData.WidgetName, testData.PollName); contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. @@ -70,7 +70,7 @@ public class ContentParser_Test : CmsKitDomainTestBase [Fact] public async Task ParseAsync_ShouldWorkWithWrongWidgetType() { - _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + _options.Value.AddWidget(testData.PollName, testData.WidgetName); contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. @@ -86,7 +86,7 @@ public class ContentParser_Test : CmsKitDomainTestBase [Fact] public async Task ParseAsync_ShouldWorkWithWrongPollName() { - _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + _options.Value.AddWidget(testData.PollName, testData.WidgetName); contentParser = new ContentParser(_options); var content = @"**ABP Framework** is completely open source and developed in a community-driven manner. @@ -103,7 +103,7 @@ public class ContentParser_Test : CmsKitDomainTestBase [MemberData(nameof(ExampleData))] public async Task ParseAsync_ShouldWorkProperlyWithCorrectInputs(string content, int expectedLine) { - _options.Value.AddWidgetConfig(testData.PollName, new ContentWidgetConfig(testData.WidgetName)); + _options.Value.AddWidget(testData.PollName, testData.WidgetName); contentParser = new ContentParser(_options); var widgets = await contentParser.ParseAsync(content); From 36fae04f9fdf011d3eb4198c56ca3183f36c3143 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 10:50:07 +0300 Subject: [PATCH 39/60] Update OpenIddictDataSeedContributor.cs --- .../OpenIddict/OpenIddictDataSeedContributor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs index 9505c467c0..9026bfaeaa 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs @@ -99,6 +99,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{webClientRootUrl}signin-oidc", + clientUri: webClientRootUrl, postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" ); } @@ -123,6 +124,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: consoleAndAngularClientRootUrl, + clientUri: consoleAndAngularClientRootUrl, postLogoutRedirectUri: consoleAndAngularClientRootUrl ); } @@ -145,6 +147,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{blazorRootUrl}/authentication/login-callback", + clientUri: blazorRootUrl, postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" ); } @@ -168,6 +171,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{blazorServerTieredRootUrl}signin-oidc", + clientUri: blazorServerTieredRootUrl, postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc" ); } @@ -189,7 +193,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep OpenIddictConstants.GrantTypes.AuthorizationCode, }, scopes: commonScopes, - redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html" + redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", + clientUri: swaggerRootUrl ); } } From d2f39facac4ca8ce3664c5fb2a7395d230a7d458 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 10:50:28 +0300 Subject: [PATCH 40/60] Update design for openIdDict AuthServer --- .../Pages/Index.cshtml | 135 ++++++++++++++---- .../Pages/Index.cshtml.cs | 29 +++- 2 files changed, 138 insertions(+), 26 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml index db9f1f100a..2bd2ff4677 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml @@ -1,34 +1,119 @@ @page +@using Microsoft.AspNetCore.Http.Extensions +@using Microsoft.AspNetCore.Mvc.Localization @using MyCompanyName.MyProjectName.Pages +@using MyCompanyName.MyProjectName.Localization @using Volo.Abp.Users +@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@using Volo.Abp.Ui.Branding @model IndexModel +@inject IHtmlLocalizer L @inject ICurrentUser CurrentUser -@if (CurrentUser.IsAuthenticated) -{ -
+@inject IBrandingProvider BrandingProvider +@inject ITheme Theme + +@{ + Layout = Theme.GetEmptyLayout(); +} + +
+
- - - Logout - - -

@CurrentUser.UserName

-
@CurrentUser.Email
-
- Roles: @CurrentUser.Roles.JoinAsString(", ") -
- Claims:
- @Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString("
")) + + -} + + + + +
+ + + +
+
+ +
+
+ @if (CurrentUser.IsAuthenticated) + { + + @L["Welcome"] @CurrentUser.UserName + + @CurrentUser.Email + + } + else + { + @L["Login"] + } +
-@if (!CurrentUser.IsAuthenticated) -{ -
-

- Login +
+ + +
+ + + + @foreach (var language in Model.Languages) + { + @language.DisplayName + } + + +
+
+ + +
+ + + + @foreach (var application in Model.Applications) + { + + + + + @if (!application.LogoUri.IsNullOrEmpty()) + { +
+ +
+ } + +

@application.DisplayName

+ @application.ClientUri + +
+
+
+ } + +
+
+ + + + +
+ +
-} +
\ No newline at end of file diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs index e8230ee00c..f873648b3a 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs @@ -1,10 +1,37 @@ +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Abp.Localization; +using Volo.Abp.OpenIddict.Applications; namespace MyCompanyName.MyProjectName.Pages; public class IndexModel : AbpPageModel { - public void OnGet() + public List Applications { get; protected set; } + + public IReadOnlyList Languages { get; protected set; } + + public string CurrentLanguage { get; protected set; } + + protected IOpenIddictApplicationRepository OpenIdApplicationRepository { get; } + + protected ILanguageProvider LanguageProvider { get; } + + public IndexModel(IOpenIddictApplicationRepository openIdApplicationmRepository, ILanguageProvider languageProvider) { + OpenIdApplicationRepository = openIdApplicationmRepository; + LanguageProvider = languageProvider; + } + + public async Task OnGetAsync() + { + var cts = new CancellationTokenSource(30); + Applications = await OpenIdApplicationRepository.GetListAsync(); + + Languages = await LanguageProvider.GetLanguagesAsync(); + CurrentLanguage = CultureInfo.CurrentCulture.DisplayName; } } From e96e7331b86dd6a6e4c6a32167da31a61e433f59 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 10:54:42 +0300 Subject: [PATCH 41/60] Update Index.cshtml --- .../Pages/Index.cshtml | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml index 2bd2ff4677..48b2d8de02 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml @@ -40,29 +40,29 @@ -
-
- -
-
- @if (CurrentUser.IsAuthenticated) - { - - @L["Welcome"] @CurrentUser.UserName - - @CurrentUser.Email - - } - else - { - @L["Login"] - } -
+
+
+ +
+
+ @if (CurrentUser.IsAuthenticated) + { + + @L["Welcome"] @CurrentUser.UserName + + @CurrentUser.Email + + } + else + { + @L["Login"] + } +
-
+
@@ -77,7 +77,7 @@
- +

@@ -91,8 +91,8 @@ @if (!application.LogoUri.IsNullOrEmpty()) { -
- +
+
} From 3e5181c360b37467d593f3972f01fe6d4564ed65 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 21 Jun 2022 11:35:38 +0300 Subject: [PATCH 42/60] Cli: Publish events on project creation steps --- .../Volo/Abp/Cli/Commands/NewCommand.cs | 12 ++++---- .../Commands/ProjectCreationCommandBase.cs | 29 +++++++++++++++++-- .../Events/ProjectCreationProgressEvent.cs | 6 ++++ .../ProjectBuilding/TemplateProjectBuilder.cs | 13 +++++++-- 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index ebad70ce76..aac5ce860c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -16,13 +16,14 @@ using Volo.Abp.Cli.ProjectBuilding.Building; using Volo.Abp.Cli.ProjectModification; using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Local; namespace Volo.Abp.Cli.Commands; public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransientDependency { public const string Name = "new"; - + protected TemplateProjectBuilder TemplateProjectBuilder { get; } public ITemplateInfoProvider TemplateInfoProvider { get; } @@ -33,8 +34,9 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien ICmdHelper cmdHelper, IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder, - InitialMigrationCreator ınitialMigrationCreator) - : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder, ınitialMigrationCreator) + InitialMigrationCreator ınitialMigrationCreator, + ILocalEventBus eventBus) + : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder, ınitialMigrationCreator, eventBus) { TemplateProjectBuilder = templateProjectBuilder; TemplateInfoProvider = templateInfoProvider; @@ -79,10 +81,10 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien Logger.LogInformation($"'{projectName}' has been successfully created to '{projectArgs.OutputFolder}'"); - RunGraphBuildForMicroserviceServiceTemplate(projectArgs); + await RunGraphBuildForMicroserviceServiceTemplate(projectArgs); await CreateInitialMigrationsAsync(projectArgs); await RunInstallLibsForWebTemplateAsync(projectArgs); - ConfigurePwaSupportForAngular(projectArgs); + await ConfigurePwaSupportForAngular(projectArgs); OpenRelatedWebPage(projectArgs, template, isTiered, commandLineArgs); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs index 07741779b1..8ef7bcb7e1 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs @@ -13,10 +13,12 @@ using Volo.Abp.Cli.Commands.Services; using Volo.Abp.Cli.LIbs; using Volo.Abp.Cli.ProjectBuilding; using Volo.Abp.Cli.ProjectBuilding.Building; +using Volo.Abp.Cli.ProjectBuilding.Events; using Volo.Abp.Cli.ProjectBuilding.Templates.App; using Volo.Abp.Cli.ProjectBuilding.Templates.Microservice; using Volo.Abp.Cli.ProjectBuilding.Templates.Module; using Volo.Abp.Cli.Utils; +using Volo.Abp.EventBus.Local; namespace Volo.Abp.Cli.Commands; @@ -28,6 +30,7 @@ public abstract class ProjectCreationCommandBase public IInstallLibsService InstallLibsService { get; } public AngularPwaSupportAdder AngularPwaSupportAdder { get; } public InitialMigrationCreator InitialMigrationCreator { get; } + public ILocalEventBus EventBus { get; } public ILogger Logger { get; set; } public ProjectCreationCommandBase( @@ -36,7 +39,8 @@ public abstract class ProjectCreationCommandBase ICmdHelper cmdHelper, IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder, - InitialMigrationCreator initialMigrationCreator) + InitialMigrationCreator initialMigrationCreator, + ILocalEventBus eventBus) { ConnectionStringProvider = connectionStringProvider; SolutionPackageVersionFinder = solutionPackageVersionFinder; @@ -44,6 +48,7 @@ public abstract class ProjectCreationCommandBase InstallLibsService = installLibsService; AngularPwaSupportAdder = angularPwaSupportAdder; InitialMigrationCreator = initialMigrationCreator; + EventBus = eventBus; Logger = NullLogger.Instance; } @@ -190,6 +195,10 @@ public abstract class ProjectCreationCommandBase protected void ExtractProjectZip(ProjectBuildResult project, string outputFolder) { + EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Extracting solution to file system" + }, false); + using (var templateFileStream = new MemoryStream(project.ZipContent)) { using (var zipInputStream = new ZipInputStream(templateFileStream)) @@ -321,10 +330,14 @@ public abstract class ProjectCreationCommandBase throw new CliUsageException("The option you provided for Database Provider is invalid!"); } - protected virtual void RunGraphBuildForMicroserviceServiceTemplate(ProjectBuildArgs projectArgs) + protected virtual async Task RunGraphBuildForMicroserviceServiceTemplate(ProjectBuildArgs projectArgs) { if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(projectArgs.TemplateName)) { + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Building the microservice solution" + }, false); + CmdHelper.RunCmd("dotnet build /graphbuild", projectArgs.OutputFolder); } } @@ -337,6 +350,11 @@ public abstract class ProjectCreationCommandBase MicroserviceServiceTemplateBase.IsMicroserviceTemplate(projectArgs.TemplateName)) { Logger.LogInformation("Installing client-side packages..."); + + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Installing client-side packages" + }, false); + await InstallLibsService.InstallLibsAsync(projectArgs.OutputFolder); } } @@ -373,10 +391,14 @@ public abstract class ProjectCreationCommandBase return; } + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Creating the initial migration" + }, false); + await InitialMigrationCreator.CreateAsync(Path.GetDirectoryName(efCoreProjectPath), isLayeredTemplate); } - protected void ConfigurePwaSupportForAngular(ProjectBuildArgs projectArgs) + protected async Task ConfigurePwaSupportForAngular(ProjectBuildArgs projectArgs) { var isAngular = projectArgs.UiFramework == UiFramework.Angular; var isPwa = projectArgs.Pwa; @@ -384,6 +406,7 @@ public abstract class ProjectCreationCommandBase if (isAngular && isPwa) { Logger.LogInformation("Adding PWA Support to Angular app."); + AngularPwaSupportAdder.AddPwaSupport(projectArgs.OutputFolder); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs new file mode 100644 index 0000000000..24c424f4cb --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.Cli.ProjectBuilding.Events; + +public class ProjectCreationProgressEvent +{ + public string Message { get; set; } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index 5743a423c0..db430296fa 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -10,8 +10,10 @@ using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Licensing; using Volo.Abp.Cli.ProjectBuilding.Analyticses; using Volo.Abp.Cli.ProjectBuilding.Building; +using Volo.Abp.Cli.ProjectBuilding.Events; using Volo.Abp.Cli.ProjectBuilding.Templates.App; using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Local; using Volo.Abp.Json; namespace Volo.Abp.Cli.ProjectBuilding; @@ -26,6 +28,7 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency protected AbpCliOptions Options { get; } protected IJsonSerializer JsonSerializer { get; } protected IApiKeyService ApiKeyService { get; } + protected ILocalEventBus EventBus { get; } private readonly IConfiguration _configuration; @@ -35,7 +38,8 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency IOptions options, IJsonSerializer jsonSerializer, IApiKeyService apiKeyService, - IConfiguration configuration) + IConfiguration configuration, + ILocalEventBus eventBus) { SourceCodeStore = sourceCodeStore; TemplateInfoProvider = templateInfoProvider; @@ -43,6 +47,7 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency Options = options.Value; JsonSerializer = jsonSerializer; ApiKeyService = apiKeyService; + EventBus = eventBus; _configuration = configuration; Logger = NullLogger.Instance; @@ -116,7 +121,11 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency { appTemplateBase.HasDbMigrations = SemanticVersion.Parse(templateFile.Version) < new SemanticVersion(4, 3, 99); } - + + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Preparing the solution according to preferences" + }, false); + TemplateProjectBuildPipelineBuilder.Build(context).Execute(); if (!templateInfo.DocumentUrl.IsNullOrEmpty()) From 9a19e6e3924548f0804b912de9615c5789ccc7b4 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 11:38:00 +0300 Subject: [PATCH 43/60] Remove unnecessary CancellationTokenSource from Index.cshtml.cs --- .../MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs index f873648b3a..8e31fb91f1 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs @@ -28,7 +28,6 @@ public class IndexModel : AbpPageModel public async Task OnGetAsync() { - var cts = new CancellationTokenSource(30); Applications = await OpenIdApplicationRepository.GetListAsync(); Languages = await LanguageProvider.GetLanguagesAsync(); From 62529edbf8081e5786141ff0520526d777c80a2b Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 21 Jun 2022 18:34:15 +0300 Subject: [PATCH 44/60] Moved ConvertToDynamicObject to framework --- .../Generic/AbpDictionaryExtensions.cs | 19 +++++++++++++++++ .../Volo.CmsKit.Common.Web/Contents/Helper.cs | 21 ------------------- .../Pages/Public/CmsKit/Blogs/BlogPost.cshtml | 2 -- .../Pages/Public/CmsKit/Pages/Index.cshtml | 5 +---- 4 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs diff --git a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs index 1e6dd0288c..6ac5601f7d 100644 --- a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs @@ -1,4 +1,5 @@ using System.Collections.Concurrent; +using System.Dynamic; namespace System.Collections.Generic; @@ -128,4 +129,22 @@ public static class AbpDictionaryExtensions { return dictionary.GetOrAdd(key, k => factory()); } + + /// + /// Converts a dictionary to dynamic object so added and removed at run + /// + /// The collection object + /// If value is correct, return ExpandoObject that represents an object + public static dynamic ConvertToDynamicObject(this Dictionary dictionary) + { + var expandoObject = new ExpandoObject(); + var expendObjectCollection = (ICollection>)expandoObject; + + foreach (var keyValuePair in dictionary) + { + expendObjectCollection.Add(keyValuePair); + } + + return expandoObject; + } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs deleted file mode 100644 index d61c5f418a..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Web/Contents/Helper.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.Dynamic; - -namespace Volo.CmsKit.Web.Contents; - -public static class DictionaryDynamicExtensions -{ - public static dynamic ConvertToDynamicObject(this Dictionary dict) //TODO: Move to AbpDictionaryExtensions - { - var expandoObject = new ExpandoObject(); - var eoColl = (ICollection>)expandoObject; - - foreach (var kvp in dict) - { - eoColl.Add(kvp); - } - - return expandoObject; - } -} - diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml index d9211ed04c..2cff5c9072 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/BlogPost.cshtml @@ -1,6 +1,5 @@ @page -@using System.Dynamic @using Volo.Abp.Data @using Volo.CmsKit.Public.Blogs @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment @@ -13,7 +12,6 @@ @using Volo.CmsKit.Public.Web.Renderers @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs @using Volo.CmsKit.Contents -@using Volo.CmsKit.Web.Contents; @inherits CmsKitPublicPageBase diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml index 17045c4575..5a92ae2b04 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Pages/Index.cshtml @@ -1,5 +1,4 @@ - -@page +@page @addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap @using Volo.CmsKit.Contents @using System.Dynamic @@ -7,8 +6,6 @@ @using Volo.Abp.Data @using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; @using Volo.Abp.AspNetCore.Mvc.UI.Widgets; -@using Volo.CmsKit.Web.Contents; - @inject IMarkdownToHtmlRenderer MarkdownRenderer From 846cb4d6d6a9729573bb16ad3011618cd34e2bfc Mon Sep 17 00:00:00 2001 From: MagicalConch <37917403+git102347501@users.noreply.github.com> Date: Wed, 22 Jun 2022 09:23:15 +0800 Subject: [PATCH 45/60] Update Redis-Cache.md --- docs/zh-Hans/Redis-Cache.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/zh-Hans/Redis-Cache.md b/docs/zh-Hans/Redis-Cache.md index c9a0d020dd..27a420a4bb 100644 --- a/docs/zh-Hans/Redis-Cache.md +++ b/docs/zh-Hans/Redis-Cache.md @@ -1,11 +1,11 @@ # Redis 缓存 -ABP Framework [缓存系统](Caching.md) 拓展了 [ASP.NET Core 分布式缓存](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed). 因此, 标准 ASP.NET Core 分布式缓存支持的 **任何提供程序** 都可以在您的应用程序中使用,并且可以像 **微软文档** 那样进行配置. +ABP Framework [缓存系统](Caching.md) 拓展了 [ASP.NET Core 分布式缓存](https://docs.microsoft.com/zh-cn/aspnet/core/performance/caching/distributed). 因此, 标准 ASP.NET Core 分布式缓存支持的 **任何提供程序** 都可以在你的应用程序中使用,并且可以像 **微软文档** 那样进行配置. 不过, ABP为 Redis Cache 还提供了一个集成包: [Volo.Abp.Caching.StackExchangeRedis](https://www.nuget.org/packages/Volo.Abp.Caching.StackExchangeRedis). 为何使用中这个包而不是标准的[Microsoft.Extensions.Caching.StackExchangeRedis](https://www.nuget.org/packages/Microsoft.Extensions.Caching.StackExchangeRedis/)包有两个原因. -1. 它实现 `SetManyAsync` 和 `GetManyAsync` 方法. 这些都不是 Microsoft 缓存库的标准方法,而是由ABP框架[缓存](Caching.md)系统添加的. 当您需要通过单个方法调用设置/获取多个缓存项时,它们**显着提高了性能**. +1. 它实现 `SetManyAsync` 和 `GetManyAsync` 方法. 这些都不是 Microsoft 缓存库的标准方法,而是由ABP框架[缓存](Caching.md)系统添加的. 当你需要通过单个方法调用设置/获取多个缓存项时,它们**显著提高了性能**. 2. 它 **简化** 了 Redis 缓存 **配置** (将在下面解释). > Volo.Abp.Caching.StackExchangeRedis 已经使用了 Microsoft.Extensions.Caching.StackExchangeRedis 包,但对其进行了扩展和改进. @@ -20,7 +20,7 @@ abp add-package Volo.Abp.Caching.StackExchangeRedis ## 配置 -Volo.Abp.Caching.StackExchangeRedis 包自动从`IConfiguration`获取Redis[配置](Configuration.md). 因此,您可以在以下位置设置配置 `appsettings.json`: +Volo.Abp.Caching.StackExchangeRedis 包自动从`IConfiguration`获取Redis[配置](Configuration.md). 因此,你可以在以下位置设置配置 `appsettings.json`: ````js "Redis": { @@ -31,7 +31,7 @@ Volo.Abp.Caching.StackExchangeRedis 包自动从`IConfiguration`获取Redis[配 设置`IsEnabled`为可选的,如果未设置将默认视为`true`. -或者,您可以[模块](Module-Development-Basics.md)的方法中配置标准的[RedisCacheOptions](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.stackexchangeredis.rediscacheoptions)类: `ConfigureServices` +或者,你可以在[模块](Module-Development-Basics.md)的ConfigureServices方法中配置标准的[RedisCacheOptions](https://docs.microsoft.com/zh-cn/dotnet/api/microsoft.extensions.caching.stackexchangeredis.rediscacheoptions)类: `ConfigureServices` ````csharp Configure(options => From 93082f2bf40d6b8f7c790a9286933a31f10038ca Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Wed, 22 Jun 2022 09:57:24 +0300 Subject: [PATCH 46/60] Add missing localization --- .../AbpIoLocalization/Commercial/Localization/Resources/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index 0fdcd10747..36c00e9015 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -400,6 +400,7 @@ "UserDeveloperDescription": "The 'Developers' can write code in the ABP Commercial projects, download the ABP sample projects, and ask questions on the support website. On the other hand, the 'Developers' cannot manage this organization.", "RemoveCurrentUserFromOrganizationWarningMessage": "You are removing yourself from your own organization. You will no longer be able to manage this organization, do you confirm?", "RenewExistingOrganizationOrCreateNewOneMessage": "You can renew the license of your organization(s) by clicking the below \"Extend Now\" button(s) and thus you can extend the license expiration date by 1 year. If you continue to checkout, you will have a new organization. Do you want to continue with a new organization?", + "PurchaseTrialOrganizationOrCreateNewOneMessage": "You have a trial license. To purchase your trial license click Purchase Now button. If you continue to checkout, you will have a new organization. Do you want to continue with a new organization?", "ExtendNow": "Extend Now", "CreateNewOrganization": "Create a new organization", "RenewLicenseEarly": "If I renew my license early, will I get the full year?", From 853242e1f738bc5fdc77c6406fd04786ead5d050 Mon Sep 17 00:00:00 2001 From: MagicalConch <37917403+git102347501@users.noreply.github.com> Date: Thu, 23 Jun 2022 10:02:28 +0800 Subject: [PATCH 47/60] Update docs-nav.json --- docs/zh-Hans/docs-nav.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json index d66d11b3cf..203000c6c6 100644 --- a/docs/zh-Hans/docs-nav.json +++ b/docs/zh-Hans/docs-nav.json @@ -167,7 +167,13 @@ }, { "text": "缓存", - "path": "Caching.md" + "path": "Caching.md", + "items": [ + { + "text": "Redis 缓存", + "path": "Redis-Cache.md" + } + ] }, { "text": "日志", From be9e24d27870b194e00cf027b65731143d65dd97 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 23 Jun 2022 14:57:51 +0800 Subject: [PATCH 48/60] Remove `Logout` page. --- ....cs => 20220623064459_Initial.Designer.cs} | 13 ++++++++--- ...5_Initial.cs => 20220623064459_Initial.cs} | 2 ++ .../ServerDbContextModelSnapshot.cs | 11 ++++++++-- .../Controllers/LogoutController.cs | 19 +++++----------- .../Abp/OpenIddict/Views/Logout/Logout.cshtml | 22 ------------------- .../Localization/OpenIddict/el.json | 6 ++--- .../Localization/OpenIddict/en.json | 4 +--- .../Localization/OpenIddict/pt-BR.json | 6 ++--- .../Localization/OpenIddict/tr.json | 4 +--- .../Localization/OpenIddict/zh-Hans.json | 4 +--- .../Localization/OpenIddict/zh-Hant.json | 4 +--- 11 files changed, 34 insertions(+), 61 deletions(-) rename modules/openiddict/app/OpenIddict.Demo.Server/Migrations/{20220425082215_Initial.Designer.cs => 20220623064459_Initial.Designer.cs} (99%) rename modules/openiddict/app/OpenIddict.Demo.Server/Migrations/{20220425082215_Initial.cs => 20220623064459_Initial.cs} (99%) delete mode 100644 modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Logout/Logout.cshtml diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220425082215_Initial.Designer.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220623064459_Initial.Designer.cs similarity index 99% rename from modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220425082215_Initial.Designer.cs rename to modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220623064459_Initial.Designer.cs index be749fd719..db5f69843f 100644 --- a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220425082215_Initial.Designer.cs +++ b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220623064459_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace OpenIddict.Demo.Server.Migrations { [DbContext(typeof(ServerDbContext))] - [Migration("20220425082215_Initial")] + [Migration("20220623064459_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -21,7 +21,7 @@ namespace OpenIddict.Demo.Server.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) - .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("ProductVersion", "6.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); @@ -336,7 +336,8 @@ namespace OpenIddict.Demo.Server.Migrations .HasColumnName("ExtraProperties"); b.Property("IsActive") - .HasColumnType("bit"); + .HasColumnType("bit") + .HasColumnName("IsActive"); b.Property("IsDeleted") .ValueGeneratedOnAdd() @@ -682,6 +683,9 @@ namespace OpenIddict.Demo.Server.Migrations b.Property("ClientSecret") .HasColumnType("nvarchar(max)"); + b.Property("ClientUri") + .HasColumnType("nvarchar(max)"); + b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasMaxLength(40) @@ -732,6 +736,9 @@ namespace OpenIddict.Demo.Server.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("LastModifierId"); + b.Property("LogoUri") + .HasColumnType("nvarchar(max)"); + b.Property("Permissions") .HasColumnType("nvarchar(max)"); diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220425082215_Initial.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220623064459_Initial.cs similarity index 99% rename from modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220425082215_Initial.cs rename to modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220623064459_Initial.cs index 5d8df54c6a..823204d341 100644 --- a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220425082215_Initial.cs +++ b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/20220623064459_Initial.cs @@ -237,6 +237,8 @@ namespace OpenIddict.Demo.Server.Migrations RedirectUris = table.Column(type: "nvarchar(max)", nullable: true), Requirements = table.Column(type: "nvarchar(max)", nullable: true), Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + ClientUri = table.Column(type: "nvarchar(max)", nullable: true), + LogoUri = table.Column(type: "nvarchar(max)", nullable: true), ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), CreationTime = table.Column(type: "datetime2", nullable: false), diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs index 6ec3ed82f7..0ed7013f11 100644 --- a/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs +++ b/modules/openiddict/app/OpenIddict.Demo.Server/Migrations/ServerDbContextModelSnapshot.cs @@ -19,7 +19,7 @@ namespace OpenIddict.Demo.Server.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) - .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("ProductVersion", "6.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); @@ -334,7 +334,8 @@ namespace OpenIddict.Demo.Server.Migrations .HasColumnName("ExtraProperties"); b.Property("IsActive") - .HasColumnType("bit"); + .HasColumnType("bit") + .HasColumnName("IsActive"); b.Property("IsDeleted") .ValueGeneratedOnAdd() @@ -680,6 +681,9 @@ namespace OpenIddict.Demo.Server.Migrations b.Property("ClientSecret") .HasColumnType("nvarchar(max)"); + b.Property("ClientUri") + .HasColumnType("nvarchar(max)"); + b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasMaxLength(40) @@ -730,6 +734,9 @@ namespace OpenIddict.Demo.Server.Migrations .HasColumnType("uniqueidentifier") .HasColumnName("LastModifierId"); + b.Property("LogoUri") + .HasColumnType("nvarchar(max)"); + b.Property("Permissions") .HasColumnType("nvarchar(max)"); diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs index 404fd0da14..9f92fa7f23 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/LogoutController.cs @@ -10,21 +10,12 @@ namespace Volo.Abp.OpenIddict.Controllers; public class LogoutController : AbpOpenIdDictControllerBase { [HttpGet] - public virtual Task GetAsync() + public virtual async Task GetAsync() { - return Task.FromResult(View("Logout")); - } - - [HttpPost] - public virtual async Task PostAsync() - { - if (await HasFormValueAsync("accept")) - { - // Ask ASP.NET Core Identity to delete the local and external cookies created - // when the user agent is redirected from the external identity provider - // after a successful authentication flow (e.g Google or Facebook). - await SignInManager.SignOutAsync(); - } + // Ask ASP.NET Core Identity to delete the local and external cookies created + // when the user agent is redirected from the external identity provider + // after a successful authentication flow (e.g Google or Facebook). + await SignInManager.SignOutAsync(); // Returning a SignOutResult will ask OpenIddict to redirect the user agent // to the post_logout_redirect_uri specified by the client application or to diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Logout/Logout.cshtml b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Logout/Logout.cshtml deleted file mode 100644 index 6838e92ad5..0000000000 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Views/Logout/Logout.cshtml +++ /dev/null @@ -1,22 +0,0 @@ -@using Microsoft.Extensions.Primitives -@using Volo.Abp.OpenIddict.Localization -@using Microsoft.AspNetCore.Mvc.Localization -@model AuthorizeViewModel -@inject IHtmlLocalizer L - -
-

@L["LogOut"]

-

@L["AreYouSureYouWantToSignOut"]

- -
- @Html.AntiForgeryToken() - @* Flow the request parameters so they can be received by the LogoutPost action: *@ - @foreach (var parameter in Context.Request.HasFormContentType ? (IEnumerable>) Context.Request.Form : Context.Request.Query) - { - - } - - - - -
diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/el.json b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/el.json index de0b8ec150..28dbc2cb6f 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/el.json +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/el.json @@ -10,8 +10,6 @@ "DoYouWantToGrantAccessToYourData": "Θέλετε να παραχωρήσετε στον χρήστη {0} πρόσβαση στα δεδομένα σας;", "ScopesRequested": "Ζητούνται πεδία εφαρμογής", "Accept": "Αποδοχή", - "Deny": "Άρνηση", - "LogOut": "Αποσύνδεση", - "AreYouSureYouWantToSignOut": "Είστε βέβαιοι ότι θέλετε να αποσυνδεθείτε;" + "Deny": "Άρνηση" } -} \ No newline at end of file +} diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/en.json b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/en.json index 8bd3a92007..9932b3f97e 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/en.json +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/en.json @@ -10,8 +10,6 @@ "DoYouWantToGrantAccessToYourData": "Do you want to grant {0} access to your data?", "ScopesRequested": "Scopes requested", "Accept": "Accept", - "Deny": "Deny", - "LogOut": "Log out", - "AreYouSureYouWantToSignOut": "Are you sure you want to sign out?" + "Deny": "Deny" } } diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/pt-BR.json b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/pt-BR.json index ebcf57b00e..2952a0352c 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/pt-BR.json +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/pt-BR.json @@ -10,8 +10,6 @@ "DoYouWantToGrantAccessToYourData": "Deseja permitir {0} acesse seus dados?", "ScopesRequested": "Escopo solicitado", "Accept": "Aceitar", - "Deny": "Negar", - "LogOut": "Sair", - "AreYouSureYouWantToSignOut": "Tem certeza que deseja sair?" + "Deny": "Negar" } -} \ No newline at end of file +} diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/tr.json b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/tr.json index 39e525e27e..5ad9154636 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/tr.json +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/tr.json @@ -10,8 +10,6 @@ "DoYouWantToGrantAccessToYourData": "Do you want to grant {0} access to your data?", "ScopesRequested": "İstenen kapsamlar", "Accept": "Kabul etmek", - "Deny": "Reddetmek", - "LogOut": "Çıkış Yap", - "AreYouSureYouWantToSignOut": "Çıkış yapmak istediğinden emin misin?" + "Deny": "Reddetmek" } } diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hans.json b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hans.json index 3c6fd502b3..9c4577d9c0 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hans.json +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hans.json @@ -10,8 +10,6 @@ "DoYouWantToGrantAccessToYourData": "是否要授予 {0} 访问你的数据的权限?", "ScopesRequested": "要求的Scope", "Accept": "同意", - "Deny": "拒绝", - "LogOut": "注销", - "AreYouSureYouWantToSignOut": "你确定要退出吗?" + "Deny": "拒绝" } } diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hant.json b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hant.json index 5d22654a76..8ecebfc676 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hant.json +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo/Abp/OpenIddict/Localization/OpenIddict/zh-Hant.json @@ -11,8 +11,6 @@ "DoYouWantToGrantAccessToYourData": "是否要授予 {0} 訪問你的數據的權限?", "ScopesRequested": "要求的Scope", "Accept": "接受", - "Deny": "拒絕", - "LogOut": "註銷", - "AreYouSureYouWantToSignOut": "你確定要退出嗎?" + "Deny": "拒絕" } } From a3b8f0828bf2a80bde46391376f5a863c057e4dd Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 23 Jun 2022 15:15:11 +0300 Subject: [PATCH 49/60] Update TemplateProjectBuilder.cs --- .../Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index db430296fa..bc071a4288 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -59,6 +59,10 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency NormalizeArgs(args, templateInfo); + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Fetching the solution template" + }, false); + var templateFile = await SourceCodeStore.GetAsync( args.TemplateName, SourceCodeTypes.Template, From 73481e441954f0012aa08c9b7b74a95ead175cd8 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Thu, 23 Jun 2022 17:25:17 +0300 Subject: [PATCH 50/60] CLI: Remove the IdentityServer project from app template if it's not needed --- .../Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index 75441af295..2503378828 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -349,6 +349,7 @@ public abstract class AppTemplateBase : TemplateInfo else { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.AuthServer")); steps.Add(new TemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); @@ -388,6 +389,7 @@ public abstract class AppTemplateBase : TemplateInfo { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Blazor.Server.Tiered")); steps.Add(new TemplateProjectRenameStep("MyCompanyName.MyProjectName.Blazor.Server", "MyCompanyName.MyProjectName.Blazor")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.AuthServer")); steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44313")); @@ -409,6 +411,7 @@ public abstract class AppTemplateBase : TemplateInfo { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.AuthServer")); steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44303")); } @@ -439,6 +442,7 @@ public abstract class AppTemplateBase : TemplateInfo else { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.AuthServer")); steps.Add(new TemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); From c457e1f3590147c20d3da4b25529c3eff6672fe8 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 24 Jun 2022 09:51:43 +0800 Subject: [PATCH 51/60] Introdce the `IApplicationConfigurationContributor`. Resolve #13099 --- .../AbpApplicationConfigurationOptions.cs | 13 +++++++++++++ ...pplicationConfigurationContributorContext.cs | 17 +++++++++++++++++ .../ApplicationConfigurationDto.cs | 3 ++- .../IApplicationConfigurationContributor.cs | 8 ++++++++ .../AbpApplicationConfigurationAppService.cs | 17 ++++++++++++++++- .../Mvc/AbpAspNetCoreMvcTestModule.cs | 6 ++++++ .../ApplicationConfigurationBuilder_Tests.cs | 2 ++ .../TestApplicationConfigurationContributor.cs | 13 +++++++++++++ 8 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationOptions.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationContributorContext.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IApplicationConfigurationContributor.cs create mode 100644 framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TestApplicationConfigurationContributor.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationOptions.cs new file mode 100644 index 0000000000..e4e59bc197 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationOptions.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class AbpApplicationConfigurationOptions +{ + public List Contributors { get; } + + public AbpApplicationConfigurationOptions() + { + Contributors = new List(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationContributorContext.cs new file mode 100644 index 0000000000..3831cc1618 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationContributorContext.cs @@ -0,0 +1,17 @@ +using System; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class ApplicationConfigurationContributorContext : IServiceProviderAccessor +{ + public IServiceProvider ServiceProvider { get; } + + public ApplicationConfigurationDto ApplicationConfiguration { get; } + + public ApplicationConfigurationContributorContext(IServiceProvider serviceProvider, ApplicationConfigurationDto applicationConfiguration) + { + ServiceProvider = serviceProvider; + ApplicationConfiguration = applicationConfiguration; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs index eb29c5c7cb..4a7a21959f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs @@ -1,11 +1,12 @@ using System; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; +using Volo.Abp.ObjectExtending; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; [Serializable] -public class ApplicationConfigurationDto +public class ApplicationConfigurationDto : ExtensibleObject { public ApplicationLocalizationConfigurationDto Localization { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IApplicationConfigurationContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IApplicationConfigurationContributor.cs new file mode 100644 index 0000000000..7612ae6fec --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IApplicationConfigurationContributor.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public interface IApplicationConfigurationContributor +{ + Task ContributeAsync(ApplicationConfigurationContributorContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index b80a288e81..abf3fe603c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -41,6 +41,7 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp private readonly ITimezoneProvider _timezoneProvider; private readonly AbpClockOptions _abpClockOptions; private readonly ICachedObjectExtensionsDtoService _cachedObjectExtensionsDtoService; + private readonly AbpApplicationConfigurationOptions _options; public AbpApplicationConfigurationAppService( IOptions localizationOptions, @@ -58,7 +59,8 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp ILanguageProvider languageProvider, ITimezoneProvider timezoneProvider, IOptions abpClockOptions, - ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService) + ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService, + IOptions options) { _serviceProvider = serviceProvider; _abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider; @@ -74,6 +76,7 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp _timezoneProvider = timezoneProvider; _abpClockOptions = abpClockOptions.Value; _cachedObjectExtensionsDtoService = cachedObjectExtensionsDtoService; + _options = options.Value; _localizationOptions = localizationOptions.Value; _multiTenancyOptions = multiTenancyOptions.Value; } @@ -99,6 +102,18 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp ObjectExtensions = _cachedObjectExtensionsDtoService.Get() }; + if (_options.Contributors.Any()) + { + using (var scope = _serviceProvider.CreateScope()) + { + var context = new ApplicationConfigurationContributorContext(scope.ServiceProvider, result); + foreach (var contributor in _options.Contributors) + { + await contributor.ContributeAsync(context); + } + } + } + Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAsync()."); return result; diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs index 2e8d8c4689..e303a0fb5d 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; using Volo.Abp.AspNetCore.Mvc.Authorization; using Volo.Abp.AspNetCore.Mvc.GlobalFeatures; using Volo.Abp.AspNetCore.Mvc.Localization; @@ -127,6 +128,11 @@ public class AbpAspNetCoreMvcTestModule : AbpModule options.Maps.Add("SerialNumber", () => ClaimTypes.SerialNumber); options.Maps.Add("DateOfBirth", () => ClaimTypes.DateOfBirth); }); + + Configure(options => + { + options.Contributors.Add(new TestApplicationConfigurationContributor()); + }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder_Tests.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder_Tests.cs index c932e09488..5d3cb09749 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder_Tests.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder_Tests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Shouldly; +using Volo.Abp.Data; using Xunit; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; @@ -15,5 +16,6 @@ public class ApplicationConfigurationBuilder_Tests : AspNetCoreMvcTestBase config.Auth.ShouldNotBeNull(); config.Localization.ShouldNotBeNull(); + config.GetProperty("TestKey").ShouldBe("TestValue"); } } diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TestApplicationConfigurationContributor.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TestApplicationConfigurationContributor.cs new file mode 100644 index 0000000000..4ae197d2a0 --- /dev/null +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TestApplicationConfigurationContributor.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Volo.Abp.Data; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class TestApplicationConfigurationContributor : IApplicationConfigurationContributor +{ + public Task ContributeAsync(ApplicationConfigurationContributorContext context) + { + context.ApplicationConfiguration.SetProperty("TestKey", "TestValue"); + return Task.CompletedTask; + } +} From 9a9e8d36df7849c30d398d55ee2c75db1722da13 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 24 Jun 2022 09:56:06 +0800 Subject: [PATCH 52/60] Use `IHasExtraProperties` to replace `ExtensibleObject`. --- .../ApplicationConfigurationDto.cs | 6 ++++-- .../AbpApplicationConfigurationAppService.cs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs index 4a7a21959f..61b5ec18db 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs @@ -1,12 +1,12 @@ using System; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; -using Volo.Abp.ObjectExtending; +using Volo.Abp.Data; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; [Serializable] -public class ApplicationConfigurationDto : ExtensibleObject +public class ApplicationConfigurationDto : IHasExtraProperties { public ApplicationLocalizationConfigurationDto Localization { get; set; } @@ -29,4 +29,6 @@ public class ApplicationConfigurationDto : ExtensibleObject public ClockDto Clock { get; set; } public ObjectExtensionsDto ObjectExtensions { get; set; } + + public ExtraPropertyDictionary ExtraProperties { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index abf3fe603c..528a04583d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -13,6 +13,7 @@ using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; using Volo.Abp.Authorization; using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Data; using Volo.Abp.Features; using Volo.Abp.GlobalFeatures; using Volo.Abp.Localization; @@ -99,7 +100,8 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp CurrentTenant = GetCurrentTenant(), Timing = await GetTimingConfigAsync(), Clock = GetClockConfig(), - ObjectExtensions = _cachedObjectExtensionsDtoService.Get() + ObjectExtensions = _cachedObjectExtensionsDtoService.Get(), + ExtraProperties = new ExtraPropertyDictionary() }; if (_options.Contributors.Any()) From 91a6f41a188ab9aac709ddccb6359cdea1fa5282 Mon Sep 17 00:00:00 2001 From: JRoger Date: Fri, 24 Jun 2022 13:28:15 +0800 Subject: [PATCH 53/60] chore: Update typo in error message --- framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs index 2a73b72932..741f6f0586 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs @@ -223,7 +223,7 @@ public abstract class AbpApplicationBase : IAbpApplication { if (_configuredServices) { - throw new AbpInitializationException("Services have already been configured! If you call ConfigureServicesAsync method, you must have set AbpApplicationCreationOptions.SkipConfigureServices tu true before."); + throw new AbpInitializationException("Services have already been configured! If you call ConfigureServicesAsync method, you must have set AbpApplicationCreationOptions.SkipConfigureServices to true before."); } } @@ -231,7 +231,7 @@ public abstract class AbpApplicationBase : IAbpApplication public virtual void ConfigureServices() { CheckMultipleConfigureServices(); - + var context = new ServiceConfigurationContext(Services); Services.AddSingleton(context); From 4115a9a23c85f87ff09b7f6337262bc17cc3195b Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 24 Jun 2022 14:47:18 +0800 Subject: [PATCH 54/60] Enhance MauiChangeApplicationIdGuidStep --- .../Steps/ChangeApplicationIdGuidStep.cs | 14 -------- .../Maui/MauiChangeApplicationIdGuidStep.cs | 34 +++++++++++++++++++ .../Templates/Maui/MauiTemplateBase.cs | 2 +- 3 files changed, 35 insertions(+), 15 deletions(-) delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeApplicationIdGuidStep.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiChangeApplicationIdGuidStep.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeApplicationIdGuidStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeApplicationIdGuidStep.cs deleted file mode 100644 index d37b7a67c3..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeApplicationIdGuidStep.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Linq; - -namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps; - -public class ChangeApplicationIdGuidStep: ProjectBuildPipelineStep -{ - public override void Execute(ProjectBuildContext context) - { - var projectFile = context.Files.FirstOrDefault(f => f.Name.EndsWith("MyCompanyName.MyProjectName.csproj")); - - projectFile?.SetContent(projectFile.Content.Replace("27317750-B571-4690-B433-B358B2480E01", Guid.NewGuid().ToString())); - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiChangeApplicationIdGuidStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiChangeApplicationIdGuidStep.cs new file mode 100644 index 0000000000..9bbaa8b553 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiChangeApplicationIdGuidStep.cs @@ -0,0 +1,34 @@ +using System; +using System.Linq; +using System.Xml; +using Volo.Abp.Cli.ProjectBuilding.Building; +using Volo.Abp.Cli.Utils; + +namespace Volo.Abp.Cli.ProjectBuilding.Templates.Maui; + +public class MauiChangeApplicationIdGuidStep: ProjectBuildPipelineStep +{ + public override void Execute(ProjectBuildContext context) + { + var projectFile = context.Files.FirstOrDefault(f => f.Name.EndsWith("MyCompanyName.MyProjectName.csproj") || f.Name.EndsWith("MyCompanyName.MyProjectName.Maui.csproj")); + + if (projectFile == null) + { + return; + } + + using (var stream = StreamHelper.GenerateStreamFromString(projectFile.Content)) + { + var doc = new XmlDocument { PreserveWhitespace = true }; + doc.Load(stream); + + var node = doc.SelectSingleNode("/Project/PropertyGroup/ApplicationIdGuid"); + if (node != null) + { + node.InnerText = Guid.NewGuid().ToString(); + } + + projectFile.SetContent(doc.OuterXml); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiTemplateBase.cs index 399773ce32..c17d661efa 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Maui/MauiTemplateBase.cs @@ -16,7 +16,7 @@ public class MauiTemplateBase: TemplateInfo { var steps = new List { - new ChangeApplicationIdGuidStep() + new MauiChangeApplicationIdGuidStep() }; return steps; From 629390833d108eaae4013963edcf7bf664c0bb6c Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 24 Jun 2022 17:04:31 +0800 Subject: [PATCH 55/60] Fix typo in CLI document --- docs/en/CLI.md | 2 +- docs/zh-Hans/CLI.md | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/en/CLI.md b/docs/en/CLI.md index 0597c0daf5..87522e2923 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -193,7 +193,7 @@ Example: abp add-package Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic ```` -* This example adds the Volo.Abp.MongoDB package to the project. +* This example adds the `Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic` package to the project. #### Options diff --git a/docs/zh-Hans/CLI.md b/docs/zh-Hans/CLI.md index dcdf6c2303..bd2c75230b 100644 --- a/docs/zh-Hans/CLI.md +++ b/docs/zh-Hans/CLI.md @@ -168,10 +168,10 @@ abp add-package <包名> [options] 示例: ```` -abp add-package Volo.Abp.MongoDB +abp add-package Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic ```` -* 示例中将Volo.Abp.MongoDB包添加到项目中. +* 示例中将`Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic`包添加到项目中. #### Options @@ -179,6 +179,12 @@ abp add-package Volo.Abp.MongoDB * `--with-source-code`: 下载包的源码到你的解决方案文件夹,而不是NuGet/NPM软件包. * `--add-to-solution-file`: 添加下载/创建的包添加到解决方案文件中,你在IDE中打开解决方案时也会看到包的项目. (仅当 `--with-source-code` 为 `True` 时可用.) +> 当前只有基本主题包([MVC](https://docs.abp.io/zh-Hans/abp/latest/UI/AspNetCore/Basic-Theme) 和 [Blazor](https://docs.abp.io/zh-Hans/abp/latest/UI/Blazor/Basic-Theme)) 可以下载. +> - Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic +> - Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme +> - Volo.Abp.AspNetCore.Components.Web.BasicTheme +> - Volo.Abp.AspNetCore.Components.Server.BasicTheme + ### add-module 通过查找模块的所有包,查找解决方案中的相关项目,并将每个包添加到解决方案中的相应项目,从而将[多包应用程序模块](Modules/Index)添加到解决方案中. From 2aaa7059f6bf80389885fa53d32c5929ea4870c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alper=20Ebi=C3=A7o=C4=9Flu?= <9526587+ebicoglu@users.noreply.github.com> Date: Sat, 25 Jun 2022 11:34:44 +0300 Subject: [PATCH 56/60] Update TemplateProjectBuilder.cs --- .../Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index bc071a4288..4aa6be745f 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -60,7 +60,7 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency NormalizeArgs(args, templateInfo); await EventBus.PublishAsync(new ProjectCreationProgressEvent { - Message = "Fetching the solution template" + Message = "Downloading the solution template" }, false); var templateFile = await SourceCodeStore.GetAsync( From 2e82e24d92bf9b7ec6f03a2b44b2d11ced3462d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alper=20Ebi=C3=A7o=C4=9Flu?= <9526587+ebicoglu@users.noreply.github.com> Date: Sat, 25 Jun 2022 11:48:43 +0300 Subject: [PATCH 57/60] Update TemplateProjectBuilder.cs --- .../Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index 4aa6be745f..126e9bdbf9 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -127,7 +127,7 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency } await EventBus.PublishAsync(new ProjectCreationProgressEvent { - Message = "Preparing the solution according to preferences" + Message = "Customizing the solution template" }, false); TemplateProjectBuildPipelineBuilder.Build(context).Execute(); From 90494d78c2d143818e4305734b119e690639f4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alper=20Ebi=C3=A7o=C4=9Flu?= <9526587+ebicoglu@users.noreply.github.com> Date: Sat, 25 Jun 2022 11:52:10 +0300 Subject: [PATCH 58/60] Update ProjectCreationCommandBase.cs --- .../Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs index 42a2fd72cb..356bd98dd5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs @@ -207,7 +207,7 @@ public abstract class ProjectCreationCommandBase protected void ExtractProjectZip(ProjectBuildResult project, string outputFolder) { EventBus.PublishAsync(new ProjectCreationProgressEvent { - Message = "Extracting solution to file system" + Message = "Extracting the solution archieve" }, false); using (var templateFileStream = new MemoryStream(project.ZipContent)) From 14f385312791422adf4e39dd29f7ecfc55f26af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alper=20Ebi=C3=A7o=C4=9Flu?= <9526587+ebicoglu@users.noreply.github.com> Date: Sat, 25 Jun 2022 12:12:01 +0300 Subject: [PATCH 59/60] Update ProjectCreationCommandBase.cs --- .../Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs index 356bd98dd5..fa1408e27b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs @@ -403,7 +403,7 @@ public abstract class ProjectCreationCommandBase } await EventBus.PublishAsync(new ProjectCreationProgressEvent { - Message = "Creating the initial migration" + Message = "Creating the initial DB migration" }, false); await InitialMigrationCreator.CreateAsync(Path.GetDirectoryName(efCoreProjectPath), isLayeredTemplate); From adc58416e05ec730473c4fab1a2b9ce7192ec1dc Mon Sep 17 00:00:00 2001 From: MagicalConch <37917403+git102347501@users.noreply.github.com> Date: Mon, 27 Jun 2022 12:54:24 +0800 Subject: [PATCH 60/60] Update Redis-Cache.md --- docs/zh-Hans/Redis-Cache.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-Hans/Redis-Cache.md b/docs/zh-Hans/Redis-Cache.md index 27a420a4bb..1c6d3caa42 100644 --- a/docs/zh-Hans/Redis-Cache.md +++ b/docs/zh-Hans/Redis-Cache.md @@ -31,7 +31,7 @@ Volo.Abp.Caching.StackExchangeRedis 包自动从`IConfiguration`获取Redis[配 设置`IsEnabled`为可选的,如果未设置将默认视为`true`. -或者,你可以在[模块](Module-Development-Basics.md)的ConfigureServices方法中配置标准的[RedisCacheOptions](https://docs.microsoft.com/zh-cn/dotnet/api/microsoft.extensions.caching.stackexchangeredis.rediscacheoptions)类: `ConfigureServices` +或者,你可以在[模块](Module-Development-Basics.md)的ConfigureServices方法中配置标准的[RedisCacheOptions](https://docs.microsoft.com/zh-cn/dotnet/api/microsoft.extensions.caching.stackexchangeredis.rediscacheoptions)类: ````csharp Configure(options =>