From ba6d7cf24456c4615f0bfb6e2e2e6297d6674e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20M=C3=A5rtensson?= Date: Fri, 6 Jan 2023 20:35:39 +0100 Subject: [PATCH 1/4] Adding CDN support for binary content. Configurable from site.config. --- .../ConfigFile/Interfaces/ISiteConfig.cs | 6 ++- .../DasBlog.Services/ConfigFile/SiteConfig.cs | 23 +++++++++- .../DasBlog.Tests/UnitTests/SiteConfigTest.cs | 4 +- .../FileSystemBinaryManager.cs | 5 ++- source/DasBlog.Web.UI/Config/site.config | 4 ++ .../CdnManager.cs | 42 +++++++++++++++++++ .../FileSystemBinaryDataService.cs | 29 +++++++------ .../ICdnManager.cs | 16 +++++++ 8 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 source/newtelligence.DasBlog.Runtime/CdnManager.cs create mode 100644 source/newtelligence.DasBlog.Runtime/ICdnManager.cs diff --git a/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs b/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs index 713ce45e1..e70e74e14 100644 --- a/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs @@ -61,9 +61,11 @@ public interface ISiteConfig string Root { get; set; } - string Copyright { get; set; } + string CdnRoot { get; set; } - int RssDayCount { get; set; } + string Copyright { get; set; } + + int RssDayCount { get; set; } int RssMainEntryCount { get; set; } diff --git a/source/DasBlog.Services/ConfigFile/SiteConfig.cs b/source/DasBlog.Services/ConfigFile/SiteConfig.cs index 413247e4e..557c56b83 100644 --- a/source/DasBlog.Services/ConfigFile/SiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/SiteConfig.cs @@ -52,8 +52,9 @@ namespace DasBlog.Services.ConfigFile public class SiteConfig : ISiteConfig { private string _root; + private string _cdnRoot; - public SiteConfig() { } + public SiteConfig() { } public string Title { get; set; } public string Subtitle { get; set; } @@ -77,6 +78,26 @@ public string Root { } } } + + public string CdnRoot + { + get + { + return _cdnRoot; + } + set + { + if (!string.IsNullOrEmpty(value)) + { + _cdnRoot = value + (value.EndsWith("/") ? "" : "/"); + } + else + { + _cdnRoot = value; + } + } + } + public string AllowedHosts { get; set; } public string Copyright { get; set; } public int RssDayCount { get; set; } diff --git a/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs b/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs index 5ac656ada..236c67280 100644 --- a/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs +++ b/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs @@ -3,8 +3,6 @@ using DasBlog.Services.ConfigFile.Interfaces; using newtelligence.DasBlog.Runtime; using System; -using System.Collections.Generic; -using System.Text; using System.Xml; namespace DasBlog.Tests.UnitTests @@ -17,10 +15,10 @@ public class SiteConfigTest : ISiteConfig public string Description { get => "Description"; set => throw new NotImplementedException(); } public string Contact { get => "Contact"; set => throw new NotImplementedException(); } public string Root { get => "http://www.poppastring.com/"; set => throw new NotImplementedException(); } + public string CdnRoot { get => ""; set => throw new NotImplementedException(); } public string Copyright { get => "CopyRight"; set => throw new NotImplementedException(); } public int RssDayCount { get => 100; set => throw new NotImplementedException(); } public bool ShowCommentCount { get => true; set => throw new NotImplementedException(); } - public int RssMainEntryCount { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public int RssEntryCount { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public bool EnableRssItemFooters { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } diff --git a/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs b/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs index 1fccc9cf7..bad0b2239 100644 --- a/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs +++ b/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs @@ -1,7 +1,6 @@ using DasBlog.Managers.Interfaces; using DasBlog.Services; using DasBlog.Services.ConfigFile; -using DasBlog.Services.ConfigFile.Interfaces; using DasBlog.Services.FileManagement; using DasBlog.Services.FileManagement.Interfaces; using Microsoft.Extensions.Options; @@ -33,7 +32,9 @@ public FileSystemBinaryManager(IDasBlogSettings dasBlogSettings, IConfigFileServ var loggingDataService = LoggingDataServiceFactory.GetService(Path.Combine(dasBlogSettings.WebRootDirectory, dasBlogSettings.SiteConfiguration.LogDir)); - this.binaryDataService = BinaryDataServiceFactory.GetService(options.BinaryFolder, physBinaryPathUrl, loggingDataService); + var cdnManager = CdnManagerFactory.GetService(dasBlogSettings.SiteConfiguration.Root, dasBlogSettings.SiteConfiguration.CdnRoot); + + binaryDataService = BinaryDataServiceFactory.GetService(options.BinaryFolder, physBinaryPathUrl, loggingDataService, cdnManager); } public string SaveFile(Stream inputFile, string fileName) diff --git a/source/DasBlog.Web.UI/Config/site.config b/source/DasBlog.Web.UI/Config/site.config index 586e84fbf..f649ca010 100644 --- a/source/DasBlog.Web.UI/Config/site.config +++ b/source/DasBlog.Web.UI/Config/site.config @@ -29,6 +29,10 @@ + + + + diff --git a/source/newtelligence.DasBlog.Runtime/CdnManager.cs b/source/newtelligence.DasBlog.Runtime/CdnManager.cs new file mode 100644 index 000000000..e9994797c --- /dev/null +++ b/source/newtelligence.DasBlog.Runtime/CdnManager.cs @@ -0,0 +1,42 @@ +using System; + +namespace newtelligence.DasBlog.Runtime +{ + public static class CdnManagerFactory + { + public static ICdnManager GetService(string rootUri, string cdnUri) + { + return new CdnManager(rootUri, cdnUri); + } + } + + internal sealed class CdnManager : ICdnManager + { + private readonly string rootUri; + private readonly string cdnUri; + + /// + /// Setting up the cdn manager to return cdn uris when that is configured. + /// + /// The root of the + /// + public CdnManager(string rootUri, string cdnUri) + { + this.rootUri = + string.IsNullOrWhiteSpace(rootUri) || !Uri.TryCreate(rootUri, UriKind.Absolute, out _) ? + null : + rootUri; + this.cdnUri = + string.IsNullOrWhiteSpace(cdnUri) || !Uri.TryCreate(cdnUri, UriKind.Absolute, out _) ? + null : + cdnUri; + if (this.rootUri == null) this.cdnUri = null; + } + + public string ApplyCdnUri(string uri) + { + // If the cdnUri is null then we can just return the uri. + return cdnUri == null ? uri : uri.Replace(rootUri, cdnUri); + } + } +} diff --git a/source/newtelligence.DasBlog.Runtime/FileSystemBinaryDataService.cs b/source/newtelligence.DasBlog.Runtime/FileSystemBinaryDataService.cs index 2f54ac70e..78f47402b 100644 --- a/source/newtelligence.DasBlog.Runtime/FileSystemBinaryDataService.cs +++ b/source/newtelligence.DasBlog.Runtime/FileSystemBinaryDataService.cs @@ -19,7 +19,7 @@ public static class BinaryDataServiceFactory /// /// /// - public static IBinaryDataService GetService(string contentLocation, Uri rootUrl, ILoggingDataService loggingService) + public static IBinaryDataService GetService(string contentLocation, Uri rootUrl, ILoggingDataService loggingService, ICdnManager cdnManager) { IBinaryDataService service; @@ -27,7 +27,7 @@ public static IBinaryDataService GetService(string contentLocation, Uri rootUrl, { if (!services.TryGetValue(contentLocation, out service)) { - service = new FileSystemBinaryDataService(contentLocation, rootUrl, loggingService); + service = new FileSystemBinaryDataService(contentLocation, rootUrl, loggingService, cdnManager); services.Add(contentLocation, service); } } @@ -50,14 +50,14 @@ public static bool RemoveService(string contentLocation) internal sealed class FileSystemBinaryDataService : IBinaryDataService { - - /// - /// - /// - /// The location of the content on disk. - /// The relative url to the binary content from the root of the site. - /// The logging service. - internal FileSystemBinaryDataService(string contentLocation, Uri binaryRootUrl, ILoggingDataService loggingService) + /// + /// + /// + /// The location of the content on disk. + /// The relative url to the binary content from the root of the site. + /// The logging service. + /// Creates content URis for CDN locations. + internal FileSystemBinaryDataService(string contentLocation, Uri binaryRootUrl, ILoggingDataService loggingService, ICdnManager cdnManager) { // parameter validation if (string.IsNullOrEmpty(contentLocation)) @@ -82,6 +82,7 @@ internal FileSystemBinaryDataService(string contentLocation, Uri binaryRootUrl, this.contentLocation = contentLocation; this.loggingService = loggingService; + this.cdnManager = cdnManager; this.binaryRoot = binaryRootUrl; } @@ -144,9 +145,11 @@ public string SaveFile(System.IO.Stream inputFile, ref string fileName) string absUri = GetAbsoluteFileUri(file.FullName, out relUri); - fileName = relUri; + fileName = relUri; + + absUri = cdnManager.ApplyCdnUri(absUri); - return absUri; + return absUri; } private string GetAbsoluteFileUri(string fullPath, out string relFileUri) @@ -218,6 +221,6 @@ private bool EqualBuffers(byte[] buf1, byte[] buf2) private string contentLocation; private Uri binaryRoot; private ILoggingDataService loggingService; - + private readonly ICdnManager cdnManager; } } diff --git a/source/newtelligence.DasBlog.Runtime/ICdnManager.cs b/source/newtelligence.DasBlog.Runtime/ICdnManager.cs new file mode 100644 index 000000000..21e1059b5 --- /dev/null +++ b/source/newtelligence.DasBlog.Runtime/ICdnManager.cs @@ -0,0 +1,16 @@ +namespace newtelligence.DasBlog.Runtime +{ + /// + /// When the site is configured with a "CdnRoot" setting, + /// this manager is used to create content URIs for the CDN location. + /// + public interface ICdnManager + { + /// + /// Manages URI creation for resources when CDN is configured. + /// + /// The URI of a file hosted locally. + /// The URI of a file when it is hosted in CDN. + string ApplyCdnUri(string uri); + } +} From 6f11f33de72696625290a0694b2eeb0db235088e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20M=C3=A5rtensson?= Date: Tue, 10 Jan 2023 08:35:48 +0100 Subject: [PATCH 2/4] CDN is configured as a from-to replace pattern for flexibility. --- .../ConfigFile/Interfaces/ISiteConfig.cs | 5 ++-- .../DasBlog.Services/ConfigFile/SiteConfig.cs | 30 +++++++++++++++---- .../DasBlog.Tests/UnitTests/SiteConfigTest.cs | 3 +- source/DasBlog.Web.UI/Config/site.config | 10 +++++-- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs b/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs index e70e74e14..dfd0af252 100644 --- a/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs @@ -61,9 +61,10 @@ public interface ISiteConfig string Root { get; set; } - string CdnRoot { get; set; } + string CdnFrom { get; set; } + string CdnTo { get; set; } - string Copyright { get; set; } + string Copyright { get; set; } int RssDayCount { get; set; } diff --git a/source/DasBlog.Services/ConfigFile/SiteConfig.cs b/source/DasBlog.Services/ConfigFile/SiteConfig.cs index 557c56b83..eb5735144 100644 --- a/source/DasBlog.Services/ConfigFile/SiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/SiteConfig.cs @@ -52,7 +52,8 @@ namespace DasBlog.Services.ConfigFile public class SiteConfig : ISiteConfig { private string _root; - private string _cdnRoot; + private string _cdnFrom; + private string _cdnTo; public SiteConfig() { } @@ -79,21 +80,40 @@ public string Root { } } - public string CdnRoot + public string CdnFrom { get { - return _cdnRoot; + return _cdnFrom; } set { if (!string.IsNullOrEmpty(value)) { - _cdnRoot = value + (value.EndsWith("/") ? "" : "/"); + _cdnFrom = value + (value.EndsWith("/") ? "" : "/"); } else { - _cdnRoot = value; + _cdnFrom = value; + } + } + } + + public string CdnTo + { + get + { + return _cdnTo; + } + set + { + if (!string.IsNullOrEmpty(value)) + { + _cdnTo= value + (value.EndsWith("/") ? "" : "/"); + } + else + { + _cdnTo = value; } } } diff --git a/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs b/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs index 236c67280..0a285a45a 100644 --- a/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs +++ b/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs @@ -15,7 +15,8 @@ public class SiteConfigTest : ISiteConfig public string Description { get => "Description"; set => throw new NotImplementedException(); } public string Contact { get => "Contact"; set => throw new NotImplementedException(); } public string Root { get => "http://www.poppastring.com/"; set => throw new NotImplementedException(); } - public string CdnRoot { get => ""; set => throw new NotImplementedException(); } + public string CdnFrom{ get => ""; set => throw new NotImplementedException(); } + public string CdnTo{ get => ""; set => throw new NotImplementedException(); } public string Copyright { get => "CopyRight"; set => throw new NotImplementedException(); } public int RssDayCount { get => 100; set => throw new NotImplementedException(); } public bool ShowCommentCount { get => true; set => throw new NotImplementedException(); } diff --git a/source/DasBlog.Web.UI/Config/site.config b/source/DasBlog.Web.UI/Config/site.config index f649ca010..07bb088c0 100644 --- a/source/DasBlog.Web.UI/Config/site.config +++ b/source/DasBlog.Web.UI/Config/site.config @@ -29,9 +29,13 @@ - - - + + + + + From 6d7084b512cd8146650e8ea11764b2ab1b489438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20M=C3=A5rtensson?= Date: Tue, 10 Jan 2023 08:35:48 +0100 Subject: [PATCH 3/4] CDN is a from to replace pattern. --- .../ConfigFile/Interfaces/ISiteConfig.cs | 5 ++-- .../DasBlog.Services/ConfigFile/SiteConfig.cs | 30 +++++++++++++++---- .../DasBlog.Tests/UnitTests/SiteConfigTest.cs | 3 +- .../FileSystemBinaryManager.cs | 2 +- source/DasBlog.Web.UI/Config/site.config | 11 +++++-- .../CdnManager.cs | 27 +++++++---------- 6 files changed, 49 insertions(+), 29 deletions(-) diff --git a/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs b/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs index e70e74e14..dfd0af252 100644 --- a/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs @@ -61,9 +61,10 @@ public interface ISiteConfig string Root { get; set; } - string CdnRoot { get; set; } + string CdnFrom { get; set; } + string CdnTo { get; set; } - string Copyright { get; set; } + string Copyright { get; set; } int RssDayCount { get; set; } diff --git a/source/DasBlog.Services/ConfigFile/SiteConfig.cs b/source/DasBlog.Services/ConfigFile/SiteConfig.cs index 557c56b83..eb5735144 100644 --- a/source/DasBlog.Services/ConfigFile/SiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/SiteConfig.cs @@ -52,7 +52,8 @@ namespace DasBlog.Services.ConfigFile public class SiteConfig : ISiteConfig { private string _root; - private string _cdnRoot; + private string _cdnFrom; + private string _cdnTo; public SiteConfig() { } @@ -79,21 +80,40 @@ public string Root { } } - public string CdnRoot + public string CdnFrom { get { - return _cdnRoot; + return _cdnFrom; } set { if (!string.IsNullOrEmpty(value)) { - _cdnRoot = value + (value.EndsWith("/") ? "" : "/"); + _cdnFrom = value + (value.EndsWith("/") ? "" : "/"); } else { - _cdnRoot = value; + _cdnFrom = value; + } + } + } + + public string CdnTo + { + get + { + return _cdnTo; + } + set + { + if (!string.IsNullOrEmpty(value)) + { + _cdnTo= value + (value.EndsWith("/") ? "" : "/"); + } + else + { + _cdnTo = value; } } } diff --git a/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs b/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs index 236c67280..0a285a45a 100644 --- a/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs +++ b/source/DasBlog.Tests/UnitTests/SiteConfigTest.cs @@ -15,7 +15,8 @@ public class SiteConfigTest : ISiteConfig public string Description { get => "Description"; set => throw new NotImplementedException(); } public string Contact { get => "Contact"; set => throw new NotImplementedException(); } public string Root { get => "http://www.poppastring.com/"; set => throw new NotImplementedException(); } - public string CdnRoot { get => ""; set => throw new NotImplementedException(); } + public string CdnFrom{ get => ""; set => throw new NotImplementedException(); } + public string CdnTo{ get => ""; set => throw new NotImplementedException(); } public string Copyright { get => "CopyRight"; set => throw new NotImplementedException(); } public int RssDayCount { get => 100; set => throw new NotImplementedException(); } public bool ShowCommentCount { get => true; set => throw new NotImplementedException(); } diff --git a/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs b/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs index bad0b2239..894afa2ca 100644 --- a/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs +++ b/source/DasBlog.Web.Repositories/FileSystemBinaryManager.cs @@ -32,7 +32,7 @@ public FileSystemBinaryManager(IDasBlogSettings dasBlogSettings, IConfigFileServ var loggingDataService = LoggingDataServiceFactory.GetService(Path.Combine(dasBlogSettings.WebRootDirectory, dasBlogSettings.SiteConfiguration.LogDir)); - var cdnManager = CdnManagerFactory.GetService(dasBlogSettings.SiteConfiguration.Root, dasBlogSettings.SiteConfiguration.CdnRoot); + var cdnManager = CdnManagerFactory.GetService(dasBlogSettings.SiteConfiguration.CdnFrom, dasBlogSettings.SiteConfiguration.CdnTo); binaryDataService = BinaryDataServiceFactory.GetService(options.BinaryFolder, physBinaryPathUrl, loggingDataService, cdnManager); } diff --git a/source/DasBlog.Web.UI/Config/site.config b/source/DasBlog.Web.UI/Config/site.config index f649ca010..db6f87a88 100644 --- a/source/DasBlog.Web.UI/Config/site.config +++ b/source/DasBlog.Web.UI/Config/site.config @@ -29,9 +29,14 @@ - - - + + + + + diff --git a/source/newtelligence.DasBlog.Runtime/CdnManager.cs b/source/newtelligence.DasBlog.Runtime/CdnManager.cs index e9994797c..586f9f501 100644 --- a/source/newtelligence.DasBlog.Runtime/CdnManager.cs +++ b/source/newtelligence.DasBlog.Runtime/CdnManager.cs @@ -4,39 +4,32 @@ namespace newtelligence.DasBlog.Runtime { public static class CdnManagerFactory { - public static ICdnManager GetService(string rootUri, string cdnUri) + public static ICdnManager GetService(string cdnFrom, string cdnTo) { - return new CdnManager(rootUri, cdnUri); + return new CdnManager(cdnFrom, cdnTo); } } internal sealed class CdnManager : ICdnManager { - private readonly string rootUri; - private readonly string cdnUri; + private readonly string cdnFrom; + private readonly string cdnTo; /// /// Setting up the cdn manager to return cdn uris when that is configured. /// - /// The root of the - /// - public CdnManager(string rootUri, string cdnUri) + /// The binary hosting path to be replaced. + /// The cdn binary hosting path to change to. + public CdnManager(string cdnFrom, string cdnTo) { - this.rootUri = - string.IsNullOrWhiteSpace(rootUri) || !Uri.TryCreate(rootUri, UriKind.Absolute, out _) ? - null : - rootUri; - this.cdnUri = - string.IsNullOrWhiteSpace(cdnUri) || !Uri.TryCreate(cdnUri, UriKind.Absolute, out _) ? - null : - cdnUri; - if (this.rootUri == null) this.cdnUri = null; + this.cdnFrom = string.IsNullOrWhiteSpace(cdnFrom) ? null : cdnFrom; + this.cdnTo = string.IsNullOrWhiteSpace(cdnTo) || this.cdnFrom == null ? null : cdnTo; } public string ApplyCdnUri(string uri) { // If the cdnUri is null then we can just return the uri. - return cdnUri == null ? uri : uri.Replace(rootUri, cdnUri); + return cdnTo == null ? uri : uri.Replace(cdnFrom, cdnTo); } } } From 8e715df3d8ab7b3984e072b0e45caf05a5ae78c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20M=C3=A5rtensson?= Date: Tue, 10 Jan 2023 11:56:38 +0100 Subject: [PATCH 4/4] Making CDN configurable from Site Admin. --- .../DasBlog.Services/ConfigFile/SiteConfig.cs | 40 +------------------ source/DasBlog.Web.UI/Config/site.config | 19 ++++----- .../Models/AdminViewModels/SiteViewModel.cs | 9 ++++- .../Views/Admin/Settings.cshtml | 16 ++++++++ 4 files changed, 36 insertions(+), 48 deletions(-) diff --git a/source/DasBlog.Services/ConfigFile/SiteConfig.cs b/source/DasBlog.Services/ConfigFile/SiteConfig.cs index eb5735144..cf3c65fd3 100644 --- a/source/DasBlog.Services/ConfigFile/SiteConfig.cs +++ b/source/DasBlog.Services/ConfigFile/SiteConfig.cs @@ -79,44 +79,8 @@ public string Root { } } } - - public string CdnFrom - { - get - { - return _cdnFrom; - } - set - { - if (!string.IsNullOrEmpty(value)) - { - _cdnFrom = value + (value.EndsWith("/") ? "" : "/"); - } - else - { - _cdnFrom = value; - } - } - } - - public string CdnTo - { - get - { - return _cdnTo; - } - set - { - if (!string.IsNullOrEmpty(value)) - { - _cdnTo= value + (value.EndsWith("/") ? "" : "/"); - } - else - { - _cdnTo = value; - } - } - } + public string CdnFrom { get; set; } + public string CdnTo { get; set; } public string AllowedHosts { get; set; } public string Copyright { get; set; } diff --git a/source/DasBlog.Web.UI/Config/site.config b/source/DasBlog.Web.UI/Config/site.config index db6f87a88..5f26767d0 100644 --- a/source/DasBlog.Web.UI/Config/site.config +++ b/source/DasBlog.Web.UI/Config/site.config @@ -29,15 +29,6 @@ - - - - - - @@ -65,6 +56,16 @@ logs content/binary + + + + + + true false false diff --git a/source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs b/source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs index 9e72f3c32..3fc1b87f2 100644 --- a/source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs +++ b/source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs @@ -240,9 +240,16 @@ public class SiteViewModel [DisplayName("Time zone index")] [Description("")] - public int DisplayTimeZoneIndex { get; set; } + [DisplayName("CDN from")] + [Description("The part of your Root URL to replace with the CDN URL. (optional)")] + public string CdnFrom { get; set; } + + [DisplayName("CDN to")] + [Description("The CDN URL that will replace 'CDN from'. (optional)")] + public string CdnTo { get; set; } + [DisplayName("Comments require approval")] [Description("")] public bool CommentsRequireApproval { get; set; } diff --git a/source/DasBlog.Web.UI/Views/Admin/Settings.cshtml b/source/DasBlog.Web.UI/Views/Admin/Settings.cshtml index 7dcf36689..cf3b0df0e 100644 --- a/source/DasBlog.Web.UI/Views/Admin/Settings.cshtml +++ b/source/DasBlog.Web.UI/Views/Admin/Settings.cshtml @@ -694,6 +694,22 @@ @Html.ValidationMessageFor(m => m.SiteConfig.DisplayTimeZoneIndex, null, new { @class = "text-danger" }) + +
+ + @Html.LabelFor(m => @Model.SiteConfig.CdnFrom, null, new { @class = "col-form-label col-sm-2" }) +
+ @Html.TextBoxFor(m => @Model.SiteConfig.CdnFrom, null, new { @class = "form-control sm-10" }) +
+ @Html.ValidationMessageFor(m => m.SiteConfig.CdnFrom, null, new { @class = "text-danger" }) + + @Html.LabelFor(m => @Model.SiteConfig.CdnTo, null, new { @class = "col-form-label col-sm-2" }) +
+ @Html.TextBoxFor(m => @Model.SiteConfig.CdnTo, null, new { @class = "form-control sm-10" }) +
+ @Html.ValidationMessageFor(m => m.SiteConfig.CdnTo, null, new { @class = "text-danger" }) + +

Security