add support specifying RenderMode for Resources
This commit is contained in:
@ -95,6 +95,8 @@ namespace Oqtane.Modules
|
|||||||
var scripts = new List<object>();
|
var scripts = new List<object>();
|
||||||
var inline = 0;
|
var inline = 0;
|
||||||
foreach (Resource resource in resources)
|
foreach (Resource resource in resources)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(resource.RenderMode) || resource.RenderMode == RenderModes.Interactive)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(resource.Url))
|
if (!string.IsNullOrEmpty(resource.Url))
|
||||||
{
|
{
|
||||||
@ -107,6 +109,7 @@ namespace Oqtane.Modules
|
|||||||
await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower());
|
await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (scripts.Any())
|
if (scripts.Any())
|
||||||
{
|
{
|
||||||
await interop.IncludeScripts(scripts.ToArray());
|
await interop.IncludeScripts(scripts.ToArray());
|
||||||
|
@ -61,6 +61,8 @@ namespace Oqtane.Themes
|
|||||||
var scripts = new List<object>();
|
var scripts = new List<object>();
|
||||||
var inline = 0;
|
var inline = 0;
|
||||||
foreach (Resource resource in resources)
|
foreach (Resource resource in resources)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(resource.RenderMode) || resource.RenderMode == RenderModes.Interactive)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(resource.Url))
|
if (!string.IsNullOrEmpty(resource.Url))
|
||||||
{
|
{
|
||||||
@ -73,6 +75,7 @@ namespace Oqtane.Themes
|
|||||||
await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower());
|
await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (scripts.Any())
|
if (scripts.Any())
|
||||||
{
|
{
|
||||||
await interop.IncludeScripts(scripts.ToArray());
|
await interop.IncludeScripts(scripts.ToArray());
|
||||||
|
@ -578,6 +578,7 @@
|
|||||||
Location = resource.Location,
|
Location = resource.Location,
|
||||||
ES6Module = resource.ES6Module,
|
ES6Module = resource.ES6Module,
|
||||||
Content = resource.Content,
|
Content = resource.Content,
|
||||||
|
RenderMode = resource.RenderMode,
|
||||||
Level = level,
|
Level = level,
|
||||||
Namespace = name
|
Namespace = name
|
||||||
});
|
});
|
||||||
|
@ -527,10 +527,11 @@
|
|||||||
if (!string.IsNullOrEmpty(resource.Url))
|
if (!string.IsNullOrEmpty(resource.Url))
|
||||||
{
|
{
|
||||||
var url = (resource.Url.Contains("://")) ? resource.Url : alias.BaseUrl + resource.Url;
|
var url = (resource.Url.Contains("://")) ? resource.Url : alias.BaseUrl + resource.Url;
|
||||||
return "<script src=\"" + url + "\"" +
|
return "<script" +
|
||||||
((!string.IsNullOrEmpty(resource.Integrity)) ? " integrity=\"" + resource.Integrity + "\"" : "") +
|
((!string.IsNullOrEmpty(resource.Integrity)) ? " integrity=\"" + resource.Integrity + "\"" : "") +
|
||||||
((!string.IsNullOrEmpty(resource.CrossOrigin)) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") +
|
((!string.IsNullOrEmpty(resource.CrossOrigin)) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") +
|
||||||
"></script>";
|
((resource.ES6Module) ? " type=\"module\"" : "") +
|
||||||
|
" src =\"" + url + "\"></script>"; // src at end of element due to enhanced navigation patch algorithm
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -647,6 +648,7 @@
|
|||||||
Location = resource.Location,
|
Location = resource.Location,
|
||||||
ES6Module = resource.ES6Module,
|
ES6Module = resource.ES6Module,
|
||||||
Content = resource.Content,
|
Content = resource.Content,
|
||||||
|
RenderMode = resource.RenderMode,
|
||||||
Level = level,
|
Level = level,
|
||||||
Namespace = name
|
Namespace = name
|
||||||
});
|
});
|
||||||
@ -666,7 +668,10 @@
|
|||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
string id = "id=\"app-stylesheet-" + ResourceLevel.Page.ToString().ToLower() + "-" + batch + "-" + count.ToString("00") + "\" ";
|
string id = "id=\"app-stylesheet-" + ResourceLevel.Page.ToString().ToLower() + "-" + batch + "-" + count.ToString("00") + "\" ";
|
||||||
_styleSheets += "<link " + id + "rel=\"stylesheet\"" + (!string.IsNullOrEmpty(resource.Integrity) ? " integrity=\"" + resource.Integrity + "\"" : "") + (!string.IsNullOrEmpty(resource.CrossOrigin) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") + " href=\"" + resource.Url + "\" type=\"text/css\"/>" + Environment.NewLine;
|
_styleSheets += "<link " + id + "rel=\"stylesheet\"" +
|
||||||
|
(!string.IsNullOrEmpty(resource.Integrity) ? " integrity=\"" + resource.Integrity + "\"" : "") +
|
||||||
|
(!string.IsNullOrEmpty(resource.CrossOrigin) ? " crossorigin=\"" + resource.CrossOrigin + "\"" : "") +
|
||||||
|
" href=\"" + resource.Url + "\" type=\"text/css\"/>" + Environment.NewLine; // href at end of element due to enhanced navigation patch algorithm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,9 +681,12 @@
|
|||||||
if (resources != null)
|
if (resources != null)
|
||||||
{
|
{
|
||||||
foreach (var resource in resources.Where(item => item.ResourceType == ResourceType.Script))
|
foreach (var resource in resources.Where(item => item.ResourceType == ResourceType.Script))
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(resource.RenderMode) || resource.RenderMode == RenderModes.Static)
|
||||||
{
|
{
|
||||||
AddScript(resource, alias);
|
AddScript(resource, alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -62,6 +62,11 @@ namespace Oqtane.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For Scripts this defines the render mode (default is all render modes) - not applicable to Stylesheets
|
||||||
|
/// </summary>
|
||||||
|
public string RenderMode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The namespace of the component that declared the resource - only used in SiteRouter
|
/// The namespace of the component that declared the resource - only used in SiteRouter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Reference in New Issue
Block a user