diff --git a/demos/cloudscribe.DemoWeb/appsettings.json b/demos/cloudscribe.DemoWeb/appsettings.json index 0ce814c..4f90db1 100644 --- a/demos/cloudscribe.DemoWeb/appsettings.json +++ b/demos/cloudscribe.DemoWeb/appsettings.json @@ -1,358 +1,362 @@ { - "AppSettings": { - "UseSsl": true, - "HttpsPort": 443, - "UseAzureBlobForDataProtection": false, - "DataProtectionBlobStorageConnectionString": "" - }, - - "ConnectionStrings": { - "EntityFrameworkConnection": "Server=(localdb)\\mssqllocaldb;Database=sourceDev.WebApp-4935FAD8-F6E0-4525-9C6A-FDDEFFAD85BF;Trusted_Connection=True;MultipleActiveResultSets=true", - "MySqlEntityFrameworkConnectionString": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", - "PostgreSqlEntityFrameworkConnectionString": "Server=localhost;Port=5432;User Id=yourdbusr;Password=yourdbpassword;Database=yourdbname;", - "SQLiteEntityFrameworkConnectionString": "Data Source=appdata.db;" - }, - + "AppSettings": { + "UseSsl": true, + "HttpsPort": 443, + "UseAzureBlobForDataProtection": false, + "DataProtectionBlobStorageConnectionString": "" + }, - "DevOptions": { - "DbPlatform": "NoDb", - "EFProvider": "MSSQL" - }, + "ConnectionStrings": { + "EntityFrameworkConnection": "Server=(localdb)\\mssqllocaldb;Database=sourceDev.WebApp-4935FAD8-F6E0-4525-9C6A-FDDEFFAD85BF;Trusted_Connection=True;MultipleActiveResultSets=true", + "MySqlEntityFrameworkConnectionString": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", + "PostgreSqlEntityFrameworkConnectionString": "Server=localhost;Port=5432;User Id=yourdbusr;Password=yourdbpassword;Database=yourdbname;", + "SQLiteEntityFrameworkConnectionString": "Data Source=appdata.db;" + }, - "MultiTenantOptions": { - "Mode": "FolderName", - "UseRelatedSitesMode": "false", - "RelatedSiteId": "00000000-0000-0000-0000-000000000000", - "RelatedSiteAliasId": "", - "SiteUploadFilesRootFolderName": "siteuploadfiles" - }, + "DevOptions": { + "DbPlatform": "NoDb", + "EFProvider": "MSSQL" + }, - "PushServiceClient": { - "Subject": "", - "PublicKey": "", - "PrivateKey": "" - }, - "PwaOptions": { - "CacheIdSuffix": "v1.0", - "AutoRegisterServiceWorker": true, - "RequireCookieConsentBeforeRegisteringServiceWorker": true, - "EnableServiceWorkerConsoleLog": true, - "ServiceWorkerCacheControlMaxAgeInSeconds": 86400, //1 day - "EnableCspNonce": false, - "AllowHttp": false, - "SetupInstallPrompt": true, - "ReloadPageOnServiceWorkerUpdate": false, - "ExcludedAutoRegistrationPathsCsv": "/account/login,/account/register", - "WorkBoxUrl": "https://storage.googleapis.com/workbox-cdn/releases/6.2.0/workbox-sw.js" - }, - "PwaPreCacheItems": { - "Assets": [ - { - "Url": "/custom1/css/style.css" - }, - { - "Url": "/cr/js/ckeditor4114/plugins/codesnippet/lib/highlight/styles/default.css" - }, - { - "Url": "/custom1/js/jquery.min.js" - }, - { - "Url": "/custom1/js/bootstrap.bundle.js" - }, - { - "Url": "/cr/js/bs4.smartmenus.min.js" - }, - { - "Url": "/cr/js/ckeditor4114/plugins/codesnippet/lib/highlight/highlight.pack.js" - }, - { - "Url": "/cr/js/syntax-highlight-init.js" - }, - { - "Url": "/csscsr/css/blog-common.min.css" - }, - { - "Url": "/cr/css/baguetteBox.min.css" - }, - { - "Url": "/csscsr/css/simple-gallery.min.css" - }, - { - "Url": "/sctr/css/simple-image.min.css" - }, - { - "Url": "/cr/js/baguetteBox.min.js" - }, - { - "Url": "/csscsr/js/sc-simple-gallery-init.js" - }, - { - "Url": "/manifest.json" - }, - { - "Url": "/webfonts/fa-solid-900.woff2" - }, - { - "Url": "/webfonts/fa-regular-400.woff2" - }, - { - "Url": "/webfonts/fa-solid-900.woff" - }, - { - "Url": "/webfonts/fa-regular-400.woff" - }, - { - "Url": "/webfonts/fa-solid-900.ttf" - }, - { - "Url": "/webfonts/fa-regular-400.ttf" - }, - { - "Url": "/cr/images/generic-user.png" - } + "MultiTenantOptions": { + "Mode": "FolderName", + "UseRelatedSitesMode": "false", + "RelatedSiteId": "00000000-0000-0000-0000-000000000000", + "RelatedSiteAliasId": "", + "SiteUploadFilesRootFolderName": "siteuploadfiles" + }, + "PushServiceClient": { + "Subject": "", + "PublicKey": "", + "PrivateKey": "" + }, - ] - }, + "PwaOptions": { + "CacheIdSuffix": "v1.0", + "AutoRegisterServiceWorker": true, + "RequireCookieConsentBeforeRegisteringServiceWorker": true, + "EnableServiceWorkerConsoleLog": true, + "ServiceWorkerCacheControlMaxAgeInSeconds": 86400, //1 day + "EnableCspNonce": false, + "AllowHttp": false, + "SetupInstallPrompt": true, + "ReloadPageOnServiceWorkerUpdate": false, + "ExcludedAutoRegistrationPathsCsv": "/account/login,/account/register", + "WorkBoxUrl": "https://storage.googleapis.com/workbox-cdn/releases/6.2.0/workbox-sw.js" + }, + "PwaPreCacheItems": { + "Assets": [ + { + "Url": "/custom1/css/style.css" + }, + { + "Url": "/cr/js/ckeditor4114/plugins/codesnippet/lib/highlight/styles/default.css" + }, + { + "Url": "/custom1/js/jquery.min.js" + }, + { + "Url": "/custom1/js/bootstrap.bundle.js" + }, + { + "Url": "/cr/js/bs4.smartmenus.min.js" + }, + { + "Url": "/cr/js/ckeditor4114/plugins/codesnippet/lib/highlight/highlight.pack.js" + }, + { + "Url": "/cr/js/syntax-highlight-init.js" + }, + { + "Url": "/csscsr/css/blog-common.min.css" + }, + { + "Url": "/cr/css/baguetteBox.min.css" + }, + { + "Url": "/csscsr/css/simple-gallery.min.css" + }, + { + "Url": "/sctr/css/simple-image.min.css" + }, + { + "Url": "/cr/js/baguetteBox.min.js" + }, + { + "Url": "/csscsr/js/sc-simple-gallery-init.js" + }, + { + "Url": "/manifest.json" + }, + { + "Url": "/webfonts/fa-solid-900.woff2" + }, + { + "Url": "/webfonts/fa-regular-400.woff2" + }, + { + "Url": "/webfonts/fa-solid-900.woff" + }, + { + "Url": "/webfonts/fa-regular-400.woff" + }, + { + "Url": "/webfonts/fa-solid-900.ttf" + }, + { + "Url": "/webfonts/fa-regular-400.ttf" + }, + { + "Url": "/cr/images/generic-user.png" + } - "PwaContentFilesPreCacheOptions": { - "FileExtensionsToCache": ".jpg,.gif,.png,.jpe,.jpeg" - }, + ] + }, + "PwaContentFilesPreCacheOptions": { + "FileExtensionsToCache": ".jpg,.gif,.png,.jpe,.jpeg" + }, + "PwaNetworkOnlyUrlOptions": { + "Urls": [ + "/excluded-page", + "/excluded-page2" + ] + }, - "SmtpOptions": { - "Server": "", - "Port": "25", - "User": "", - "Password": "", - "UseSsl": "false", - "RequiresAuthentication": "false", - "DefaultEmailFromAddress": "", - "DefaultEmailFromAlias": "" - }, - "SendGridOptions": { - "ApiKey": "", - "DefaultEmailFromAddress": "", - "DefaultEmailFromAlias": "" - }, - "MailgunOptions": { - "ApiKey": "", - "EndpointUrl": "", - "DefaultEmailFromAddress": "", - "DefaultEmailFromAlias": "" - }, - "ElasticEmailOptions": { - "ApiKey": "", - "DefaultEmailFromAddress": "", - "DefaultEmailFromAlias": "", - "EndpointUrl": "https://api.elasticemail.com/v2/email/send" - }, + "SmtpOptions": { + "Server": "", + "Port": "25", + "User": "", + "Password": "", + "UseSsl": "false", + "RequiresAuthentication": "false", + "DefaultEmailFromAddress": "", + "DefaultEmailFromAlias": "" + }, + "SendGridOptions": { + "ApiKey": "", + "DefaultEmailFromAddress": "", + "DefaultEmailFromAlias": "" + }, + "MailgunOptions": { + "ApiKey": "", + "EndpointUrl": "", + "DefaultEmailFromAddress": "", + "DefaultEmailFromAlias": "" + }, + "ElasticEmailOptions": { + "ApiKey": "", + "DefaultEmailFromAddress": "", + "DefaultEmailFromAlias": "", + "EndpointUrl": "https://api.elasticemail.com/v2/email/send" + }, - "SiteConfigOptions": { - "DefaultTheme": "superhero", - "FirstSiteTheme": "custom1", - "RolesThatCannotBeDeleted": "" - }, - "UIOptions": { - "AllowDeleteChildSites": "false" - }, - "CoreThemeConfig": { - "DefaultTheme": "default", - "ThemeSettings": [ - { - "ThemeName": "default", - "CoreIconSetId": "fontawesome5x", - "AdminSideNavExpanded": true, - "EnableHeaderFooterEditingInSiteSettings": true - } - ] - }, - "CoreIconConfig": { - "DefaultSetId": "fontawesome5x", - "IconSets": [ - { - "SetId": "fontawesome5x", - "Email": "fas fa-at", - "Username": "far fa-arrow-alt-circle-right", - "Password": "fas fa-lock", - "FirstName": "far fa-user", - "LastName": "far fa-user", - "DateOfBirth": "far fa-calendar-alt", - "Facebook": "fab fa-facebook-square", - "Google": "fab fa-google", - "Twitter": "fab fa-twitter-square", - "Microsoft": "fab fa-windows", - "OpenIDConnect": "fas fa-arrow-alt-circle-right" - } - ] - }, + "SiteConfigOptions": { + "DefaultTheme": "superhero", + "FirstSiteTheme": "custom1", + "RolesThatCannotBeDeleted": "" + }, + "UIOptions": { + "AllowDeleteChildSites": "false" + }, + "CoreThemeConfig": { + "DefaultTheme": "default", + "ThemeSettings": [ + { + "ThemeName": "default", + "CoreIconSetId": "fontawesome5x", + "AdminSideNavExpanded": true, + "EnableHeaderFooterEditingInSiteSettings": true + } + ] + }, + "CoreIconConfig": { + "DefaultSetId": "fontawesome5x", + "IconSets": [ + { + "SetId": "fontawesome5x", + "Email": "fas fa-at", + "Username": "far fa-arrow-alt-circle-right", + "Password": "fas fa-lock", + "FirstName": "far fa-user", + "LastName": "far fa-user", + "DateOfBirth": "far fa-calendar-alt", + "Facebook": "fab fa-facebook-square", + "Google": "fab fa-google", + "Twitter": "fab fa-twitter-square", + "Microsoft": "fab fa-windows", + "OpenIDConnect": "fas fa-arrow-alt-circle-right" + } + ] + }, - // enable developer tools if you want to add javascript and css to pages - "PageEditOptions": { - "AlwaysShowDeveloperLink": false, - "DeveloperAllowedRole": "Administrators", - "ShowDisableEditorOption": true, - "AllowDeleteDefaultPage": false, - "HideUnpublishButton": false - }, - "BlogEditOptions": { - "ForceLowerCaseCategories": false, - "AllowMarkdown": true, - "HideUnpublishButton": false - }, - "ContentLocalizationOptions": { - "UseCultureRoutesAndProjects": false - }, + // enable developer tools if you want to add javascript and css to pages + "PageEditOptions": { + "AlwaysShowDeveloperLink": false, + "DeveloperAllowedRole": "Administrators", + "ShowDisableEditorOption": true, + "AllowDeleteDefaultPage": false, + "HideUnpublishButton": false + }, + "BlogEditOptions": { + "ForceLowerCaseCategories": false, + "AllowMarkdown": true, + "HideUnpublishButton": false + }, + "ContentLocalizationOptions": { + "UseCultureRoutesAndProjects": false + }, - "SimpleContentThemeConfig": { - "ThemeSettings": [ - { - "ThemeName": "default", - "IconSetId": "fontawesome5x", - "NumberOfRecentPostsToShow": 3, - "NumberOfFeaturedPostsToShow": 3 - } - ] - }, + "SimpleContentThemeConfig": { + "ThemeSettings": [ + { + "ThemeName": "default", + "IconSetId": "fontawesome5x", + "NumberOfRecentPostsToShow": 3, + "NumberOfFeaturedPostsToShow": 3 + } + ] + }, - "SimpleContentIconConfig": { - "DefaultSetId": "fontawesome5x", - "IconSets": [ + "SimpleContentIconConfig": { + "DefaultSetId": "fontawesome5x", + "IconSets": [ - { - "SetId": "fontawesome5x", - "Previous": "fas fa-backward", - "Next": "fas fa-forward", - "Comments": "fas fa-comment", - "Tags": "fas fa-hashtag", - "Archives": "far fa-calendar-alt", - "About": "far fa-star", - "BadRequest": "fas fa-ban", - "UnAuthorized": "fas fa-ban", - "Forbidden": "fas fa-exclamation-circle", - "PageNotFound": "fas fa-exclamation-circle", - "Error": "fas fa-exclamation-circle", - "Home": "fas fa-home", - "ShowEditToolbar": "fas fa-pencil-alt", - "NewItem": "fas fa-plus", - "PageTree": "fas fa-tree", - "SortAlpha": "fas fa-sort-alpha-down", - "Edit": "fas fa-pencil-alt", - "View": "fas fa-eye", - "Delete": "far fa-trash-alt", - "Unpublish": "far fa-eye-slash", - "RelatedPosts": "far fa-hand-point-right" + { + "SetId": "fontawesome5x", + "Previous": "fas fa-backward", + "Next": "fas fa-forward", + "Comments": "fas fa-comment", + "Tags": "fas fa-hashtag", + "Archives": "far fa-calendar-alt", + "About": "far fa-star", + "BadRequest": "fas fa-ban", + "UnAuthorized": "fas fa-ban", + "Forbidden": "fas fa-exclamation-circle", + "PageNotFound": "fas fa-exclamation-circle", + "Error": "fas fa-exclamation-circle", + "Home": "fas fa-home", + "ShowEditToolbar": "fas fa-pencil-alt", + "NewItem": "fas fa-plus", + "PageTree": "fas fa-tree", + "SortAlpha": "fas fa-sort-alpha-down", + "Edit": "fas fa-pencil-alt", + "View": "fas fa-eye", + "Delete": "far fa-trash-alt", + "Unpublish": "far fa-eye-slash", + "RelatedPosts": "far fa-hand-point-right" - } - ] - }, - "ContentTemplateSettings": { - "GalleryOptions": { - "NewImagePath": "/media/gallery", - "ResizeMaxWidth": 1500, - "ResizeMaxHeight": 1500, - "KeepOriginalSizeImages": false, - "EnableBrowseServer": true, - "EnableCropping": true, - "CropAreaWidth": 690, - "CropAreaHeight": 517, - "PlaceholderImageUrl": "/cr/images/690x517-placeholder.png" - }, - "LinkListOptions": { - "NewImagePath": "/media/linklists", - "ResizeMaxWidth": 500, - "ResizeMaxHeight": 500, - "ImageRenderMaxHeight": 150, - "KeepOriginalSizeImages": false, - "EnableBrowseServer": true, - "EnableCropping": true, - "CropAreaWidth": 350, - "CropAreaHeight": 250, - "PlaceholderImageUrl": "/cr/images/350x250-placeholder.png" + } + ] }, - "ColumnTemplateOptions": { - "NewImagePath": "/media/images", - "ResizeMaxWidth": 1500, - "ResizeMaxHeight": 1500, - "KeepOriginalSizeImages": false, - "EnableBrowseServer": true, - "EnableCropping": true, - "CropAreaWidth": 690, - "CropAreaHeight": 517, - "PlaceholderImageUrl": "/cr/images/690x517-placeholder.png" - }, - "ImageWithContentOptions": { - "NewImagePath": "/media/images", - "ResizeMaxWidth": 1500, - "ResizeMaxHeight": 1500, - "KeepOriginalSizeImages": false, - "EnableBrowseServer": true, - "EnableCropping": true, - "CropAreaWidth": 690, - "CropAreaHeight": 517, - "PlaceholderImageUrl": "/cr/images/690x517-placeholder.png" - } + "ContentTemplateSettings": { + "GalleryOptions": { + "NewImagePath": "/media/gallery", + "ResizeMaxWidth": 1500, + "ResizeMaxHeight": 1500, + "KeepOriginalSizeImages": false, + "EnableBrowseServer": true, + "EnableCropping": true, + "CropAreaWidth": 690, + "CropAreaHeight": 517, + "PlaceholderImageUrl": "/cr/images/690x517-placeholder.png" + }, + "LinkListOptions": { + "NewImagePath": "/media/linklists", + "ResizeMaxWidth": 500, + "ResizeMaxHeight": 500, + "ImageRenderMaxHeight": 150, + "KeepOriginalSizeImages": false, + "EnableBrowseServer": true, + "EnableCropping": true, + "CropAreaWidth": 350, + "CropAreaHeight": 250, + "PlaceholderImageUrl": "/cr/images/350x250-placeholder.png" + }, + "ColumnTemplateOptions": { + "NewImagePath": "/media/images", + "ResizeMaxWidth": 1500, + "ResizeMaxHeight": 1500, + "KeepOriginalSizeImages": false, + "EnableBrowseServer": true, + "EnableCropping": true, + "CropAreaWidth": 690, + "CropAreaHeight": 517, + "PlaceholderImageUrl": "/cr/images/690x517-placeholder.png" + }, + "ImageWithContentOptions": { + "NewImagePath": "/media/images", + "ResizeMaxWidth": 1500, + "ResizeMaxHeight": 1500, + "KeepOriginalSizeImages": false, + "EnableBrowseServer": true, + "EnableCropping": true, + "CropAreaWidth": 690, + "CropAreaHeight": 517, + "PlaceholderImageUrl": "/cr/images/690x517-placeholder.png" + } - }, + }, - "AutomaticUploadOptions": { - "WebSizeImageMaxWidth": 690, - "WebSizeImageMaxHeight": 690, - "ThumbnailImageMaxWidth": 300, - "ThumbnailImageMaxHeight": 300, - "ResizeMaxAllowedWidth": 2560, - "ResizeMaxAllowedHeight": 2560 - }, - "GoogleAnalyticsOptions": { - "TrackUserId": "true", - "UserIdDimensionIndex": "1", - "RegisteredUserDimensionIndex": "2", - "LoginRegisterSourceDimenstionIndex": "3", - "RegisterSuccessMetricIndex": "1", - "RegisterFailMetricIndex": "2", - "RegisterSubmitMetricIndex": "3", - "LoginSuccessMetricIndex": "4", - "LoginFailMetricIndex": "5", - "LoginSubmitMetricIndex": "6", - "LoginRegisterEventCategory": "Login and Registration", - "LoginSuccessEventAction": "Login Success", - "LoginFailEventAction": "Login Fail", - "LoginSubmitEventAction": "Login Submit", - "RegisterSuccessEventAction": "Register Success", - "RegisterFailEventAction": "Register Fail", - "RegisterSubmitEventAction": "Register Submit" + "AutomaticUploadOptions": { + "WebSizeImageMaxWidth": 690, + "WebSizeImageMaxHeight": 690, + "ThumbnailImageMaxWidth": 300, + "ThumbnailImageMaxHeight": 300, + "ResizeMaxAllowedWidth": 2560, + "ResizeMaxAllowedHeight": 2560 + }, + "GoogleAnalyticsOptions": { + "TrackUserId": "true", + "UserIdDimensionIndex": "1", + "RegisteredUserDimensionIndex": "2", + "LoginRegisterSourceDimenstionIndex": "3", + "RegisterSuccessMetricIndex": "1", + "RegisterFailMetricIndex": "2", + "RegisterSubmitMetricIndex": "3", + "LoginSuccessMetricIndex": "4", + "LoginFailMetricIndex": "5", + "LoginSubmitMetricIndex": "6", + "LoginRegisterEventCategory": "Login and Registration", + "LoginSuccessEventAction": "Login Success", + "LoginFailEventAction": "Login Fail", + "LoginSubmitEventAction": "Login Submit", + "RegisterSuccessEventAction": "Register Success", + "RegisterFailEventAction": "Register Fail", + "RegisterSubmitEventAction": "Register Submit" - }, - "DbLoggerConfig": { - "DevLogLevel": "Debug", - "ProductionLogLevel": "Warning", - "ExcludedNamesSpaces": [ - "SaasKit.Multitenancy" - ], - "BelowWarningExcludedNamesSpaces": [ - "Microsoft.AspNetCore.StaticFiles", - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Authorization", - "Microsoft.AspNetCore.Mvc.Internal" - ] - }, - "Logging": { - "IncludeScopes": false, - "Debug": { - "LogLevel": { - "Default": "Warning" - } }, - "Console": { - "LogLevel": { - "Default": "Warning" - } + "DbLoggerConfig": { + "DevLogLevel": "Debug", + "ProductionLogLevel": "Warning", + "ExcludedNamesSpaces": [ + "SaasKit.Multitenancy" + ], + "BelowWarningExcludedNamesSpaces": [ + "Microsoft.AspNetCore.StaticFiles", + "Microsoft.AspNetCore.Hosting", + "Microsoft.AspNetCore.Authorization", + "Microsoft.AspNetCore.Mvc.Internal" + ] + }, + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning" + } + } } - } } diff --git a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/NetworkOnlyUrlProvider.cs b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/NetworkOnlyUrlProvider.cs index f3a5341..2873997 100644 --- a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/NetworkOnlyUrlProvider.cs +++ b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/NetworkOnlyUrlProvider.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Routing; +using Microsoft.Extensions.Options; using System.Collections.Generic; using System.Threading.Tasks; @@ -15,13 +16,15 @@ public NetworkOnlyUrlProvider( NavigationTreeBuilderService siteMapTreeBuilder, IEnumerable permissionResolvers, IUrlHelperFactory urlHelperFactory, - IActionContextAccessor actionContextAccesor + IActionContextAccessor actionContextAccesor, + IOptions optionsAccessor ) { - _siteMapTreeBuilder = siteMapTreeBuilder; - _permissionResolvers = permissionResolvers; - _urlHelperFactory = urlHelperFactory; + _siteMapTreeBuilder = siteMapTreeBuilder; + _permissionResolvers = permissionResolvers; + _urlHelperFactory = urlHelperFactory; _actionContextAccesor = actionContextAccesor; + _options = optionsAccessor.Value; _networkOnlyControllers = new List() { @@ -37,13 +40,13 @@ IActionContextAccessor actionContextAccesor "ContentHistory" }; - } - private readonly NavigationTreeBuilderService _siteMapTreeBuilder; + private readonly NavigationTreeBuilderService _siteMapTreeBuilder; private readonly IEnumerable _permissionResolvers; - private readonly IUrlHelperFactory _urlHelperFactory; - private readonly IActionContextAccessor _actionContextAccesor; + private readonly IUrlHelperFactory _urlHelperFactory; + private readonly IActionContextAccessor _actionContextAccesor; + private readonly PwaNetworkOnlyUrlOptions _options; private List _networkOnlyControllers; @@ -57,12 +60,22 @@ public async Task> GetNetworkOnlyUrls(PwaOptions options, HttpConte "/pwa/topnav" }; + // Network Only from json config + if (_options?.Urls != null) + { + foreach (var url in _options.Urls) + { + if(!result.Contains(url)) + result.Add(url); + } + } + if (!context.User.Identity.IsAuthenticated) { - //admin pages won't be in the menu anyway so just return empty list + //admin pages won't be in the menu anyway so just return what we have so far return result; } - + var rootNode = await _siteMapTreeBuilder.GetTree(); var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccesor.ActionContext); @@ -75,13 +88,10 @@ public async Task> GetNetworkOnlyUrls(PwaOptions options, HttpConte var url = ResolveUrl(navNode, urlHelper); result.Add(url); } - } - } return result; - } private string ResolveUrl(NavigationNode node, IUrlHelper urlHelper) @@ -113,7 +123,6 @@ private async Task WouldRenderNode(NavigationNode node) { //if (node.Controller == "Account") return false; - TreeNode treeNode = new TreeNode(node); foreach (var permission in _permissionResolvers) { @@ -137,10 +146,6 @@ private bool ShouldBeNetworkOnly(NavigationNode node) } return include; - - } - - } } diff --git a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/PwaNetworkOnlyUrlOptions.cs b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/PwaNetworkOnlyUrlOptions.cs new file mode 100644 index 0000000..a79067a --- /dev/null +++ b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/PwaNetworkOnlyUrlOptions.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace cloudscribe.PwaKit.Integration.CloudscribeCore +{ + public class PwaNetworkOnlyUrlOptions + { + /// + /// a list of urls that result in the page being regarded as network only - never cached + /// + public PwaNetworkOnlyUrlOptions() + { + Urls = new List(); + } + + public List Urls { get; set; } + } +} diff --git a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/StartupExtensions.cs b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/StartupExtensions.cs index 78db1ec..7b278e5 100644 --- a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/StartupExtensions.cs +++ b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/StartupExtensions.cs @@ -35,6 +35,7 @@ public static PwaBuilder MakeCloudscribeAdminPagesNetworkOnly(this PwaBuilder bu public static PwaBuilder PreCacheContentFiles(this PwaBuilder builder) { builder.Services.Configure(builder.Configuration.GetSection("PwaContentFilesPreCacheOptions")); + builder.Services.Configure(builder.Configuration.GetSection("PwaNetworkOnlyUrlOptions")); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/cloudscribe.PwaKit.Integration.CloudscribeCore.csproj b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/cloudscribe.PwaKit.Integration.CloudscribeCore.csproj index ba838f3..a03b41e 100644 --- a/src/cloudscribe.PwaKit.Integration.CloudscribeCore/cloudscribe.PwaKit.Integration.CloudscribeCore.csproj +++ b/src/cloudscribe.PwaKit.Integration.CloudscribeCore/cloudscribe.PwaKit.Integration.CloudscribeCore.csproj @@ -2,7 +2,7 @@ Integration between cloudscribe.Core and cloudscribe.PwaKit - 6.0.1 + 6.0.2 net6.0 Joe Audette true