Merge pull request #8059 from abpframework/cms-kit/page-style-script

Cms Kit - Script & Style support for Page
pull/7719/head^2
İlkay İlknur 5 years ago committed by GitHub
commit 02e0822cd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Page_StyleScript : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Script",
table: "CmsPages",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Style",
table: "CmsPages",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Script",
table: "CmsPages");
migrationBuilder.DropColumn(
name: "Style",
table: "CmsPages");
}
}
}

@ -18,7 +18,7 @@ namespace Volo.CmsKit.Migrations
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.3")
.HasAnnotation("ProductVersion", "5.0.4")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>
@ -1506,11 +1506,17 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Script")
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("Style")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");

@ -18,5 +18,11 @@ namespace Volo.CmsKit.Admin.Pages
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxContentLength))]
public string Content { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))]
public string Script { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))]
public string Style { get; set; }
}
}

@ -11,5 +11,9 @@ namespace Volo.CmsKit.Admin.Pages
public string Slug { get; set; }
public string Content { get; set; }
public string Script { get; set; }
public string Style { get; set; }
}
}

@ -18,5 +18,11 @@ namespace Volo.CmsKit.Admin.Pages
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxContentLength))]
public string Content { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))]
public string Script { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))]
public string Style { get; set; }
}
}

@ -53,7 +53,7 @@ namespace Volo.CmsKit.Admin.Pages
[Authorize(CmsKitAdminPermissions.Pages.Create)]
public virtual async Task<PageDto> CreateAsync(CreatePageInputDto input)
{
var page = await PageManager.CreateAsync(input.Title, input.Slug, input.Content);
var page = await PageManager.CreateAsync(input.Title, input.Slug, input.Content, input.Script, input.Style);
await PageRepository.InsertAsync(page);
@ -69,6 +69,8 @@ namespace Volo.CmsKit.Admin.Pages
page.SetTitle(input.Title);
page.SetContent(input.Content);
page.SetScript(input.Script);
page.SetStyle(input.Style);
await PageRepository.UpdateAsync(page);

@ -18,18 +18,18 @@
}
@section scripts {
<abp-script-bundle>
<abp-script type="typeof(TuiEditorScriptContributor)"/>
<abp-script type="typeof(UppyScriptContributor)"/>
<abp-script type="typeof(SlugifyScriptContributor)"/>
<abp-script src="/Pages/CmsKit/Pages/create.js" />
</abp-script-bundle>
<abp-script-bundle>
<abp-script type="typeof(TuiEditorScriptContributor)" />
<abp-script type="typeof(UppyScriptContributor)" />
<abp-script type="typeof(SlugifyScriptContributor)" />
<abp-script src="/Pages/CmsKit/Pages/create.js" />
</abp-script-bundle>
}
@section styles {
<abp-style-bundle>
<abp-style type="typeof(TuiEditorStyleContributor)"/>
</abp-style-bundle>
<abp-style-bundle>
<abp-style type="typeof(TuiEditorStyleContributor)" />
</abp-style-bundle>
}
<abp-card>
@ -37,16 +37,30 @@
<abp-card-body>
<form asp-page="/CmsKit/Pages/Create" id="form-page-create">
<abp-input asp-for="@Model.ViewModel.Title" />
<abp-input asp-for="ViewModel.Slug" title="@L["PageSlugInformation"]" data-toggle="tooltip"/>
<abp-input asp-for="ViewModel.Slug" title="@L["PageSlugInformation"]" data-toggle="tooltip" />
<abp-input asp-for="@Model.ViewModel.Content" />
<div class="content-editor"
id="ContentEditor"
data-input-id="@Html.IdFor(x => x.ViewModel.Content)"
data-language="@(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)">
</div>
<abp-tabs tab-style="Tab">
<abp-tab title="@L["Content"]">
<div class="content-editor"
id="ContentEditor"
data-input-id="@Html.IdFor(x => x.ViewModel.Content)"
data-language="@(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)">
</div>
</abp-tab>
<abp-tab title="@L["Script"]">
<abp-input asp-for="ViewModel.Script" suppress-label="true" />
</abp-tab>
<abp-tab title="@L["Style"]">
<abp-input asp-for="ViewModel.Style" suppress-label="true"/>
</abp-tab>
</abp-tabs>
</form>
</abp-card-body>
<abp-card-footer>

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;
using Volo.Abp.Validation;
using Volo.CmsKit.Admin.Pages;
using Volo.CmsKit.Pages;
@ -39,10 +40,18 @@ namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Slug { get; set; }
[HiddenInput]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Content { get; set; }
[TextArea(Rows = 6)]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Script { get; set; }
[TextArea(Rows = 6)]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Style { get; set; }
}
}
}

@ -19,37 +19,53 @@
@section scripts {
<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>
<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-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>
<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="@Model.Id" />
<abp-input asp-for="ViewModel.Slug" title="@L["PageSlugInformation"]" data-toggle="tooltip"/>
<abp-input asp-for="@Model.ViewModel.Title" />
<abp-input asp-for="@Model.ViewModel.Content"/>
<abp-input asp-for="ViewModel.Slug" title="@L["PageSlugInformation"]" data-toggle="tooltip" />
<abp-input asp-for="@Model.ViewModel.Content" />
<abp-tabs tab-style="Tab">
<abp-tab title="@L["Content"]">
<div class="content-editor"
id="ContentEditor"
data-input-id="@Html.IdFor(x => x.ViewModel.Content)"
data-language="@(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)">
</div>
</abp-tab>
<abp-tab title="@L["Script"]">
<abp-input asp-for="ViewModel.Script" suppress-label="true" />
</abp-tab>
<abp-tab title="@L["Style"]">
<abp-input asp-for="ViewModel.Style" suppress-label="true"/>
</abp-tab>
</abp-tabs>
<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>

@ -57,6 +57,14 @@ namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Pages
[HiddenInput]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxSlugLength))]
public string Content { get; set; }
[TextArea(Rows = 6)]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxScriptLength))]
public string Script { get; set; }
[TextArea(Rows = 6)]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxStyleLength))]
public string Style { get; set; }
}
}
}

@ -27,6 +27,7 @@
"CommentAuthorizationExceptionMessage": "Those comments are not allowed for public display.",
"CommentDeletionConfirmationMessage": "This comment and all replies will be deleted!",
"Comments": "Comments",
"Content": "Content",
"ContentDeletionConfirmationMessage": "Are you sure to delete this content?",
"Contents": "Contents",
"CoverImage": "Cover Image",
@ -93,6 +94,7 @@
"ReplyTo": "Reply to",
"SamplePageMessage": "A sample page for the Pro module",
"SaveChanges": "Save Changes",
"Script": "Script",
"SelectAll": "Select All",
"Send": "Send",
"SendMessage": "Send Message",
@ -102,6 +104,7 @@
"SourceUrl": "Source Url",
"Star": "Star",
"StartDate": "Start Date",
"Style": "Style",
"Subject": "Subject",
"SubjectPlaceholder": "Please type a subject",
"Submit": "Submit",

@ -9,6 +9,9 @@
"Blogs": "Bloglar",
"ChoosePreference": "Tercih seçiniz...",
"Cms": "Cms",
"Content": "İçerik",
"Script": "Script Kodları",
"Style": "Stil Kodları",
"CmsKit.Comments": "Yorumlar",
"CmsKit.Ratings": "Puanlama",
"CmsKit.Reactions": "Tepkiler",

@ -9,5 +9,9 @@
public static int MaxSlugLength { get; set; } = 256;
public static int MaxContentLength { get; set; } = int.MaxValue;
public static int MaxScriptLength { get; set; } = int.MaxValue;
public static int MaxStyleLength { get; set; } = int.MaxValue;
}
}

@ -15,18 +15,31 @@ namespace Volo.CmsKit.Pages
public virtual string Slug { get; protected set; }
public virtual string Content { get; protected set; }
public virtual string Script { get; protected set; }
public virtual string Style { get; protected set; }
protected Page()
{
}
internal Page(Guid id, [NotNull] string title, [NotNull] string slug, string content = null, Guid? tenantId = null) : base(id)
internal Page(
Guid id,
[NotNull] string title,
[NotNull] string slug,
string content = null,
string script = null,
string style = null,
Guid? tenantId = null) : base(id)
{
TenantId = tenantId;
SetTitle(title);
SetSlug(slug);
SetContent(content);
SetScript(script);
SetStyle(style);
}
public virtual void SetTitle(string title)
@ -43,5 +56,15 @@ namespace Volo.CmsKit.Pages
{
Content = Check.Length(content, nameof(content), PageConsts.MaxContentLength);
}
public virtual void SetScript(string script)
{
Script = Check.Length(script, nameof(script), PageConsts.MaxScriptLength);
}
public virtual void SetStyle(string style)
{
Style = Check.Length(style, nameof(style), PageConsts.MaxStyleLength);
}
}
}

@ -21,7 +21,9 @@ namespace Volo.CmsKit.Pages
public virtual async Task<Page> CreateAsync(
[NotNull] string title,
[NotNull] string slug,
[CanBeNull] string content = null)
[CanBeNull] string content = null,
[CanBeNull] string script = null,
[CanBeNull] string style = null)
{
Check.NotNullOrEmpty(title, nameof(title));
Check.NotNullOrEmpty(slug, nameof(slug));
@ -32,7 +34,9 @@ namespace Volo.CmsKit.Pages
GuidGenerator.Create(),
title,
slug,
content,
content,
script,
style,
CurrentTenant.Id);
}

@ -11,5 +11,9 @@ namespace Volo.CmsKit.Public.Pages
public string Slug { get; set; }
public string Content { get; set; }
public string Script { get; set; }
public string Style { get; set; }
}
}

@ -7,7 +7,17 @@
@section styles{
<abp-style src="/Pages/Public/CmsKit/Pages/index.css" />
<style>
@Html.Raw(Model.Page.Style)
</style>
}
@section scripts{
<script>
@Html.Raw(Model.Page.Script)
</script>
}
@await Component.InvokeAsync(typeof(DefaultPageViewComponent),
new
{

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace MyCompanyName.MyProjectName.Migrations
{
public partial class CmsKit_Pages_ScriptStyle : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Script",
table: "CmsPages",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Style",
table: "CmsPages",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Script",
table: "CmsPages");
migrationBuilder.DropColumn(
name: "Style",
table: "CmsPages");
}
}
}

@ -18,7 +18,7 @@ namespace MyCompanyName.MyProjectName.Migrations
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.3")
.HasAnnotation("ProductVersion", "5.0.4")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>
@ -2319,11 +2319,17 @@ namespace MyCompanyName.MyProjectName.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Script")
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("Style")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");

Loading…
Cancel
Save