Merge remote-tracking branch 'oqtane/dev' into dev
This commit is contained in:
commit
ef8c47a49f
|
@ -355,7 +355,7 @@
|
|||
// appearance
|
||||
_title = _page.Title;
|
||||
_themetype = _page.ThemeType;
|
||||
if (string.IsNullOrEmpty(_themetype))
|
||||
if (string.IsNullOrEmpty(_themetype) || ThemeService.GetTheme(PageState.Site.Themes, _themetype)?.ThemeName != ThemeService.GetTheme(PageState.Site.Themes, PageState.Site.DefaultThemeType)?.ThemeName)
|
||||
{
|
||||
_themetype = PageState.Site.DefaultThemeType;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,14 @@ namespace Oqtane.Services
|
|||
/// <returns></returns>
|
||||
Task<Theme> GetThemeAsync(int themeId, int siteId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a theme <see cref="ThemeControl"/>s containing a specific theme control type
|
||||
/// </summary>
|
||||
/// <param name="themes"></param>
|
||||
/// <param name="themeControlType"></param>
|
||||
/// <returns></returns>
|
||||
Theme GetTheme(List<Theme> themes, string themeControlType);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of <see cref="ThemeControl"/>s from the given themes
|
||||
/// </summary>
|
||||
|
@ -32,19 +40,20 @@ namespace Oqtane.Services
|
|||
List<ThemeControl> GetThemeControls(List<Theme> themes);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of <see cref="ThemeControl"/>s from the given themes with a matching theme type
|
||||
/// Returns a list of <see cref="ThemeControl"/>s for a theme containing a specific theme control type
|
||||
/// </summary>
|
||||
/// <param name="themes"></param>
|
||||
/// <param name="themeControlType"></param>
|
||||
/// <returns></returns>
|
||||
List<ThemeControl> GetThemeControls(List<Theme> themes, string themeType);
|
||||
List<ThemeControl> GetThemeControls(List<Theme> themes, string themeControlType);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of containers (<see cref="ThemeControl"/>) from the given themes with a matching theme type
|
||||
/// Returns a list of containers (<see cref="ThemeControl"/>) for a theme containing a specific theme control type
|
||||
/// </summary>
|
||||
/// <param name="themes"></param>
|
||||
/// <param name="themeName"></param>
|
||||
/// <param name="themeControlType"></param>
|
||||
/// <returns></returns>
|
||||
List<ThemeControl> GetContainerControls(List<Theme> themes, string themeType);
|
||||
List<ThemeControl> GetContainerControls(List<Theme> themes, string themeControlType);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a existing theem
|
||||
|
|
|
@ -26,20 +26,25 @@ namespace Oqtane.Services
|
|||
return await GetJsonAsync<Theme>($"{ApiUrl}/{themeId}?siteid={siteId}");
|
||||
}
|
||||
|
||||
public Theme GetTheme(List<Theme> themes, string themeControlType)
|
||||
{
|
||||
return themes.FirstOrDefault(item => item.Themes.Any(item => item.TypeName == themeControlType));
|
||||
}
|
||||
|
||||
public List<ThemeControl> GetThemeControls(List<Theme> themes)
|
||||
{
|
||||
return themes.SelectMany(item => item.Themes).OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public List<ThemeControl> GetThemeControls(List<Theme> themes, string themeType)
|
||||
public List<ThemeControl> GetThemeControls(List<Theme> themes, string themeControlType)
|
||||
{
|
||||
return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Themes.OrderBy(item => item.Name).ToList();
|
||||
return GetTheme(themes, themeControlType)?.Themes.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<ThemeControl> GetContainerControls(List<Theme> themes, string themeType)
|
||||
public List<ThemeControl> GetContainerControls(List<Theme> themes, string themeControlType)
|
||||
{
|
||||
return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Containers.OrderBy(item => item.Name).ToList();
|
||||
return GetTheme(themes, themeControlType)?.Containers.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task UpdateThemeAsync(Theme theme)
|
||||
|
|
|
@ -19,7 +19,12 @@ namespace Oqtane.Themes.Controls
|
|||
{
|
||||
if (page.IsClickable)
|
||||
{
|
||||
return string.IsNullOrEmpty(page.Url) ? NavigateUrl(page.Path) : page.Url;
|
||||
var url = string.IsNullOrEmpty(page.Url) ? NavigateUrl(page.Path) : page.Url;
|
||||
if (PageState.QueryString.ContainsKey("method"))
|
||||
{
|
||||
url += ((url.Contains("?")) ? "&" : "?") + "method=" + PageState.QueryString["method"];
|
||||
}
|
||||
return url;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
{
|
||||
<link id="app-manifest" rel="manifest" />
|
||||
}
|
||||
@Html.Raw(Model.StyleSheets)
|
||||
<link id="app-stylesheet-page" />
|
||||
<link id="app-stylesheet-module" />
|
||||
<component type="typeof(Oqtane.Head)" render-mode="@((RenderMode)Enum.Parse(typeof(RenderMode), Model.RenderMode, true))" />
|
||||
|
|
|
@ -21,7 +21,6 @@ using Oqtane.Security;
|
|||
using Oqtane.Extensions;
|
||||
using Oqtane.Themes;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.UI;
|
||||
|
||||
namespace Oqtane.Pages
|
||||
{
|
||||
|
@ -69,6 +68,7 @@ namespace Oqtane.Pages
|
|||
public string RemoteIPAddress = "";
|
||||
public string HeadResources = "";
|
||||
public string BodyResources = "";
|
||||
public string StyleSheets = "";
|
||||
public string PWAScript = "";
|
||||
public string ReconnectScript = "";
|
||||
public string Message = "";
|
||||
|
@ -167,6 +167,8 @@ namespace Oqtane.Pages
|
|||
}
|
||||
|
||||
// stylesheets
|
||||
if (!HttpContext.Request.Query.ContainsKey("method") || (HttpContext.Request.Query.ContainsKey("method") && HttpContext.Request.Query["method"] == "old"))
|
||||
{
|
||||
var resources = new List<Resource>();
|
||||
if (string.IsNullOrEmpty(page.ThemeType))
|
||||
{
|
||||
|
@ -186,7 +188,8 @@ namespace Oqtane.Pages
|
|||
resources.AddRange(obj.Resources.Where(item => item.ResourceType == ResourceType.Stylesheet).ToList());
|
||||
}
|
||||
}
|
||||
ManageResources(resources, alias, theme.ThemeName);
|
||||
ManageStyleSheets(resources, alias, theme.ThemeName);
|
||||
}
|
||||
|
||||
// scripts
|
||||
if (Runtime == "Server")
|
||||
|
@ -494,7 +497,7 @@ namespace Oqtane.Pages
|
|||
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)));
|
||||
}
|
||||
|
||||
private void ManageResources(List<Resource> resources, Alias alias, string name)
|
||||
private void ManageStyleSheets(List<Resource> resources, Alias alias, string name)
|
||||
{
|
||||
if (resources != null)
|
||||
{
|
||||
|
@ -510,15 +513,11 @@ namespace Oqtane.Pages
|
|||
resource.Url = alias.BaseUrl + resource.Url;
|
||||
}
|
||||
|
||||
if (!HeadResources.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string id = "";
|
||||
if (!HttpContext.Request.Query.ContainsKey("method") || (HttpContext.Request.Query.ContainsKey("method") && HttpContext.Request.Query["method"] == "old"))
|
||||
if (!StyleSheets.Contains(resource.Url, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
count++;
|
||||
id = "id=\"app-stylesheet-" + ResourceLevel.Page.ToString().ToLower() + "-" + DateTime.UtcNow.ToString("yyyyMMddHHmmssfff") + "-" + count.ToString("00") + "\" ";
|
||||
}
|
||||
HeadResources += "<link " + id + "rel=\"stylesheet\" href=\"" + resource.Url + "\"" + (!string.IsNullOrEmpty(resource.Integrity) ? " integrity=\"" + resource.Integrity + "\"" : "") + (!string.IsNullOrEmpty(resource.CrossOrigin) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") + " type=\"text/css\"/>" + Environment.NewLine;
|
||||
string id = "id=\"app-stylesheet-" + ResourceLevel.Page.ToString().ToLower() + "-" + DateTime.UtcNow.ToString("yyyyMMddHHmmssfff") + "-" + count.ToString("00") + "\" ";
|
||||
StyleSheets += "<link " + id + "rel=\"stylesheet\" href=\"" + resource.Url + "\"" + (!string.IsNullOrEmpty(resource.Integrity) ? " integrity=\"" + resource.Integrity + "\"" : "") + (!string.IsNullOrEmpty(resource.CrossOrigin) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") + " type=\"text/css\"/>" + Environment.NewLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user