mirror of https://github.com/abpframework/abp.git
committed by
GitHub
30 changed files with 183 additions and 443 deletions
@ -1,9 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents; |
|
||||
public interface IContentAdminAppService : IApplicationService |
|
||||
{ |
|
||||
Task<ListResultDto<ContentWidgetDto>> GetWidgetsAsync(); |
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Volo.CmsKit.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents; |
|
||||
|
|
||||
public class ContentAdminAppService : CmsKitAdminAppServiceBase, IContentAdminAppService |
|
||||
{ |
|
||||
private readonly CmsKitContentWidgetOptions _options; |
|
||||
|
|
||||
public ContentAdminAppService(IOptions<CmsKitContentWidgetOptions> options) |
|
||||
{ |
|
||||
_options = options.Value; |
|
||||
} |
|
||||
|
|
||||
public virtual Task<ListResultDto<ContentWidgetDto>> GetWidgetsAsync() |
|
||||
{ |
|
||||
return Task.FromResult(new ListResultDto<ContentWidgetDto>() |
|
||||
{ |
|
||||
Items = _options.WidgetConfigs |
|
||||
.Select(n => |
|
||||
new ContentWidgetDto |
|
||||
{ |
|
||||
Key = n.Key, |
|
||||
Details = new WidgetDetailDto() { EditorComponentName = n.Value.EditorComponentName, Name = n.Value.Name }, |
|
||||
|
|
||||
}).ToList() |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
@ -1,22 +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.Admin.Contents; |
|
||||
|
|
||||
// ReSharper disable once CheckNamespace
|
|
||||
namespace Volo.CmsKit.Admin.Contents.ClientProxies; |
|
||||
|
|
||||
[Dependency(ReplaceServices = true)] |
|
||||
[ExposeServices(typeof(IContentAdminAppService), typeof(ContentAdminClientProxy))] |
|
||||
public partial class ContentAdminClientProxy : ClientProxyBase<IContentAdminAppService>, IContentAdminAppService |
|
||||
{ |
|
||||
public virtual async Task<ListResultDto<ContentWidgetDto>> GetWidgetsAsync() |
|
||||
{ |
|
||||
return await RequestAsync<ListResultDto<ContentWidgetDto>>(nameof(GetWidgetsAsync)); |
|
||||
} |
|
||||
} |
|
||||
@ -1,7 +0,0 @@ |
|||||
// This file is part of ContentAdminClientProxy, you can customize it here
|
|
||||
// ReSharper disable once CheckNamespace
|
|
||||
namespace Volo.CmsKit.Admin.Contents.ClientProxies; |
|
||||
|
|
||||
public partial class ContentAdminClientProxy |
|
||||
{ |
|
||||
} |
|
||||
@ -1,25 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents; |
|
||||
|
|
||||
[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] |
|
||||
[Area(CmsKitAdminRemoteServiceConsts.ModuleName)] |
|
||||
[Route("api/cms-kit-admin/contents")] |
|
||||
public class ContentAdminController : CmsKitAdminController, IContentAdminAppService |
|
||||
{ |
|
||||
protected IContentAdminAppService ContentAdminAppService { get; } |
|
||||
|
|
||||
public ContentAdminController(IContentAdminAppService contentAdminAppService) |
|
||||
{ |
|
||||
ContentAdminAppService = contentAdminAppService; |
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
public virtual Task<ListResultDto<ContentWidgetDto>> GetWidgetsAsync() |
|
||||
{ |
|
||||
return ContentAdminAppService.GetWidgetsAsync(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,10 +0,0 @@ |
|||||
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 +0,0 @@ |
|||||
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); |
|
||||
} |
|
||||
} |
|
||||
@ -1,6 +1,6 @@ |
|||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
|
||||
namespace Volo.CmsKit.Contents; |
namespace Volo.CmsKit.Web.Contents; |
||||
|
|
||||
public class CmsKitContentWidgetOptions |
public class CmsKitContentWidgetOptions |
||||
{ |
{ |
||||
@ -1,4 +1,4 @@ |
|||||
namespace Volo.CmsKit.Contents; |
namespace Volo.CmsKit.Web.Contents; |
||||
|
|
||||
public class ContentWidgetConfig |
public class ContentWidgetConfig |
||||
{ |
{ |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using AutoMapper; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.CmsKit.Contents; |
||||
|
using Volo.CmsKit.Users; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs; |
||||
|
|
||||
|
[AutoMap(typeof(BlogPostCommonDto), ReverseMap = true)] |
||||
|
public class BlogPostViewModel : AuditedEntityDto<Guid> |
||||
|
{ |
||||
|
public Guid BlogId { get; set; } |
||||
|
|
||||
|
public string Title { get; set; } |
||||
|
|
||||
|
public string Slug { get; set; } |
||||
|
|
||||
|
public string ShortDescription { get; set; } |
||||
|
|
||||
|
public string Content { get; set; } |
||||
|
|
||||
|
public List<ContentFragment> ContentFragments { get; set; } |
||||
|
|
||||
|
public Guid? CoverImageMediaId { get; set; } |
||||
|
|
||||
|
public CmsUserDto Author { get; set; } |
||||
|
} |
||||
@ -1,27 +0,0 @@ |
|||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Shouldly; |
|
||||
using Volo.CmsKit.Admin.Contents; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Volo.CmsKit.Contents; |
|
||||
|
|
||||
public class ContentAdminAppService_Tests : CmsKitApplicationTestBase |
|
||||
{ |
|
||||
private readonly IContentAdminAppService _contentAdminAppService; |
|
||||
|
|
||||
public ContentAdminAppService_Tests() |
|
||||
{ |
|
||||
_contentAdminAppService = GetRequiredService<IContentAdminAppService>(); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task ShouldGet_PagedListAsync() |
|
||||
{ |
|
||||
var widgets = await _contentAdminAppService.GetWidgetsAsync(); |
|
||||
|
|
||||
widgets.Items.Count.ShouldBe(0); |
|
||||
widgets.Items.Any().ShouldBeFalse(); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,138 +0,0 @@ |
|||||
using System.Collections.Generic; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using Shouldly; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Volo.CmsKit.Contents; |
|
||||
public class ContentParser_Test : CmsKitDomainTestBase |
|
||||
{ |
|
||||
private readonly CmsKitTestData testData; |
|
||||
private readonly IOptions<CmsKitContentWidgetOptions> _options; |
|
||||
private ContentParser contentParser; |
|
||||
|
|
||||
public ContentParser_Test() |
|
||||
{ |
|
||||
testData = GetRequiredService<CmsKitTestData>(); |
|
||||
_options = GetRequiredService<IOptions<CmsKitContentWidgetOptions>>(); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task ParseAsync_ShouldWorkWithDifferentWidgetTypes() |
|
||||
{ |
|
||||
_options.Value.AddWidget(testData.PollName, testData.WidgetName, string.Empty); |
|
||||
_options.Value.AddWidget("ImageGallery", "ImageGallery", string.Empty); |
|
||||
contentParser = new ContentParser(_options); |
|
||||
|
|
||||
var content = @"**ABP Framework** is completely open source and developed in a community-driven manner.
|
|
||||
[Widget Type=""Poll"" Code=""poll-name""] |
|
||||
Thanks _for_ *your * feedback. |
|
||||
[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"" Code =""poll-name""] |
|
||||
Thanks _for_ *your * feedback.";
|
|
||||
|
|
||||
contentParser = new ContentParser(_options); |
|
||||
var widgets = await contentParser.ParseAsync(content); |
|
||||
|
|
||||
widgets.ShouldNotBeNull(); |
|
||||
widgets.Count.ShouldBe(1);//Ignored Widget
|
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task ParseAsync_ShouldWorkWithWrongConfigOptions() |
|
||||
{ |
|
||||
_options.Value.AddWidget(testData.WidgetName, testData.PollName, string.Empty); |
|
||||
contentParser = new ContentParser(_options); |
|
||||
|
|
||||
var content = @"**ABP Framework** is completely open source and developed in a community-driven manner.
|
|
||||
[Widget Type= ""Poll"" Code =""poll-name""] |
|
||||
Thanks _for_ *your * feedback.";
|
|
||||
|
|
||||
var widgets = await contentParser.ParseAsync(content); |
|
||||
|
|
||||
widgets.ShouldNotBeNull(); |
|
||||
widgets.Count.ShouldBe(2); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task ParseAsync_ShouldWorkWithWrongWidgetType() |
|
||||
{ |
|
||||
_options.Value.AddWidget(testData.PollName, testData.WidgetName, string.Empty); |
|
||||
contentParser = new ContentParser(_options); |
|
||||
|
|
||||
var content = @"**ABP Framework** is completely open source and developed in a community-driven manner.
|
|
||||
[Widget Wrong Type= ""Poll"" Code =""poll-name""] |
|
||||
Thanks _for_ *your * feedback.";
|
|
||||
|
|
||||
var widgets = await contentParser.ParseAsync(content); |
|
||||
|
|
||||
widgets.ShouldNotBeNull(); |
|
||||
widgets.Count.ShouldBe(2); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task ParseAsync_ShouldWorkWithWrongPollName() |
|
||||
{ |
|
||||
_options.Value.AddWidget(testData.PollName, testData.WidgetName, string.Empty); |
|
||||
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 widgets = await contentParser.ParseAsync(content); |
|
||||
|
|
||||
widgets.ShouldNotBeNull(); |
|
||||
widgets.Count.ShouldBe(3); |
|
||||
} |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(ExampleData))] |
|
||||
public async Task ParseAsync_ShouldWorkProperlyWithCorrectInputs(string content, int expectedLine) |
|
||||
{ |
|
||||
_options.Value.AddWidget(testData.PollName, testData.WidgetName, string.Empty); |
|
||||
contentParser = new ContentParser(_options); |
|
||||
|
|
||||
var widgets = await contentParser.ParseAsync(content); |
|
||||
|
|
||||
widgets.ShouldNotBeNull(); |
|
||||
widgets.Count.ShouldBe(expectedLine); |
|
||||
} |
|
||||
|
|
||||
public static IEnumerable<object[]> ExampleData => |
|
||||
new List<object[]> |
|
||||
{ |
|
||||
new object[] { @"**ABP Framework** is completely open source and developed in a community-driven manner.
|
|
||||
[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"" Code=""poll-name""] |
|
||||
Thanks _for_ *your * feedback. |
|
||||
[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"" Code=""poll-name""]", 2 },
|
|
||||
|
|
||||
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},
|
|
||||
|
|
||||
new object[] { @"Thanks _for_ *your * feedback.
|
|
||||
Thanks _for_ *your * feedback.", 1}
|
|
||||
}; |
|
||||
} |
|
||||
Loading…
Reference in new issue