diff --git a/OliverBooth.Blog/Pages/_ViewImports.cshtml b/OliverBooth.Blog/Pages/_ViewImports.cshtml deleted file mode 100644 index b7624fb..0000000 --- a/OliverBooth.Blog/Pages/_ViewImports.cshtml +++ /dev/null @@ -1,2 +0,0 @@ -@namespace OliverBooth.Blog.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/OliverBooth.Blog/Pages/_ViewStart.cshtml b/OliverBooth.Blog/Pages/_ViewStart.cshtml deleted file mode 100644 index d641c67..0000000 --- a/OliverBooth.Blog/Pages/_ViewStart.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@{ - Layout = "_Layout"; -} \ No newline at end of file diff --git a/OliverBooth.Blog/Program.cs b/OliverBooth.Blog/Program.cs index 62a0efd..1cc5c43 100644 --- a/OliverBooth.Blog/Program.cs +++ b/OliverBooth.Blog/Program.cs @@ -1,11 +1,13 @@ using OliverBooth.Blog.Data; using OliverBooth.Blog.Middleware; using OliverBooth.Blog.Services; +using OliverBooth.Common; using OliverBooth.Common.Extensions; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Configuration.AddTomlFile("data/config.toml", true, true); +builder.Services.ConfigureOptions(); builder.Services.AddDbContextFactory(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/OliverBooth.Common/OliverBooth.Common.csproj b/OliverBooth.Common/OliverBooth.Common.csproj index 18f7f3d..eaad31a 100644 --- a/OliverBooth.Common/OliverBooth.Common.csproj +++ b/OliverBooth.Common/OliverBooth.Common.csproj @@ -5,6 +5,7 @@ enable enable true + true @@ -17,6 +18,11 @@ + + + + + diff --git a/OliverBooth.Common/OliverBoothConfigureOptions.cs b/OliverBooth.Common/OliverBoothConfigureOptions.cs new file mode 100644 index 0000000..98b7b13 --- /dev/null +++ b/OliverBooth.Common/OliverBoothConfigureOptions.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.StaticFiles; +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Options; + +namespace OliverBooth.Common; + +/// +/// Represents the middleware to configure static file options. +/// +public sealed class OliverBoothConfigureOptions : IPostConfigureOptions +{ + private readonly IWebHostEnvironment _environment; + + /// + /// Initializes a new instance of the class. + /// + /// The . + public OliverBoothConfigureOptions(IWebHostEnvironment environment) + { + _environment = environment; + } + + /// + public void PostConfigure(string? name, StaticFileOptions options) + { + // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract + options.ContentTypeProvider ??= new FileExtensionContentTypeProvider(); + + if (options.FileProvider == null && _environment.WebRootFileProvider == null) + { + throw new InvalidOperationException("Missing FileProvider."); + } + + options.FileProvider ??= _environment.WebRootFileProvider; + + var filesProvider = new ManifestEmbeddedFileProvider(GetType().Assembly, "wwwroot"); + options.FileProvider = new CompositeFileProvider(options.FileProvider, filesProvider); + } +} diff --git a/OliverBooth/Pages/Shared/_Layout.cshtml b/OliverBooth.Common/Pages/Shared/_Layout.cshtml similarity index 89% rename from OliverBooth/Pages/Shared/_Layout.cshtml rename to OliverBooth.Common/Pages/Shared/_Layout.cshtml index 7feedb3..b25510a 100644 --- a/OliverBooth/Pages/Shared/_Layout.cshtml +++ b/OliverBooth.Common/Pages/Shared/_Layout.cshtml @@ -1,3 +1,6 @@ +@{ + string rootUrl = Environment.GetEnvironmentVariable("ROOT_URL") ?? "https://oliverbooth.dev"; +} @@ -12,7 +15,7 @@ { Oliver Booth } - + @@ -21,9 +24,9 @@ - + - +
@@ -36,22 +39,22 @@ diff --git a/OliverBooth/Pages/Shared/_LoadingSpinner.cshtml b/OliverBooth.Common/Pages/Shared/_LoadingSpinner.cshtml similarity index 100% rename from OliverBooth/Pages/Shared/_LoadingSpinner.cshtml rename to OliverBooth.Common/Pages/Shared/_LoadingSpinner.cshtml diff --git a/OliverBooth.Common/Pages/_ViewImports.cshtml b/OliverBooth.Common/Pages/_ViewImports.cshtml new file mode 100644 index 0000000..e0daad2 --- /dev/null +++ b/OliverBooth.Common/Pages/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@namespace OliverBooth.Common.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/OliverBooth/OliverBooth.csproj b/OliverBooth/OliverBooth.csproj index 37d7e68..f09ab46 100644 --- a/OliverBooth/OliverBooth.csproj +++ b/OliverBooth/OliverBooth.csproj @@ -24,7 +24,7 @@ - + diff --git a/OliverBooth/Pages/Shared/_Layout.cshtml.css b/OliverBooth/Pages/Shared/_Layout.cshtml.css deleted file mode 100644 index f45c4ca..0000000 --- a/OliverBooth/Pages/Shared/_Layout.cshtml.css +++ /dev/null @@ -1,48 +0,0 @@ -/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification -for details on configuring this project to bundle and minify static web assets. */ - -a.navbar-brand { - white-space: normal; - text-align: center; - word-break: break-all; -} - -a { - color: #0077cc; -} - -.btn-primary { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; -} - -.nav-pills .nav-link.active, .nav-pills .show > .nav-link { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; -} - -.border-top { - border-top: 1px solid #e5e5e5; -} -.border-bottom { - border-bottom: 1px solid #e5e5e5; -} - -.box-shadow { - box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); -} - -button.accept-policy { - font-size: 1rem; - line-height: inherit; -} - -.footer { - position: absolute; - bottom: 0; - width: 100%; - white-space: nowrap; - line-height: 60px; -}