mirror of https://github.com/abpframework/abp.git
committed by
GitHub
39 changed files with 417 additions and 231 deletions
@ -0,0 +1,8 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.CmsKit.Contents; |
||||
|
|
||||
|
public class DefaultContentDto : IContent |
||||
|
{ |
||||
|
public List<ContentFragment> ContentFragments { get; set; } |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.CmsKit.Contents; |
||||
|
public interface IContent |
||||
|
{ |
||||
|
public List<ContentFragment> ContentFragments { get; set; } |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace Volo.CmsKit.Contents; |
||||
|
|
||||
|
public interface IContentAppService : IApplicationService |
||||
|
{ |
||||
|
Task<List<ContentFragment>> ParseAsync(string content); |
||||
|
} |
||||
@ -1,22 +1,21 @@ |
|||||
using System; |
using System.Collections.Generic; |
||||
using System.Collections.Generic; |
using System; |
||||
using Volo.Abp.Application.Dtos; |
using Volo.Abp.Application.Dtos; |
||||
using Volo.CmsKit.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Pages; |
namespace Volo.CmsKit.Contents; |
||||
|
|
||||
[Serializable] |
[Serializable] |
||||
public class PageDto : EntityDto<Guid> |
public class PageDto : EntityDto<Guid>, IContent |
||||
{ |
{ |
||||
public string Title { get; set; } |
public string Title { get; set; } |
||||
|
|
||||
public string Slug { get; set; } |
public string Slug { get; set; } |
||||
|
|
||||
public string Content { get; set; } |
public string Content { get; set; } |
||||
|
|
||||
public List<ContentFragment> ContentFragments { get; set; } |
public List<ContentFragment> ContentFragments { get; set; } |
||||
|
|
||||
public string Script { get; set; } |
public string Script { get; set; } |
||||
|
|
||||
public string Style { get; set; } |
public string Style { get; set; } |
||||
} |
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.GlobalFeatures; |
||||
|
using Volo.CmsKit.GlobalFeatures; |
||||
|
|
||||
|
namespace Volo.CmsKit.Contents; |
||||
|
|
||||
|
[RequiresGlobalFeature(typeof(PagesFeature))] |
||||
|
public class ContentAppService : CmsKitAppServiceBase, IContentAppService |
||||
|
{ |
||||
|
protected ContentParser ContentParser { get; } |
||||
|
|
||||
|
public ContentAppService(ContentParser contentParser) |
||||
|
{ |
||||
|
ContentParser = contentParser; |
||||
|
} |
||||
|
|
||||
|
public async Task<List<ContentFragment>> ParseAsync(string content) |
||||
|
{ |
||||
|
return await ContentParser.ParseAsync(content); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.CmsKit.Web.Pages.CmsKit.Components.ContentPreview; |
||||
|
|
||||
|
namespace Volo.CmsKit.Web.Controllers; |
||||
|
|
||||
|
public class CmsKitCommonWidgetsController : AbpController |
||||
|
{ |
||||
|
[HttpPost] |
||||
|
public IActionResult ContentPreview(ContentPreviewDto dto) |
||||
|
{ |
||||
|
return ViewComponent(typeof(ContentPreviewViewComponent), new { content = dto.Content }); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.CmsKit.Web.Pages.CmsKit.Components.ContentPreview; |
||||
|
|
||||
|
[Serializable] |
||||
|
public class ContentPreviewDto |
||||
|
{ |
||||
|
public string Content { get; set; } |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.CmsKit.Contents; |
||||
|
|
||||
|
namespace Volo.CmsKit.Web.Pages.CmsKit.Components.ContentPreview; |
||||
|
|
||||
|
public class ContentPreviewViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
protected IContentAppService ContentAppService { get; } |
||||
|
|
||||
|
public ContentPreviewViewComponent(IContentAppService contentAppService) |
||||
|
{ |
||||
|
ContentAppService = contentAppService; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IViewComponentResult> InvokeAsync(string content) |
||||
|
{ |
||||
|
var fragments = await ContentAppService.ParseAsync(content); |
||||
|
|
||||
|
return View("~/Pages/CmsKit/Components/ContentPreview/Default.cshtml", new DefaultContentDto |
||||
|
{ |
||||
|
ContentFragments = fragments |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
@using Volo.CmsKit.Contents |
||||
|
@using Volo.CmsKit.Web.Pages.CmsKit.Components.Contents |
||||
|
|
||||
|
@model DefaultContentDto |
||||
|
|
||||
|
<div class="content"> |
||||
|
|
||||
|
@await Component.InvokeAsync(typeof(ContentFragmentViewComponent), Model) |
||||
|
|
||||
|
</div> |
||||
@ -0,0 +1,20 @@ |
|||||
|
@using System.Dynamic |
||||
|
@using Volo.Abp.Data |
||||
|
@using Volo.CmsKit.Web.Renderers; |
||||
|
@using Volo.CmsKit.Web.Pages.CmsKit.Components.Contents; |
||||
|
|
||||
|
@model ContentFragmentViewComponent |
||||
|
|
||||
|
@inject IMarkdownToHtmlRenderer MarkdownRenderer |
||||
|
|
||||
|
@foreach (var contentFragment in Model.ContentDto.ContentFragments) |
||||
|
{ |
||||
|
if (contentFragment.Type == "Markdown") |
||||
|
{ |
||||
|
@Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty<string>("Content"))) |
||||
|
} |
||||
|
else if (contentFragment.Type == "Widget") |
||||
|
{ |
||||
|
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
||||
|
using Volo.CmsKit.Contents; |
||||
|
|
||||
|
namespace Volo.CmsKit.Web.Pages.CmsKit.Components.Contents; |
||||
|
|
||||
|
[ViewComponent(Name = "ContentFragment")] |
||||
|
[Widget( |
||||
|
AutoInitialize = true |
||||
|
)] |
||||
|
public class ContentFragmentViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
public IContent ContentDto { get; set; } |
||||
|
|
||||
|
public virtual async Task<IViewComponentResult> InvokeAsync(IContent contentDto) |
||||
|
{ |
||||
|
return View("~/Pages/CmsKit/Components/Contents/ContentFragment.cshtml", new ContentFragmentViewComponent() { ContentDto = contentDto }); |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,6 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
|
||||
namespace Volo.CmsKit.Web.Contents; |
namespace Volo.CmsKit.Web.Pages.CmsKit.Components.Contents; |
||||
|
|
||||
public interface IContentRenderer |
public interface IContentRenderer |
||||
{ |
{ |
||||
@ -1,7 +1,7 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
namespace Volo.CmsKit.Web.Contents; |
namespace Volo.CmsKit.Web.Pages.CmsKit.Components.Contents; |
||||
|
|
||||
public class PlainTextContentRenderer : IContentRenderer, ITransientDependency |
public class PlainTextContentRenderer : IContentRenderer, ITransientDependency |
||||
{ |
{ |
||||
@ -1,6 +1,6 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
|
||||
namespace Volo.CmsKit.Public.Web.Renderers; |
namespace Volo.CmsKit.Web.Renderers; |
||||
|
|
||||
public interface IMarkdownToHtmlRenderer |
public interface IMarkdownToHtmlRenderer |
||||
{ |
{ |
||||
@ -1,38 +1,40 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
<Import Project="..\..\..\..\common.props" /> |
<Import Project="..\..\..\..\common.props" /> |
||||
<Import Project="..\..\..\..\configureawait.props" /> |
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
<TargetFramework>net6.0</TargetFramework> |
||||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
<IsPackable>true</IsPackable> |
<IsPackable>true</IsPackable> |
||||
<OutputType>Library</OutputType> |
<OutputType>Library</OutputType> |
||||
<RootNamespace>Volo.CmsKit.Web</RootNamespace> |
<RootNamespace>Volo.CmsKit.Web</RootNamespace> |
||||
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> |
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" /> |
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" /> |
||||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
||||
<ProjectReference Include="..\Volo.CmsKit.Common.Application.Contracts\Volo.CmsKit.Common.Application.Contracts.csproj" /> |
<ProjectReference Include="..\Volo.CmsKit.Common.Application.Contracts\Volo.CmsKit.Common.Application.Contracts.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.5" /> |
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.5" /> |
||||
</ItemGroup> |
<PackageReference Include="Markdig.Signed" Version="0.26.0" /> |
||||
|
<PackageReference Include="HtmlSanitizer" Version="5.0.331" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<EmbeddedResource Include="wwwroot\**\*.*" /> |
<EmbeddedResource Include="wwwroot\**\*.*" /> |
||||
<Content Remove="wwwroot\**\*.*" /> |
<Content Remove="wwwroot\**\*.*" /> |
||||
<EmbeddedResource Include="Pages\**\*.css" /> |
<EmbeddedResource Include="Pages\**\*.css" /> |
||||
<Content Remove="Pages\**\*.css" /> |
<Content Remove="Pages\**\*.css" /> |
||||
<EmbeddedResource Include="Pages\**\*.js" /> |
<EmbeddedResource Include="Pages\**\*.js" /> |
||||
<Content Remove="Pages\**\*.js" /> |
<Content Remove="Pages\**\*.js" /> |
||||
<EmbeddedResource Include="Components\**\*.js" /> |
<EmbeddedResource Include="Components\**\*.js" /> |
||||
<EmbeddedResource Include="Components\**\*.css" /> |
<EmbeddedResource Include="Components\**\*.css" /> |
||||
<Content Remove="Components\**\*.js" /> |
<Content Remove="Components\**\*.js" /> |
||||
<Content Remove="Components\**\*.css" /> |
<Content Remove="Components\**\*.css" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,28 @@ |
|||||
|
using JetBrains.Annotations; |
||||
|
using Volo.Abp.GlobalFeatures; |
||||
|
|
||||
|
namespace Volo.CmsKit.GlobalFeatures; |
||||
|
|
||||
|
[GlobalFeatureName(Name)] |
||||
|
public class ContentsFeature : GlobalFeature |
||||
|
{ |
||||
|
public const string Name = "CmsKit.Contents"; |
||||
|
|
||||
|
internal ContentsFeature( |
||||
|
[NotNull] GlobalCmsKitFeatures cmsKit |
||||
|
) : base(cmsKit) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public override void Enable() |
||||
|
{ |
||||
|
var userFeature = FeatureManager.Modules.CmsKit().User; |
||||
|
if (!userFeature.IsEnabled) |
||||
|
{ |
||||
|
userFeature.Enable(); |
||||
|
} |
||||
|
|
||||
|
base.Enable(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue