-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #678 from noopman/cdnsupport
Adding CDN support for binary content. Configurable via the Admin page
- Loading branch information
Showing
10 changed files
with
117 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
|
||
namespace newtelligence.DasBlog.Runtime | ||
{ | ||
public static class CdnManagerFactory | ||
{ | ||
public static ICdnManager GetService(string cdnFrom, string cdnTo) | ||
{ | ||
return new CdnManager(cdnFrom, cdnTo); | ||
} | ||
} | ||
|
||
internal sealed class CdnManager : ICdnManager | ||
{ | ||
private readonly string cdnFrom; | ||
private readonly string cdnTo; | ||
|
||
/// <summary> | ||
/// Setting up the cdn manager to return cdn uris when that is configured. | ||
/// </summary> | ||
/// <param name="cdnFrom">The binary hosting path to be replaced.</param> | ||
/// <param name="cdnTo">The cdn binary hosting path to change to.</param> | ||
public CdnManager(string cdnFrom, string cdnTo) | ||
{ | ||
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 cdnTo == null ? uri : uri.Replace(cdnFrom, cdnTo); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace newtelligence.DasBlog.Runtime | ||
{ | ||
/// <summary> | ||
/// When the site is configured with a "CdnRoot" setting, | ||
/// this manager is used to create content URIs for the CDN location. | ||
/// </summary> | ||
public interface ICdnManager | ||
{ | ||
/// <summary> | ||
/// Manages URI creation for resources when CDN is configured. | ||
/// </summary> | ||
/// <param name="uri">The URI of a file hosted locally.</param> | ||
/// <returns>The URI of a file when it is hosted in CDN.</returns> | ||
string ApplyCdnUri(string uri); | ||
} | ||
} |