Skip to content

Commit 4ac91e5

Browse files
committed
Site Config: Add TinyMCE API Key
1 parent c45aa6d commit 4ac91e5

File tree

8 files changed

+24
-4
lines changed

8 files changed

+24
-4
lines changed

source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public interface ISiteConfig
100100
bool SendPostsByEmail { get; set; }
101101
bool EnableAboutView { get; set; }
102102

103+
string TinyMCEApiKey { get; set; }
104+
103105
bool EnableBloggerApi { get; set; }
104106

105107
bool EnableComments { get; set; }

source/DasBlog.Services/ConfigFile/SiteConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public SiteConfig() { }
8080
public bool SendPingbacksByEmail { get; set; }
8181
public bool SendPostsByEmail { get; set; }
8282
public bool EnableAboutView { get; set; }
83+
public string TinyMCEApiKey { get; set; }
8384
public bool EnableBloggerApi { get; set; }
8485
public bool EnableComments { get; set; }
8586
public bool EnableCommentApi { get; set; }

source/DasBlog.Tests/UnitTests/SiteConfigTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class SiteConfigTest : ISiteConfig
4040
public bool SendPostsByEmail { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
4141
public bool EnableAboutView { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
4242
public bool EnableBloggerApi { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
43+
public string TinyMCEApiKey { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
4344
public bool EnableComments { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
4445
public bool EnableCommentApi { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
4546
public bool EnableConfigEditService { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

source/DasBlog.Web.UI/Config/site.Development.config

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

source/DasBlog.Web.UI/Config/site.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
<EntryEditControl>TinyMce</EntryEditControl>
9797
<!-- TinyMce, NicEdit, TextArea or Froala -->
98-
98+
<TinyMCEApiKey>no-api-key</TinyMCEApiKey>
9999
<EnableBloggerApi>true</EnableBloggerApi>
100100

101101

source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ public class SiteViewModel
204204
[Description("")]
205205
[StringLength(300, MinimumLength = 1, ErrorMessage = "{0} should be between 1 to 300 characters")]
206206
public string EntryEditControl { get; set; }
207+
208+
[DisplayName("TinyMCE API Key")]
209+
[Description("")]
210+
[StringLength(300, MinimumLength = 1, ErrorMessage = "{0} should be between 1 to 300 characters")]
211+
[Required(AllowEmptyStrings = false, ErrorMessage = "Enter a value for TinyMCE API Key or enter 'no-api-key'")]
212+
public string TinyMCEApiKey { get; set; }
207213

208214
[DisplayName("Content directory")]
209215
[Description("")]

source/DasBlog.Web.UI/TagHelpers/RichEdit/TinyMceBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace DasBlog.Web.TagHelpers.RichEdit
66
public class TinyMceBuilder : IRichEditBuilder
77
{
88
private readonly IDasBlogSettings dasBlogSettings;
9-
private const string TINY_MCE_SERVICE_URL = "https://cloud.tinymce.com/stable/tinymce.min.js";
9+
private const string TINY_MCE_SERVICE_URL = "https://cdn.tiny.cloud/1/{0}/tinymce/5/tinymce.min.js";
1010
private const string INIT_SCRIPT_TEMPLATE = @"
1111
<script language=""javascript"" type=""text/javascript"" src=""{0}/js/tinymce/plugins/code/plugin.min.js""></script>
1212
<script>
@@ -37,7 +37,7 @@ public void ProcessScripts(RichEditScriptsTagHelper tagHeelper, TagHelperContext
3737
{
3838
output.TagName = "script";
3939
output.TagMode = TagMode.StartTagAndEndTag;
40-
output.Attributes.SetAttribute("src", TINY_MCE_SERVICE_URL);
40+
output.Attributes.SetAttribute("src", string.Format(TINY_MCE_SERVICE_URL, dasBlogSettings.SiteConfiguration.TinyMCEApiKey));
4141
output.Attributes.SetAttribute("type", "text/javascript");
4242
output.Attributes.SetAttribute("language", "javascript");
4343
string htmlContent = string.Format(INIT_SCRIPT_TEMPLATE, dasBlogSettings.SiteConfiguration.Root, tagHeelper.ControlId);

source/DasBlog.Web.UI/Views/Admin/Settings.cshtml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@
468468

469469
</div>
470470

471+
<div class="form-group row mb-3">
472+
@Html.LabelFor(m => @Model.SiteConfig.TinyMCEApiKey, null, new { @class = "col-form-label col-sm-2" })
473+
474+
<div class="col-sm-5">
475+
@Html.TextBoxFor(m => @Model.SiteConfig.TinyMCEApiKey, null, new { @class = "form-control sm-10" })
476+
</div>
477+
478+
@Html.ValidationMessageFor(m => m.SiteConfig.TinyMCEApiKey, null, new { @class = "text-danger" })
479+
</div>
480+
471481
<h3>Email Settings & Notifications</h3>
472482

473483
<div class="form-group row mb-3">

0 commit comments

Comments
 (0)