Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure page css #4500

Merged
merged 5 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DNN Platform/DotNetNuke.Web.Client/ClientResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ public static void RegisterStyleSheet(Page page, string filePath, int priority,

// Some "legacy URLs" could be using their own query string versioning scheme (and we've forced them to use the new API through re-routing PageBase.RegisterStyleSheet
// Ensure that physical CSS files with query strings have their query strings removed
if (filePath.Contains(".css?"))
// Ignore absolute urls, they will not exist locally
if (!Uri.TryCreate(filePath, UriKind.Absolute, out _) && filePath.Contains(".css?"))
{
var filePathSansQueryString = RemoveQueryString(filePath);
if (File.Exists(page.Server.MapPath(filePathSansQueryString)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private Dictionary<string, string> GetDefaultContentTypes()
contentTypes.Add("pps", "application/vnd.ms-powerpoint");
contentTypes.Add("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
contentTypes.Add("ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow");
contentTypes.Add("css", "text/css");

return contentTypes;
}
Expand Down
30 changes: 28 additions & 2 deletions DNN Platform/Website/Default.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,18 @@ private void InitializePage()
// register the custom stylesheet of current page
if (this.PortalSettings.ActiveTab.TabSettings.ContainsKey("CustomStylesheet") && !string.IsNullOrEmpty(this.PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString()))
{
var customStylesheet = Path.Combine(this.PortalSettings.HomeDirectory, this.PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString());
ClientResourceManager.RegisterStyleSheet(this, customStylesheet);
var styleSheet = this.PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString();

// Try and go through the FolderProvider first
var stylesheetFile = GetPageStylesheetFileInfo(styleSheet);
if (stylesheetFile != null)
{
ClientResourceManager.RegisterStyleSheet(this, FileManager.Instance.GetUrl(stylesheetFile));
}
else
{
ClientResourceManager.RegisterStyleSheet(this, styleSheet);
}
}

// Cookie Consent
Expand Down Expand Up @@ -737,5 +747,21 @@ private IFileInfo GetBackgroundFileInfoCallBack(CacheItemArgs itemArgs)
{
return FileManager.Instance.GetFile(this.PortalSettings.PortalId, this.PortalSettings.BackgroundFile);
}

private IFileInfo GetPageStylesheetFileInfo(string styleSheet)
{
string cacheKey = string.Format(Common.Utilities.DataCache.PortalCacheKey, this.PortalSettings.PortalId, "PageStylesheet" + styleSheet);
var file = CBO.GetCachedObject<Services.FileSystem.FileInfo>(
new CacheItemArgs(cacheKey, Common.Utilities.DataCache.PortalCacheTimeOut, Common.Utilities.DataCache.PortalCachePriority, styleSheet),
this.GetPageStylesheetInfoCallBack);

return file;
}

private IFileInfo GetPageStylesheetInfoCallBack(CacheItemArgs itemArgs)
{
var styleSheet = itemArgs.Params[0].ToString();
return FileManager.Instance.GetFile(this.PortalSettings.PortalId, styleSheet);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/************************************************************/
/***** SqlDataProvider *****/
/***** *****/
/***** *****/
/***** Note: To manually execute this script you must *****/
/***** perform a search and replace operation *****/
/***** for {databaseOwner} and {objectQualifier} *****/
/***** *****/
/************************************************************/

-- Add CSS content type, this will help when a Page Style Sheet is uploaded to a folder provider such as AzureFolderProvider.
IF NOT EXISTS (SELECT * FROM {databaseOwner}{objectQualifier}Lists WHERE ListName='ContentTypes' AND Value = 'css')
BEGIN
INSERT INTO {databaseOwner}[{objectQualifier}Lists] ( [ListName], [Value], [Text], [ParentID], [Level], [SortOrder], [DefinitionID], [Description], [PortalID], [SystemList], [CreatedByUserID], [CreatedOnDate], [LastModifiedByUserID], [LastModifiedOnDate]) VALUES (N'ContentTypes', N'css', N'text/css', 0, 0, 0, -1, N'', -1, 1, -1, GETDATE(), -1, GETDATE())
END