mirror of https://github.com/abpframework/abp.git
7 changed files with 52 additions and 111 deletions
@ -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 |
|
||||
|
|
||||
<abp-card> |
|
||||
<abp-card-body> |
|
||||
@foreach (ContentFragment contentFragment in Model.ContentFragments) |
|
||||
{ |
|
||||
if (contentFragment.Type == "Markdown") //TODO: Constant |
|
||||
{ |
|
||||
@Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty<string>("Content"))) |
|
||||
} |
|
||||
else if (contentFragment.Type == "Widget") //TODO: Constant |
|
||||
{ |
|
||||
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) |
|
||||
} |
|
||||
} |
|
||||
</abp-card-body> |
|
||||
</abp-card> |
|
||||
|
|
||||
|
|
||||
@{ |
|
||||
dynamic ConvertToDynamicObject(Dictionary<string, object> dict) |
|
||||
{ |
|
||||
var eo = new ExpandoObject(); |
|
||||
var eoColl = (ICollection<KeyValuePair<string, object>>)eo; |
|
||||
|
|
||||
foreach (var kvp in dict) |
|
||||
{ |
|
||||
eoColl.Add(kvp); |
|
||||
} |
|
||||
|
|
||||
dynamic eoDynamic = eo; |
|
||||
|
|
||||
return eoDynamic; |
|
||||
} |
|
||||
} |
|
||||
@ -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<IViewComponentResult> InvokeAsync( |
|
||||
Guid pageId, |
|
||||
string title, |
|
||||
string content, |
|
||||
List<ContentFragment> contentFragments) |
|
||||
{ |
|
||||
var model = new PageViewModel |
|
||||
{ |
|
||||
Id = pageId, |
|
||||
Title = title, |
|
||||
ContentFragments = contentFragments |
|
||||
}; |
|
||||
|
|
||||
return View("~/Pages/CmsKit/Shared/Components/Pages/Default.cshtml", model); |
|
||||
} |
|
||||
} |
|
||||
@ -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.Contents |
||||
@using Volo.CmsKit.Localization |
@using System.Dynamic |
||||
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages |
@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 |
@model Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Pages.IndexModel |
||||
|
|
||||
@inject IHtmlLocalizer<CmsKitResource> L |
|
||||
|
|
||||
@section styles{ |
@section styles{ |
||||
|
|
||||
<abp-style src="/Pages/Public/CmsKit/Pages/index.css" /> |
<abp-style src="/Pages/Public/CmsKit/Pages/index.css" /> |
||||
|
|
||||
<style> |
<style> |
||||
@Html.Raw(Model.Page.Style) |
@Html.Raw(Model.PageDto.Style) |
||||
</style> |
</style> |
||||
} |
} |
||||
|
|
||||
@section scripts{ |
@section scripts{ |
||||
<script> |
<script> |
||||
@Html.Raw(Model.Page.Script) |
@Html.Raw(Model.PageDto.Script) |
||||
</script> |
</script> |
||||
} |
} |
||||
|
|
||||
@await Component.InvokeAsync(typeof(DefaultPageViewComponent), |
<abp-card> |
||||
new |
<abp-card-body> |
||||
|
@foreach (ContentFragment contentFragment in Model.PageDto.ContentFragments) |
||||
|
{ |
||||
|
if (contentFragment.Type == "Markdown") //TODO: Constant |
||||
|
{ |
||||
|
@Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty<string>("Content"))) |
||||
|
} |
||||
|
else if (contentFragment.Type == "Widget") //TODO: Constant |
||||
|
{ |
||||
|
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), ConvertToDynamicObject(contentFragment.ExtraProperties)) |
||||
|
} |
||||
|
} |
||||
|
</abp-card-body> |
||||
|
</abp-card> |
||||
|
|
||||
|
@{ |
||||
|
dynamic ConvertToDynamicObject(Dictionary<string, object> dict) |
||||
{ |
{ |
||||
pageId = Model.Page.Id, |
var eo = new ExpandoObject(); |
||||
title = Model.Page.Title, |
var eoColl = (ICollection<KeyValuePair<string, object>>)eo; |
||||
content = Model.Page.Content, |
|
||||
contentFragments = Model.Page.ContentFragments |
foreach (var kvp in dict) |
||||
}) |
{ |
||||
|
eoColl.Add(kvp); |
||||
|
} |
||||
|
|
||||
|
dynamic eoDynamic = eo; |
||||
|
|
||||
|
return eoDynamic; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue