Merge pull request #2844 from sbwalker/dev
utilize new Resources capability in default module/theme
This commit is contained in:
		| @ -53,7 +53,6 @@ | ||||
|  | ||||
| 	public override List<Resource> Resources => new List<Resource>() | ||||
| 	{ | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }, | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = "css/quill/quill.bubble.css" }, | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = "css/quill/quill.snow.css" } | ||||
|     }; | ||||
|  | ||||
| @ -15,11 +15,6 @@ | ||||
| } | ||||
|  | ||||
| @code { | ||||
| 	public override List<Resource> Resources => new List<Resource>() | ||||
|     { | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } | ||||
|     }; | ||||
|  | ||||
| 	private string content = ""; | ||||
|  | ||||
| 	protected override async Task OnParametersSetAsync() | ||||
|  | ||||
| @ -1,5 +1,7 @@ | ||||
| using System.Collections.Generic; | ||||
| using Oqtane.Documentation; | ||||
| using Oqtane.Models; | ||||
| using Oqtane.Shared; | ||||
|  | ||||
| namespace Oqtane.Modules.HtmlText | ||||
| { | ||||
| @ -13,7 +15,11 @@ namespace Oqtane.Modules.HtmlText | ||||
|             Version = "1.0.1", | ||||
|             ServerManagerType = "Oqtane.Modules.HtmlText.Manager.HtmlTextManager, Oqtane.Server", | ||||
|             ReleaseVersions = "1.0.0,1.0.1", | ||||
|             SettingsType = "Oqtane.Modules.HtmlText.Settings, Oqtane.Client" | ||||
|             SettingsType = "Oqtane.Modules.HtmlText.Settings, Oqtane.Client", | ||||
|             Resources = new List<Resource>() | ||||
|             { | ||||
|                 new Resource { ResourceType = ResourceType.Stylesheet, Url = "~/Module.css" } | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,5 +1,7 @@ | ||||
| using System.Collections.Generic; | ||||
| using Oqtane.Documentation; | ||||
| using Oqtane.Models; | ||||
| using Oqtane.Shared; | ||||
|  | ||||
| namespace Oqtane.Themes.OqtaneTheme | ||||
| { | ||||
| @ -11,7 +13,13 @@ namespace Oqtane.Themes.OqtaneTheme | ||||
|             Name = "Oqtane Theme", | ||||
|             Version = "1.0.0", | ||||
|             ThemeSettingsType = "Oqtane.Themes.OqtaneTheme.ThemeSettings, Oqtane.Client", | ||||
|             ContainerSettingsType = "Oqtane.Themes.OqtaneTheme.ContainerSettings, Oqtane.Client" | ||||
|             ContainerSettingsType = "Oqtane.Themes.OqtaneTheme.ContainerSettings, Oqtane.Client", | ||||
|             Resources = new List<Resource>() | ||||
|             { | ||||
|                 new Resource { ResourceType = ResourceType.Stylesheet, Url = "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.2.0/cyborg/bootstrap.min.css", Integrity = "sha512-d6pZJl/sNcj0GFkp4kTjXtPE14deuUsOqFQtxkj0KyBJQl+4e0qsEyuIDcNqrYuGoauAW3sWyDCQp49mhF4Syw==", CrossOrigin = "anonymous" }, | ||||
|                 new Resource { ResourceType = ResourceType.Stylesheet, Url = "~/Theme.css" }, | ||||
|                 new Resource { ResourceType = ResourceType.Script, Url = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/js/bootstrap.bundle.min.js", Integrity = "sha512-9GacT4119eY3AcosfWtHMsT5JyZudrexyEVzTBWV3viP/YfB9e2pEy3N7WXL3SV6ASXpTU0vzzSxsbfsuUH4sQ==", CrossOrigin = "anonymous" } | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -110,14 +110,6 @@ | ||||
|  | ||||
| 	public override string Panes => PaneNames.Default + ",Top Full Width,Top 100%,Left 50%,Right 50%,Left 33%,Center 33%,Right 33%,Left Outer 25%,Left Inner 25%,Right Inner 25%,Right Outer 25%,Left 25%,Center 50%,Right 25%,Left Sidebar 66%,Right Sidebar 33%,Left Sidebar 33%,Right Sidebar 66%,Bottom 100%,Bottom Full Width,Footer"; | ||||
|  | ||||
|     public override List<Resource> Resources => new List<Resource>() | ||||
|     { | ||||
| 		// obtained from https://cdnjs.com/libraries | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.2.0/cyborg/bootstrap.min.css", Integrity = "sha512-d6pZJl/sNcj0GFkp4kTjXtPE14deuUsOqFQtxkj0KyBJQl+4e0qsEyuIDcNqrYuGoauAW3sWyDCQp49mhF4Syw==", CrossOrigin = "anonymous" }, | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = ThemePath() + "Theme.css" }, | ||||
|         new Resource { ResourceType = ResourceType.Script, Bundle = "Bootstrap", Url = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/js/bootstrap.bundle.min.js", Integrity = "sha512-9GacT4119eY3AcosfWtHMsT5JyZudrexyEVzTBWV3viP/YfB9e2pEy3N7WXL3SV6ASXpTU0vzzSxsbfsuUH4sQ==", CrossOrigin = "anonymous" } | ||||
| 	}; | ||||
|  | ||||
|     private bool _login = true; | ||||
|     private bool _register = true; | ||||
|     private bool _footer = false; | ||||
|  | ||||
| @ -96,6 +96,30 @@ | ||||
|             { | ||||
|                 await InjectScripts(PageState.Page.BodyContent, ResourceLocation.Body); | ||||
|             } | ||||
|  | ||||
|             if (PageState.Page.Resources != null && PageState.Page.Resources.Exists(item => item.ResourceType == ResourceType.Script)) | ||||
|             { | ||||
|                 var interop = new Interop(JSRuntime); | ||||
|                 var scripts = new List<object>(); | ||||
|                 var inline = 0; | ||||
|                 foreach (Resource resource in PageState.Page.Resources.Where(item => item.ResourceType == ResourceType.Script && item.Level != ResourceLevel.Site)) | ||||
|                 { | ||||
|                     if (!string.IsNullOrEmpty(resource.Url)) | ||||
|                     { | ||||
|                         var url = (resource.Url.Contains("://")) ? resource.Url : PageState.Alias.BaseUrl + resource.Url; | ||||
|                         scripts.Add(new { href = url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", es6module = resource.ES6Module, location = resource.Location.ToString().ToLower() }); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         inline += 1; | ||||
|                         await interop.IncludeScript(GetType().Namespace.ToLower() + inline.ToString(), "", "", "", resource.Content, resource.Location.ToString().ToLower()); | ||||
|                     } | ||||
|                 } | ||||
|                 if (scripts.Any()) | ||||
|                 { | ||||
|                     await interop.IncludeScripts(scripts.ToArray()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker