Added Customization for AppName

Currently used as prefix for page titles
This commit is contained in:
Mia Rose Winter 2024-01-18 13:44:39 +01:00
parent 638820e7dc
commit 76183c17a2
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
9 changed files with 65 additions and 34 deletions

View file

@ -7,36 +7,36 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" /> <base href="/" />
<link rel="stylesheet" href="app.css" /> <link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="/css/main.min.css" /> <link rel="stylesheet" href="/css/main.min.css" />
<link rel="stylesheet" href="Wave.styles.css" /> <link rel="stylesheet" href="Wave.styles.css" />
<!-- #region favicon + manifest --> <!-- #region favicon + manifest -->
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json"> <link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> <meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff"> <meta name="theme-color" content="#ffffff">
<!-- #endregion --> <!-- #endregion -->
<HeadOutlet /> <HeadOutlet />
</head> </head>
<body> <body>
<Routes /> <Routes />
<script src="_framework/blazor.web.js"></script> <script src="_framework/blazor.web.js"></script>
</body> </body>
</html> </html>

View file

@ -12,6 +12,9 @@
@inject UserManager<ApplicationUser> UserManager @inject UserManager<ApplicationUser> UserManager
@inject SignInManager<ApplicationUser> SignInManager @inject SignInManager<ApplicationUser> SignInManager
@inject IdentityRedirectManager RedirectManager @inject IdentityRedirectManager RedirectManager
@inject IStringLocalizer<Admin> Localizer
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<StatusMessage Message="@Message" /> <StatusMessage Message="@Message" />
@ -34,6 +37,9 @@
</EditForm> </EditForm>
@code { @code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[CascadingParameter] [CascadingParameter]
private HttpContext HttpContext { get; set; } = default!; private HttpContext HttpContext { get; set; } = default!;
private ApplicationUser User { get; set; } = default!; private ApplicationUser User { get; set; } = default!;

View file

@ -15,9 +15,9 @@
@inject IStringLocalizer<ArticleEditor> Localizer @inject IStringLocalizer<ArticleEditor> Localizer
@if (Article is not null) { @if (Article is not null) {
<PageTitle>@Localizer["PageTitle_Edit"] - @Article.Title</PageTitle> <PageTitle>@(TitlePrefix + Localizer["PageTitle_Edit"]) | @Article.Title</PageTitle>
} else { } else {
<PageTitle>@Localizer["PageTitle_New"]</PageTitle> <PageTitle>@(TitlePrefix + Localizer["PageTitle_New"])</PageTitle>
} }
<h1 class="text-3xl lg:text-5xl font-light mb-6">@Localizer["EditorTitle"]</h1> <h1 class="text-3xl lg:text-5xl font-light mb-6">@Localizer["EditorTitle"]</h1>
@ -61,6 +61,9 @@
} }
@code { @code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[Parameter] [Parameter]
public Guid? Id { get; set; } public Guid? Id { get; set; }
[SupplyParameterFromForm] [SupplyParameterFromForm]

View file

@ -7,7 +7,7 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory; @inject IDbContextFactory<ApplicationDbContext> ContextFactory;
@inject IStringLocalizer<ArticleView> Localizer @inject IStringLocalizer<ArticleView> Localizer
<PageTitle>Wave - @Article.Title</PageTitle> <PageTitle>@(TitlePrefix + Article.Title)</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light">@Article.Title</h1> <h1 class="text-3xl lg:text-5xl font-light">@Article.Title</h1>
<p class="mb-3"> <p class="mb-3">
@ -66,6 +66,9 @@
@code { @code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
[Parameter] [Parameter]
public Guid Id { get; set; } public Guid Id { get; set; }

View file

@ -8,7 +8,7 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory; @inject IDbContextFactory<ApplicationDbContext> ContextFactory;
@inject IStringLocalizer<Home> Localizer @inject IStringLocalizer<Home> Localizer
<PageTitle>@Localizer["Title"]</PageTitle> <PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-3">@Localizer["Title"]</h1> <h1 class="text-3xl lg:text-5xl font-light mb-3">@Localizer["Title"]</h1>
@ -54,6 +54,9 @@
} }
@code { @code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
private List<Article> Articles { get; } = []; private List<Article> Articles { get; } = [];
private bool HasMore { get; set; } private bool HasMore { get; set; }

View file

@ -3,13 +3,13 @@
@using Microsoft.AspNetCore.Identity @using Microsoft.AspNetCore.Identity
@using Wave.Data @using Wave.Data
@rendermode @(new InteractiveServerRenderMode(false)) @rendermode InteractiveServer
@attribute [Authorize(Policy = "RoleAssignPermissions")] @attribute [Authorize(Policy = "RoleAssignPermissions")]
@attribute [StreamRendering] @attribute [StreamRendering]
@inject UserManager<ApplicationUser> UserManager @inject UserManager<ApplicationUser> UserManager
@inject IStringLocalizer<ManageUsers> Localizer @inject IStringLocalizer<ManageUsers> Localizer
<PageTitle>@Localizer["Title"]</PageTitle> <PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>
<h1 class="text-3xl lg:text-5xl font-light mb-6">@Localizer["Title"]</h1> <h1 class="text-3xl lg:text-5xl font-light mb-6">@Localizer["Title"]</h1>
@ -41,6 +41,9 @@
<ToastComponent @ref="Toast" /> <ToastComponent @ref="Toast" />
@code { @code {
[CascadingParameter(Name = "TitlePrefix")]
private string TitlePrefix { get; set; } = default!;
public ToastComponent Toast { get; set; } = null!; public ToastComponent Toast { get; set; } = null!;
private IList<ApplicationUser> Authors { get; set; } = new List<ApplicationUser>(); private IList<ApplicationUser> Authors { get; set; } = new List<ApplicationUser>();
@ -49,10 +52,11 @@
private IList<ApplicationUser> Admins { get; set; } = new List<ApplicationUser>(); private IList<ApplicationUser> Admins { get; set; } = new List<ApplicationUser>();
[CascadingParameter] [CascadingParameter]
private Task<AuthenticationState>? AuthenticationState { get; set; } private Task<AuthenticationState> AuthenticationState { get; set; } = default!;
private ApplicationUser? User { get; set; } private ApplicationUser? User { get; set; }
protected override async Task OnInitializedAsync() { protected override async Task OnAfterRenderAsync(bool firstRender) {
if (!firstRender) return;
var state = await AuthenticationState; var state = await AuthenticationState;
User = await UserManager.GetUserAsync(state.User); User = await UserManager.GetUserAsync(state.User);

View file

@ -0,0 +1,5 @@
namespace Wave.Data;
public class Customization {
public string AppName { get; set; } = "Wave";
}

View file

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components.Server; using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Wave.Components; using Wave.Components;
using Wave.Components.Account; using Wave.Components.Account;
using Wave.Data; using Wave.Data;
@ -62,6 +63,10 @@
}); });
builder.Services.AddScoped<ImageService>(); builder.Services.AddScoped<ImageService>();
builder.Services.Configure<Customization>(builder.Configuration.GetSection(nameof(Customization)));
builder.Services.AddCascadingValue("TitlePrefix",
sf => (sf.GetService<IOptions<Customization>>()?.Value.AppName ?? "Wave") + " - ");
#endregion #endregion
var app = builder.Build(); var app = builder.Build();

View file

@ -19,6 +19,8 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
</ItemGroup> </ItemGroup>