Skip to content

Commit

Permalink
Merge pull request #630 from brandonrdnt/issue-629-tinymceapikey
Browse files Browse the repository at this point in the history
Site Config: Add TinyMCE API Key
  • Loading branch information
poppastring authored May 4, 2022
2 parents 69c7e45 + 516b5f9 commit 3f344c0
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 9 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pool:

variables:
buildConfiguration: 'Release'
version: 3.1
version: 3.2

steps:
- task: UseDotNet@2
Expand Down
2 changes: 2 additions & 0 deletions source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public interface ISiteConfig
bool SendPostsByEmail { get; set; }
bool EnableAboutView { get; set; }

string TinyMCEApiKey { get; set; }

bool EnableBloggerApi { get; set; }

bool EnableComments { get; set; }
Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.Services/ConfigFile/SiteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public SiteConfig() { }
public bool SendPingbacksByEmail { get; set; }
public bool SendPostsByEmail { get; set; }
public bool EnableAboutView { get; set; }
public string TinyMCEApiKey { get; set; }
public bool EnableBloggerApi { get; set; }
public bool EnableComments { get; set; }
public bool EnableCommentApi { get; set; }
Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.Tests/UnitTests/SiteConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SiteConfigTest : ISiteConfig
public bool SendPostsByEmail { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool EnableAboutView { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool EnableBloggerApi { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string TinyMCEApiKey { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool EnableComments { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool EnableCommentApi { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool EnableConfigEditService { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
Expand Down
209 changes: 208 additions & 1 deletion source/DasBlog.Web.UI/Config/site.Development.config

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/DasBlog.Web.UI/Config/site.config
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

<EntryEditControl>TinyMce</EntryEditControl>
<!-- TinyMce, NicEdit, TextArea or Froala -->

<TinyMCEApiKey>no-api-key</TinyMCEApiKey>
<EnableBloggerApi>true</EnableBloggerApi>


Expand Down
6 changes: 6 additions & 0 deletions source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ public class SiteViewModel
[Description("")]
[StringLength(300, MinimumLength = 1, ErrorMessage = "{0} should be between 1 to 300 characters")]
public string EntryEditControl { get; set; }

[DisplayName("TinyMCE API Key")]
[Description("")]
[StringLength(300, MinimumLength = 1, ErrorMessage = "{0} should be between 1 to 300 characters")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Enter a value for TinyMCE API Key or enter 'no-api-key'")]
public string TinyMCEApiKey { get; set; }

[DisplayName("Content directory")]
[Description("")]
Expand Down
9 changes: 4 additions & 5 deletions source/DasBlog.Web.UI/TagHelpers/RichEdit/TinyMceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ namespace DasBlog.Web.TagHelpers.RichEdit
public class TinyMceBuilder : IRichEditBuilder
{
private readonly IDasBlogSettings dasBlogSettings;
private const string TINY_MCE_SERVICE_URL = "https://cloud.tinymce.com/stable/tinymce.min.js";
private const string TINY_MCE_SERVICE_URL = "https://cdn.tiny.cloud/1/{0}/tinymce/5/tinymce.min.js";
private const string INIT_SCRIPT_TEMPLATE = @"
<script language=""javascript"" type=""text/javascript"" src=""{0}/js/tinymce/plugins/code/plugin.min.js""></script>
<script>
tinymce.init({{
selector: '#{1}'
selector: '#{0}'
,plugins: 'code'
}});
</script>
Expand All @@ -37,10 +36,10 @@ public void ProcessScripts(RichEditScriptsTagHelper tagHeelper, TagHelperContext
{
output.TagName = "script";
output.TagMode = TagMode.StartTagAndEndTag;
output.Attributes.SetAttribute("src", TINY_MCE_SERVICE_URL);
output.Attributes.SetAttribute("src", string.Format(TINY_MCE_SERVICE_URL, dasBlogSettings.SiteConfiguration.TinyMCEApiKey));
output.Attributes.SetAttribute("type", "text/javascript");
output.Attributes.SetAttribute("language", "javascript");
string htmlContent = string.Format(INIT_SCRIPT_TEMPLATE, dasBlogSettings.SiteConfiguration.Root, tagHeelper.ControlId);
string htmlContent = string.Format(INIT_SCRIPT_TEMPLATE, tagHeelper.ControlId);
output.PostElement.SetHtmlContent(htmlContent);
}
}
Expand Down
10 changes: 10 additions & 0 deletions source/DasBlog.Web.UI/Views/Admin/Settings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,16 @@

</div>

<div class="form-group row mb-3">
@Html.LabelFor(m => @Model.SiteConfig.TinyMCEApiKey, null, new { @class = "col-form-label col-sm-2" })

<div class="col-sm-5">
@Html.TextBoxFor(m => @Model.SiteConfig.TinyMCEApiKey, null, new { @class = "form-control sm-10" })
</div>

@Html.ValidationMessageFor(m => m.SiteConfig.TinyMCEApiKey, null, new { @class = "text-danger" })
</div>

<h3>Email Settings & Notifications</h3>

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

This file was deleted.

0 comments on commit 3f344c0

Please sign in to comment.