Skip to content

Commit 3f344c0

Browse files
authored
Merge pull request #630 from brandonrdnt/issue-629-tinymceapikey
Site Config: Add TinyMCE API Key
2 parents 69c7e45 + 516b5f9 commit 3f344c0

File tree

10 files changed

+234
-9
lines changed

10 files changed

+234
-9
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pool:
1010

1111
variables:
1212
buildConfiguration: 'Release'
13-
version: 3.1
13+
version: 3.2
1414

1515
steps:
1616
- task: UseDotNet@2

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: 208 additions & 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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ 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 = @"
11-
<script language=""javascript"" type=""text/javascript"" src=""{0}/js/tinymce/plugins/code/plugin.min.js""></script>
1211
<script>
1312
tinymce.init({{
14-
selector: '#{1}'
13+
selector: '#{0}'
1514
,plugins: 'code'
1615
}});
1716
</script>
@@ -37,10 +36,10 @@ public void ProcessScripts(RichEditScriptsTagHelper tagHeelper, TagHelperContext
3736
{
3837
output.TagName = "script";
3938
output.TagMode = TagMode.StartTagAndEndTag;
40-
output.Attributes.SetAttribute("src", TINY_MCE_SERVICE_URL);
39+
output.Attributes.SetAttribute("src", string.Format(TINY_MCE_SERVICE_URL, dasBlogSettings.SiteConfiguration.TinyMCEApiKey));
4140
output.Attributes.SetAttribute("type", "text/javascript");
4241
output.Attributes.SetAttribute("language", "javascript");
43-
string htmlContent = string.Format(INIT_SCRIPT_TEMPLATE, dasBlogSettings.SiteConfiguration.Root, tagHeelper.ControlId);
42+
string htmlContent = string.Format(INIT_SCRIPT_TEMPLATE, tagHeelper.ControlId);
4443
output.PostElement.SetHtmlContent(htmlContent);
4544
}
4645
}

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">

source/DasBlog.Web.UI/wwwroot/js/tinymce/plugins/code/plugin.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)