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