Skip to content

Commit 6f11f33

Browse files
committed
CDN is configured as a from-to replace pattern for flexibility.
1 parent ba6d7cf commit 6f11f33

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ public interface ISiteConfig
6161

6262
string Root { get; set; }
6363

64-
string CdnRoot { get; set; }
64+
string CdnFrom { get; set; }
65+
string CdnTo { get; set; }
6566

66-
string Copyright { get; set; }
67+
string Copyright { get; set; }
6768

6869
int RssDayCount { get; set; }
6970

source/DasBlog.Services/ConfigFile/SiteConfig.cs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ namespace DasBlog.Services.ConfigFile
5252
public class SiteConfig : ISiteConfig
5353
{
5454
private string _root;
55-
private string _cdnRoot;
55+
private string _cdnFrom;
56+
private string _cdnTo;
5657

5758
public SiteConfig() { }
5859

@@ -79,21 +80,40 @@ public string Root {
7980
}
8081
}
8182

82-
public string CdnRoot
83+
public string CdnFrom
8384
{
8485
get
8586
{
86-
return _cdnRoot;
87+
return _cdnFrom;
8788
}
8889
set
8990
{
9091
if (!string.IsNullOrEmpty(value))
9192
{
92-
_cdnRoot = value + (value.EndsWith("/") ? "" : "/");
93+
_cdnFrom = value + (value.EndsWith("/") ? "" : "/");
9394
}
9495
else
9596
{
96-
_cdnRoot = value;
97+
_cdnFrom = value;
98+
}
99+
}
100+
}
101+
102+
public string CdnTo
103+
{
104+
get
105+
{
106+
return _cdnTo;
107+
}
108+
set
109+
{
110+
if (!string.IsNullOrEmpty(value))
111+
{
112+
_cdnTo= value + (value.EndsWith("/") ? "" : "/");
113+
}
114+
else
115+
{
116+
_cdnTo = value;
97117
}
98118
}
99119
}

source/DasBlog.Tests/UnitTests/SiteConfigTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public class SiteConfigTest : ISiteConfig
1515
public string Description { get => "Description"; set => throw new NotImplementedException(); }
1616
public string Contact { get => "Contact"; set => throw new NotImplementedException(); }
1717
public string Root { get => "http://www.poppastring.com/"; set => throw new NotImplementedException(); }
18-
public string CdnRoot { get => ""; set => throw new NotImplementedException(); }
18+
public string CdnFrom{ get => ""; set => throw new NotImplementedException(); }
19+
public string CdnTo{ get => ""; set => throw new NotImplementedException(); }
1920
public string Copyright { get => "CopyRight"; set => throw new NotImplementedException(); }
2021
public int RssDayCount { get => 100; set => throw new NotImplementedException(); }
2122
public bool ShowCommentCount { get => true; set => throw new NotImplementedException(); }

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929

3030
<!-- END OF SUGGESTED SETTINGS -->
3131

32-
<!-- OPTIONAL: IF you use a CDN service your files are still stored locally on the blog site, and the CDN url below will replace your <Root> when referncing your binary content. -->
33-
<!-- Set the base URL of the cdn servcie http://cdn.example.com/blog/ -->
34-
<CdnRoot></CdnRoot>
32+
<!-- OPTIONAL: Content Delivery Network (CDN)
33+
The two CDN settings below (CdnFrom/CdnTo) is a search and replace pattern.
34+
-->
35+
<!-- The part of your <Root> or binary hosting path you want to replace (ex. http://example.com/content/binary/): -->
36+
<CdnFrom></CdnFrom>
37+
<!-- The URL of the cdn servcie you are replacing to (ex. http://cdn.example.com/content/binary/): -->
38+
<CdnTo></CdnTo>
3539

3640
<MastodonServerUrl />
3741
<MastodonAccount />

0 commit comments

Comments
 (0)