Updated admin page to be more streamlined and added the beginning of the blogging features

This commit is contained in:
Vincent Allen
2025-10-21 13:32:39 -04:00
parent 0e24ce2073
commit b34449808f
224 changed files with 27064 additions and 396 deletions

View File

@@ -1,4 +1,31 @@
@inherits LayoutComponentBase
@using Microsoft.Extensions.Options
@using OpenArchival.Blazor.Config
@inherits LayoutComponentBase
@*
For the login/logout
<AuthorizeView>
<Authorized>
<MudNavLink Href="Account/Manage" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Person">@context.User.Identity?.Name</MudNavLink>
<form action="Account/Logout" method="post">
<AntiforgeryToken />
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
<button type="submit" class="mud-nav-link mud-ripple">
<MudIcon Icon="@Icons.Material.Filled.Logout" Color="Color.Info" Class="mr-3"></MudIcon> Logout
</button>
</form>
</Authorized>
<NotAuthorized>
<MudNavLink Href="Account/Register" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Person">Register</MudNavLink>
<MudNavLink Href="Account/Login" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Password">Login</MudNavLink>
</NotAuthorized>
</AuthorizeView>
*@
@inject IOptions<ApplicationOptions> Options;
@inject NavigationManager NavigationManager;
<MudThemeProvider />
<MudPopoverProvider />
@@ -6,15 +33,57 @@
<MudSnackbarProvider />
<MudLayout>
<MudAppBar Elevation="1">
<MudStaticNavDrawerToggle DrawerId="nav-drawer" Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" />
<MudText Typo="Typo.h5" Class="ml-3">Application</MudText>
<MudSpacer />
<MudIconButton Icon="@Icons.Material.Filled.MoreVert" Color="Color.Inherit" Edge="Edge.End" />
<MudAppBar Elevation="1" >
@if (!string.IsNullOrEmpty(Options.Value.NavBarTitle)) {
<MudNavLink Href="/" Style="max-width:200px;">
<MudText Typo="Typo.h6" Class="ml-3">@Options.Value.NavBarTitle</MudText>
</MudNavLink>
}
<div class="d-flex justify-center align-center">
<MudNavLink
Icon="@Icons.Material.Filled.Home"
IconColor=Color.Secondary
Ripple=true
Style="max-width:200px;"
Href="/search">
Artifacts
</MudNavLink>
@*
<MudNavLink Icon=@Icons.Material.Filled.Book IconColor=Color.Secondary Ripple=true Style="max-width: 200px">
Articles
</MudNavLink>
*@
<MudNavLink Href="/about" Icon=@Icons.Material.Filled.QuestionMark IconColor="Color.Secondary" Ripple=true Style="max-width:200px;">
About
</MudNavLink>
</div>
<MudSpacer></MudSpacer>
<div style="background-color: white; border-radius:10px;" class="pa-2">
<MudAutocomplete
Placeholder="Search Archive"
T="string"
Variant="Variant.Filled | Variant.Outlined"
AdornmentIcon="@Icons.Material.Filled.Search"
Dense=true
Underline=false
Style="width:200px; --mud-input-text: white; --mud-input-label-text: white;"
OnKeyDown="OnSearchBarKeyDown"
@bind-Text=_searchBarText/>
</div>
@*
<MudTextField
Placeholder="Search"
Variant="Variant.Filled"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search"
IconSize="Size.Medium"
T="string">
</MudTextField>*@
</MudAppBar>
<MudDrawer id="nav-drawer" @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="2">
<NavMenu />
</MudDrawer>
<MudMainContent Class="pt-16 pa-4">
@Body
</MudMainContent>
@@ -29,6 +98,16 @@
@code {
private bool _drawerOpen = true;
private string _searchBarText = "";
private void OnSearchBarKeyDown(KeyboardEventArgs args)
{
if (args.Key == "Enter" && !string.IsNullOrEmpty(_searchBarText))
{
NavigationManager.NavigateTo($"/search/{System.Web.HttpUtility.UrlEncode(_searchBarText)}");
_searchBarText = "";
}
}
}

View File

@@ -1,51 +0,0 @@
@implements IDisposable
@inject NavigationManager NavigationManager
<MudNavMenu>
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
<MudNavLink Href="weather" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Weather</MudNavLink>
<MudNavLink Href="auth" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Lock">Auth Required</MudNavLink>
<AuthorizeView>
<Authorized>
<MudNavLink Href="Account/Manage" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Person">@context.User.Identity?.Name</MudNavLink>
<form action="Account/Logout" method="post">
<AntiforgeryToken />
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
<button type="submit" class="mud-nav-link mud-ripple">
<MudIcon Icon="@Icons.Material.Filled.Logout" Color="Color.Info" Class="mr-3"></MudIcon> Logout
</button>
</form>
</Authorized>
<NotAuthorized>
<MudNavLink Href="Account/Register" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Person">Register</MudNavLink>
<MudNavLink Href="Account/Login" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Password">Login</MudNavLink>
</NotAuthorized>
</AuthorizeView>
</MudNavMenu>
@code {
private string? currentUrl;
protected override void OnInitialized()
{
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
NavigationManager.LocationChanged += OnLocationChanged;
}
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
{
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
StateHasChanged();
}
public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
}

View File

@@ -0,0 +1,36 @@
@using Microsoft.Extensions.Options
@using OpenArchival.Blazor.Config;
@page "/about"
<PageTitle>About</PageTitle>
@if (string.IsNullOrEmpty(_htmlContent))
{
<p>Loading content...</p>
}
else
{
@((MarkupString)_htmlContent)
}
@inject IOptions<ApplicationOptions> AppOptions;
@code {
private string _htmlContent = $"<h1>HTML file not found for about page. Create one at /admin/aboutpageeditor</h1>";
protected override async void OnInitialized()
{
try
{
using var reader = new StreamReader(AppOptions.Value.AboutPageContentLocation);
_htmlContent = await reader.ReadToEndAsync();
}
catch (Exception ex)
{
_htmlContent = $"<h1>HTML file not found for homepage. Create one at /admin/aboutpageeditor</h1>";
}
StateHasChanged();
}
}

View File

@@ -1,18 +0,0 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">Counter</MudText>
<MudText Typo="Typo.body1" Class="mb-4">Current count: @currentCount</MudText>
<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="IncrementCount">Click me</MudButton>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}

View File

@@ -1,59 +1,35 @@
@page "/"
@using Microsoft.Extensions.Options
@using OpenArchival.Blazor.Config;
@page "/"
<PageTitle>Home</PageTitle>
@if (string.IsNullOrEmpty(_htmlContent))
{
<p>Loading content...</p>
}
else
{
@((MarkupString)_htmlContent)
}
<MudText Typo="Typo.h3" GutterBottom="true">Hello, world!</MudText>
<MudText Class="mb-8">Welcome to your new app, powered by MudBlazor and the .NET 9 Template!</MudText>
@inject IOptions<ApplicationOptions> AppOptions;
@code {
private string _htmlContent = $"<h1>HTML file not found for homepage. Create one at /admin/homepageeditor</h1>";
<MudAlert Severity="Severity.Normal" ContentAlignment="HorizontalAlignment.Start">
You can find documentation and examples on our website here:
<MudLink Href="https://mudblazor.com" Target="_blank" Typo="Typo.body2" Color="Color.Primary">
<b>www.mudblazor.com</b>
</MudLink>
</MudAlert>
protected override async void OnInitialized()
{
try
{
using var reader = new StreamReader(AppOptions.Value.HomepageContentLocation);
_htmlContent = await reader.ReadToEndAsync();
}
catch (Exception ex)
{
_htmlContent = $"<h1>HTML file not found for homepage. Create one at /admin/homepageeditor</h1>";
}
<br />
<MudText Typo="Typo.h5" GutterBottom="true">Interactivity in this Template</MudText>
<br />
<MudText Typo="Typo.body2">
When you opt for the "Global" Interactivity Location, <br />
the render modes are defined in App.razor and consequently apply to all child components.<br />
In this case, providers are globally set in the MainLayout.<br />
<br />
On the other hand, if you choose the "Per page/component" Interactivity Location,<br />
it is necessary to include the <br />
<br />
&lt;MudPopoverProvider /&gt; <br />
&lt;MudDialogProvider /&gt; <br />
&lt;MudSnackbarProvider /&gt; <br />
<br />
components on every interactive page.<br />
<br />
If a render mode is not specified for a page, it defaults to Server-Side Rendering (SSR),<br />
similar to this page. While MudBlazor allows pages to be rendered in SSR,<br />
please note that interactive features, such as buttons and dropdown menus, will not be functional.
</MudText>
StateHasChanged();
}
<br />
<MudText Typo="Typo.h5" GutterBottom="true">What's New in Blazor with the Release of .NET 9</MudText>
<br />
<MudText Typo="Typo.h6" GutterBottom="true">Prerendering</MudText>
<MudText Typo="Typo.body2" GutterBottom="true">
If you're exploring the features of .NET 9 Blazor,<br /> you might be pleasantly surprised to learn that each page is prerendered on the server,<br /> regardless of the selected render mode.<br /><br />
This means that you'll need to inject all necessary services on the server,<br /> even when opting for the wasm (WebAssembly) render mode.<br /><br />
This prerendering functionality is crucial to ensuring that WebAssembly mode feels fast and responsive,<br /> especially when it comes to initial page load times.<br /><br />
For more information on how to detect prerendering and leverage the RenderContext, you can refer to the following link:
<MudLink Href="https://github.com/dotnet/aspnetcore/issues/51468#issuecomment-1783568121" Target="_blank" Typo="Typo.body2" Color="Color.Primary">
More details
</MudLink>
</MudText>
<br />
<MudText Typo="Typo.h6" GutterBottom="true">InteractiveAuto</MudText>
<MudText Typo="Typo.body2">
A discussion on how to achieve this can be found here:
<MudLink Href="https://github.com/dotnet/aspnetcore/issues/51468#issue-1950424116" Target="_blank" Typo="Typo.body2" Color="Color.Primary">
More details
</MudLink>
</MudText>
}

View File

@@ -1,60 +0,0 @@
@page "/weather"
<PageTitle>Weather</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">Weather forecast</MudText>
<MudText Typo="Typo.body1" Class="mb-8">This component demonstrates fetching data from the server.</MudText>
@if (forecasts == null)
{
<MudProgressCircular Color="Color.Default" Indeterminate="true" />
}
else
{
<MudTable Items="forecasts" Hover="true" SortLabel="Sort By" Elevation="0" AllowUnsorted="false">
<HeaderContent>
<MudTh><MudTableSortLabel InitialDirection="SortDirection.Ascending" SortBy="new Func<WeatherForecast, object>(x=>x.Date)">Date</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.TemperatureC)">Temp. (C)</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.TemperatureF)">Temp. (F)</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<WeatherForecast, object>(x=>x.Summary!)">Summary</MudTableSortLabel></MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Date">@context.Date</MudTd>
<MudTd DataLabel="Temp. (C)">@context.TemperatureC</MudTd>
<MudTd DataLabel="Temp. (F)">@context.TemperatureF</MudTd>
<MudTd DataLabel="Summary">@context.Summary</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager PageSizeOptions="new int[]{50, 100}" />
</PagerContent>
</MudTable>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
// Simulate asynchronous loading to demonstrate a loading indicator
await Task.Delay(500);
var startDate = DateOnly.FromDateTime(DateTime.Now);
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();
}
private class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}

View File

@@ -4,7 +4,10 @@
@using MudBlazor
<Router AppAssembly="typeof(Program).Assembly"
AdditionalAssemblies="new[] {typeof(OpenArchival.Blazor.AdminPages.ArchiveConfiguration).Assembly, typeof(OpenArchival.Blazor.ArtifactGroupingDisplay.ArchiveGroupingDisplay).Assembly, typeof(OpenArchival.Blazor.ArchiveSearch.SearchArchive).Assembly}">
AdditionalAssemblies="new[] {typeof(OpenArchival.Blazor.AdminPages.ArchiveManagement).Assembly,
typeof(OpenArchival.Blazor.ArtifactGroupingDisplay.ArchiveGroupingDisplay).Assembly,
typeof(OpenArchival.Blazor.ArchiveSearch.SearchArchive).Assembly,
typeof(OpenArchival.Blazor.Blog.BlogEditor).Assembly}">
<Found Context="routeData">
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
<NotAuthorized>