diff --git a/.gitattributes b/.gitattributes index 176a458..883fcc0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,5 @@ * text=auto + +# Enforce Windows newlines for C# files to avoid false positives with IDE0055 warning. +# See https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/issues/106 for more information. +*.cs text eol=crlf diff --git a/Lombiq.BaseTheme.Samples/Lombiq.BaseTheme.Samples.csproj b/Lombiq.BaseTheme.Samples/Lombiq.BaseTheme.Samples.csproj index c89b195..c8091ff 100644 --- a/Lombiq.BaseTheme.Samples/Lombiq.BaseTheme.Samples.csproj +++ b/Lombiq.BaseTheme.Samples/Lombiq.BaseTheme.Samples.csproj @@ -4,7 +4,6 @@ net6.0 true $(DefaultItemExcludes);.git*;node_modules\**;Tests\** - enable enable diff --git a/Lombiq.BaseTheme.Samples/Services/ResourceFilters.cs b/Lombiq.BaseTheme.Samples/Services/ResourceFilters.cs index fd22256..8ab75bf 100644 --- a/Lombiq.BaseTheme.Samples/Services/ResourceFilters.cs +++ b/Lombiq.BaseTheme.Samples/Services/ResourceFilters.cs @@ -4,13 +4,16 @@ namespace Lombiq.DataTables.Samples.Navigation; // This service implements conditional configuration to direct the ResourceFilterMiddleware when and what styles need to -// be added to the resources. +// be added to the resources. The attribute indicates that the middleware should only invoke this provider if the +// current admin or site theme is equal to the one in the attribute constructor. +[ResourceFilterThemeRequirement(FeatureIds.BaseThemeSamples)] public class ResourceFilters : IResourceFilterProvider { public void AddResourceFilter(ResourceFilterBuilder builder) { - // We always want to add the site style. If you only have "Always" styles then it's easier to inject them via - // the Views/Widget-LayoutInjection.cshtml file and skip using a ResourceFilterMiddleware. + // We always want to add the site style. If you only have "Always" styles and you are going to override + // Views/Widget-LayoutInjection.cshtml anyway, then it's easier to inject your style there and skip using a + // ResourceFilterMiddleware altogether. builder.Always().RegisterStylesheet(ResourceNames.Site); builder.WhenContentType("BlogPost").RegisterStylesheet(ResourceNames.BlogPost); } diff --git a/Lombiq.BaseTheme.Samples/Startup.cs b/Lombiq.BaseTheme.Samples/Startup.cs index c365d36..7dd2b94 100644 --- a/Lombiq.BaseTheme.Samples/Startup.cs +++ b/Lombiq.BaseTheme.Samples/Startup.cs @@ -7,6 +7,8 @@ using OrchardCore.Modules; using OrchardCore.Navigation; using OrchardCore.ResourceManagement; +using System; +using System.Threading.Tasks; using static Lombiq.BaseTheme.Samples.Constants.FeatureIds; namespace Lombiq.BaseTheme.Samples; diff --git a/Lombiq.BaseTheme.Samples/wwwroot/Theme.png b/Lombiq.BaseTheme.Samples/wwwroot/Theme.png new file mode 100644 index 0000000..cafe457 Binary files /dev/null and b/Lombiq.BaseTheme.Samples/wwwroot/Theme.png differ diff --git a/Lombiq.BaseTheme.Tests.UI/Lombiq.BaseTheme.Tests.UI.csproj b/Lombiq.BaseTheme.Tests.UI/Lombiq.BaseTheme.Tests.UI.csproj index 9920cf3..60fd827 100644 --- a/Lombiq.BaseTheme.Tests.UI/Lombiq.BaseTheme.Tests.UI.csproj +++ b/Lombiq.BaseTheme.Tests.UI/Lombiq.BaseTheme.Tests.UI.csproj @@ -25,7 +25,7 @@ - + diff --git a/Lombiq.BaseTheme/Lombiq.BaseTheme.csproj b/Lombiq.BaseTheme/Lombiq.BaseTheme.csproj index 26a7da9..fca5ca1 100644 --- a/Lombiq.BaseTheme/Lombiq.BaseTheme.csproj +++ b/Lombiq.BaseTheme/Lombiq.BaseTheme.csproj @@ -44,10 +44,11 @@ + - + diff --git a/Lombiq.BaseTheme/Services/ResourceFilters.cs b/Lombiq.BaseTheme/Services/ResourceFilters.cs new file mode 100644 index 0000000..1870dea --- /dev/null +++ b/Lombiq.BaseTheme/Services/ResourceFilters.cs @@ -0,0 +1,11 @@ +using Lombiq.BaseTheme.Constants; +using Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement; + +namespace Lombiq.DataTables.Navigation; + +[ResourceFilterThemeRequirement(FeatureIds.BaseTheme)] +public class ResourceFilters : IResourceFilterProvider +{ + public void AddResourceFilter(ResourceFilterBuilder builder) => + builder.Always().RegisterStylesheet(ResourceNames.Site); +} diff --git a/Lombiq.BaseTheme/Startup.cs b/Lombiq.BaseTheme/Startup.cs index acf9500..d455ae2 100644 --- a/Lombiq.BaseTheme/Startup.cs +++ b/Lombiq.BaseTheme/Startup.cs @@ -1,5 +1,7 @@ using Lombiq.BaseTheme.Migrations; using Lombiq.BaseTheme.Services; +using Lombiq.DataTables.Navigation; +using Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; @@ -18,5 +20,7 @@ public override void ConfigureServices(IServiceCollection services) services.Configure(options => options.Filters.Add(typeof(MainMenuWidgetFilter))); services.AddScoped(); + + services.AddScoped(); } } diff --git a/Lombiq.BaseTheme/wwwroot/Theme.png b/Lombiq.BaseTheme/wwwroot/Theme.png new file mode 100644 index 0000000..3e38021 Binary files /dev/null and b/Lombiq.BaseTheme/wwwroot/Theme.png differ