Browse Source

remove content related classes

pull/7911/head
Ahmet 6 years ago
parent
commit
0b34091a3f
  1. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml
  2. 23
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentCreateDto.cs
  3. 15
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentDto.cs
  4. 13
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentGetListDto.cs
  5. 10
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentGetListInput.cs
  6. 15
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentUpdateDto.cs
  7. 19
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/IContentAdminAppService.cs
  8. 71
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Contents/ContentAdminController.cs
  9. 35
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml
  10. 9
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml.cs
  11. 114
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/update.js
  12. 11
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/ContentDto.cs
  13. 12
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/GetContentInput.cs
  14. 10
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs
  15. 29
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs
  16. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPost/Default.cshtml
  17. 59
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs
  18. 3
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/Default.cshtml

6
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml

@ -8,7 +8,6 @@
@using Volo.CmsKit.GlobalFeatures
@using Volo.CmsKit.Pages
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Tags
@ -31,11 +30,6 @@
<abp-card>
<abp-card-body class="p-5">
<abp-blockquote class="text-center">
@if (GlobalFeatureManager.Instance.IsEnabled<ContentsFeature>())
{
@await Component.InvokeAsync(typeof(ContentViewComponent), new {entityType = "quote", entityId = "1"})
}
@if (GlobalFeatureManager.Instance.IsEnabled<TagsFeature>())
{
@await Component.InvokeAsync(typeof(TagViewComponent), new

23
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentCreateDto.cs

@ -1,23 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Admin.Contents
{
[Serializable]
public class ContentCreateDto
{
[Required]
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxEntityTypeLength))]
public string EntityType { get; set; }
[Required]
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxEntityIdLength))]
public string EntityId { get; set; }
[Required]
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxValueLength))]
public string Value { get; set; }
}
}

15
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentDto.cs

@ -1,15 +0,0 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Admin.Contents
{
[Serializable]
public class ContentDto : EntityDto<Guid>
{
public string EntityType { get; set; }
public string EntityId { get; set; }
public string Value { get; set; }
}
}

13
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentGetListDto.cs

@ -1,13 +0,0 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Admin.Contents
{
[Serializable]
public class ContentGetListDto : EntityDto<Guid>
{
public string EntityType { get; set; }
public string EntityId { get; set; }
}
}

10
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentGetListInput.cs

@ -1,10 +0,0 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Admin.Contents
{
[Serializable]
public class ContentGetListInput : PagedAndSortedResultRequestDto
{
}
}

15
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentUpdateDto.cs

@ -1,15 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Admin.Contents
{
[Serializable]
public class ContentUpdateDto
{
[Required]
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxValueLength))]
public string Value { get; set; }
}
}

19
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/IContentAdminAppService.cs

@ -1,19 +0,0 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.CmsKit.Admin.Contents;
namespace Volo.CmsKit.Admin.Contents
{
public interface IContentAdminAppService
: ICrudAppService<
ContentDto,
ContentGetListDto,
Guid,
ContentGetListInput,
ContentCreateDto,
ContentUpdateDto>
{
Task<ContentDto> GetAsync(string entityType, string entityId);
}
}

71
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Contents/ContentAdminController.cs

@ -1,71 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Admin.Contents;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Permissions;
namespace Volo.CmsKit.Admin.Contents
{
[Authorize(CmsKitAdminPermissions.Contents.Default)]
[RequiresGlobalFeature(typeof(ContentsFeature))]
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit-admin/contents")]
public class ContentAdminController : CmsKitAdminController, IContentAdminAppService
{
protected IContentAdminAppService ContentAdminAppService { get; }
public ContentAdminController(IContentAdminAppService contentAdminAppService)
{
ContentAdminAppService = contentAdminAppService;
}
[HttpPost]
[Authorize(CmsKitAdminPermissions.Contents.Create)]
public Task<ContentDto> CreateAsync(ContentCreateDto input)
{
return ContentAdminAppService.CreateAsync(input);
}
[HttpDelete("{id}")]
[Authorize(CmsKitAdminPermissions.Contents.Delete)]
public Task DeleteAsync(Guid id)
{
return ContentAdminAppService.DeleteAsync(id);
}
[HttpGet("{id}")]
[Authorize(CmsKitAdminPermissions.Contents.Default)]
public Task<ContentDto> GetAsync(Guid id)
{
return ContentAdminAppService.GetAsync(id);
}
[HttpGet]
[Authorize(CmsKitAdminPermissions.Contents.Default)]
public Task<PagedResultDto<ContentGetListDto>> GetListAsync(ContentGetListInput input)
{
return ContentAdminAppService.GetListAsync(input);
}
[HttpPut]
[Authorize(CmsKitAdminPermissions.Contents.Update)]
public Task<ContentDto> UpdateAsync(Guid id, ContentUpdateDto input)
{
return ContentAdminAppService.UpdateAsync(id, input);
}
[HttpGet]
[Route("{entityType}/{entityId}")]
[Authorize(CmsKitAdminPermissions.Contents.Default)]
public Task<ContentDto> GetAsync(string entityType, string entityId)
{
return ContentAdminAppService.GetAsync(entityType, entityId);
}
}
}

35
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml

@ -1,5 +1,9 @@
@page "{Id}"
@using System.Globalization
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.TuiEditor
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Uppy
@using Volo.CmsKit.Admin.Web.Bundles
@using Volo.CmsKit.Admin.Web.Menus
@using Volo.CmsKit.Admin.Web.Pages
@ -15,19 +19,38 @@
@section scripts {
<abp-script src="/Pages/CmsKit/Pages/update.js" />
<abp-script-bundle>
<abp-script type="typeof(TuiEditorScriptContributor)"/>
<abp-script type="typeof(UppyScriptContributor)"/>
<abp-script type="typeof(SlugifyScriptContributor)"/>
<abp-script src="/Pages/CmsKit/Pages/update.js" />
</abp-script-bundle>
}
@section styles {
<abp-style-bundle>
<abp-style type="typeof(TuiEditorStyleContributor)"/>
</abp-style-bundle>
}
<abp-card>
<abp-card-header title="@L["Update"].Value"></abp-card-header>
<abp-card-body>
<abp-dynamic-form abp-model="ViewModel" asp-page="/CmsKit/Pages/Update" id="form-page-update">
<abp-input asp-for="Id" />
<form asp-page="/CmsKit/Pages/Update" id="form-page-update">
<abp-input asp-for="@Model.Id"/>
<abp-input asp-for="@Model.ViewModel.Title"/>
<abp-input asp-for="ViewModel.Slug" title="@L["PageSlugInformation"]" data-toggle="tooltip"/>
<abp-form-content />
<abp-input asp-for="@Model.ViewModel.Content"/>
<abp-input asp-for="ViewModel.Slug" title="@L["PageSlugInformation"]" data-toggle="tooltip" />
</abp-dynamic-form>
<div class="content-editor"
id="ContentEditor"
data-input-id="@Html.IdFor(x => x.ViewModel.Content)"
data-language="@(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)">
</div>
</form>
</abp-card-body>
<abp-card-footer>
<abp-button button-type="Primary" type="submit" text="@L["Submit"].Value" id="button-page-update" />

9
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml.cs

@ -46,14 +46,17 @@ namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages
[AutoMap(typeof(UpdatePageInputDto), ReverseMap = true)]
public class UpdatePageViewModel
{
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))]
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))]
public string Title { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
[Required]
[DynamicFormIgnore]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Slug { get; set; }
[HiddenInput]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Content { get; set; }
}
}
}

114
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/update.js

@ -4,9 +4,6 @@
var $formUpdate = $('#form-page-update');
var $buttonSubmit = $('#button-page-update');
var $pageContentInput = $('#ViewModel_Value');
var $pageIdInput = $('#Id');
var $contentIdInput = $('#ViewModel_Id');
$formUpdate.on('submit', function (e) {
e.preventDefault();
@ -17,7 +14,9 @@
$formUpdate.ajaxSubmit({
success: function (result) {
submitEntityContent();
abp.notify.success(l('SuccessfullySaved'));
abp.ui.clearBusy();
location.href = "/CmsKit/Pages/";
}
});
}
@ -28,38 +27,83 @@
$formUpdate.submit();
});
function submitEntityContent() {
var contentId = $contentIdInput.val();
var pageId = $pageIdInput.val();
var contentValue = $pageContentInput.val();
if (contentId) {
volo.cmsKit.admin.contents.contentAdmin
.update(contentId,
{
value: contentValue
})
.then(function (result) {
finishSaving(result);
});
}
else {
volo.cmsKit.admin.contents.contentAdmin
.create({
entityType: 'Page',
entityId: pageId,
value: contentValue
})
.then(function (result) {
finishSaving(result);
});
}
// -----------------------------------
function getUppyHeaders() {
var headers = {};
headers[abp.security.antiForgery.tokenHeaderName] = abp.security.antiForgery.getToken();
return headers;
}
function finishSaving(result) {
abp.notify.success(l('SuccessfullySaved'));
abp.ui.clearBusy();
location.href = "/CmsKit/Pages/";
var fileUploadUri = "/api/cms-kit-admin/media/page";
var fileUriPrefix = "/api/cms-kit/media/";
var editorDataKey = "tuiEditor";
initAllEditors();
function initAllEditors() {
$('.content-editor').each(function (i, item) {
initEditor(item);
});
}
function initEditor(element) {
var $editorContainer = $(element);
var inputName = $editorContainer.data('input-id');
var $editorInput = $('#' + inputName);
var initialValue = $editorInput.val();
var editor = $editorContainer.tuiEditor({
usageStatistics: false,
useCommandShortcut: true,
initialValue: initialValue,
previewStyle: 'tab',
height: "25em",
minHeight: "25em",
initialEditType: initialValue ? 'wysiwyg' : 'markdown',
language: $editorContainer.data("language"),
hooks: {
addImageBlobHook: uploadFile,
},
events: {
change: function (_val) {
$editorInput.val(editor.getHtml());
$editorInput.trigger("change");
}
}
}).data(editorDataKey);
}
function uploadFile(blob, callback, source) {
var UPPY_OPTIONS = {
endpoint: fileUploadUri,
formData: true,
fieldName: "file",
method: "post",
headers: getUppyHeaders()
};
var UPPY = Uppy.Core().use(Uppy.XHRUpload, UPPY_OPTIONS);
UPPY.reset();
UPPY.addFile({
id: "content-file",
name: blob.name,
type: blob.type,
data: blob,
});
UPPY.upload().then((result) => {
if (result.failed.length > 0) {
abp.message.error("File upload failed");
} else {
var mediaDto = result.successful[0].response.body;
var fileUrl = (fileUriPrefix + mediaDto.id);
callback(fileUrl, mediaDto.name);
}
});
}
});

11
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/ContentDto.cs

@ -1,11 +0,0 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Public.Contents
{
[Serializable]
public class ContentDto : EntityDto<Guid>
{
public string Value { get; set; }
}
}

12
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/GetContentInput.cs

@ -1,12 +0,0 @@
using System;
namespace Volo.CmsKit.Public.Contents
{
[Serializable]
public class GetContentInput
{
public string EntityType { get; set; }
public string EntityId { get; set; }
}
}

10
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs

@ -1,10 +0,0 @@
using System.Threading.Tasks;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Public.Contents
{
public interface IContentPublicAppService
{
Task<ContentDto> GetAsync(GetContentInput input);
}
}

29
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs

@ -1,29 +0,0 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Contents;
using Volo.CmsKit.GlobalFeatures;
namespace Volo.CmsKit.Public.Contents
{
[RequiresGlobalFeature(typeof(ContentsFeature))]
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit-public/contents")]
public class ContentController : CmsKitControllerBase, IContentPublicAppService
{
protected IContentPublicAppService ContentAppService { get; }
public ContentController(IContentPublicAppService contentAppService)
{
ContentAppService = contentAppService;
}
[HttpGet]
public virtual Task<ContentDto> GetAsync(GetContentInput input)
{
return ContentAppService.GetAsync(input);
}
}
}

2
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPost/Default.cshtml

@ -1,6 +1,4 @@
@model Volo.CmsKit.Public.Blogs.BlogPostPublicDto
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using Volo.CmsKit.Localization
@using Microsoft.Extensions.Localization

59
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs

@ -1,59 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Domain.Entities;
using Volo.CmsKit.Public.Contents;
using Volo.CmsKit.Web.Contents;
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
{
[ViewComponent(Name = "CmsContent")]
public class ContentViewComponent : AbpViewComponent
{
private readonly IContentRenderer contentRenderer;
private readonly IContentPublicAppService contentAppService;
public ContentViewComponent(
IContentRenderer contentRenderer,
IContentPublicAppService contentAppService)
{
this.contentRenderer = contentRenderer;
this.contentAppService = contentAppService;
}
public virtual async Task<IViewComponentResult> InvokeAsync(
string entityType,
string entityId)
{
var content = string.Empty;
try
{
var contentDto = await contentAppService.GetAsync(new GetContentInput
{
EntityId = entityId,
EntityType = entityType
});
content = contentDto.Value;
}
catch (EntityNotFoundException e)
{
// ContentDto can be null, we will render empty content.
}
var viewModel = new ContentViewModel
{
Value = await contentRenderer.RenderAsync(content)
};
return View("~/Pages/CmsKit/Shared/Components/Contents/Default.cshtml", viewModel);
}
public class ContentViewModel
{
public string Value { get; set; }
}
}
}

3
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/Default.cshtml

@ -1,3 +0,0 @@
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents.ContentViewComponent.ContentViewModel
@Html.Raw(Model.Value)
Loading…
Cancel
Save