This commit is contained in:
2026-05-17 20:54:09 -04:00
parent 6da2183583
commit 74c21ee5cc
3000 changed files with 11794 additions and 15301 deletions

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,35 +1,120 @@
@using Microsoft.Extensions.Options
@using Microsoft.EntityFrameworkCore
@using Microsoft.Extensions.Caching.Memory
@using Microsoft.Extensions.Options
@using OpenArchival.Blazor.Components.CustomComponents
@using OpenArchival.Blazor.Config;
@using OpenArchival.Blazor.Blog
@using OpenArchival.Blazor.ArchiveDisplay
@page "/"
<PageTitle>Home</PageTitle>
@if (string.IsNullOrEmpty(_htmlContent))
<style>
.banner-container {
position: relative;
width: calc(100% + 32px);
margin-left: -16px;
margin-right: -16px;
margin-top: -16px;
overflow: hidden;
}
.banner-container img {
width: 100% !important;
height: auto !important;
display: block;
}
.floating-buttons {
position: absolute;
bottom: 24px;
left: 0;
right: 0;
z-index: 10;
}
@@media (max-width: 600px) {
.floating-buttons {
position: static;
padding-top: 16px;
padding-bottom: 16px;
}
}
</style>
@if (_homePageConfig is null)
{
<p>Loading content...</p>
}
else
{
@((MarkupString)_htmlContent)
@if (_homePageConfig.HomePageBanner is not null)
{
<div class="banner-container">
<MudImage
ObjectPosition=ObjectPosition.Center
Src=@($"/api/files/{_homePageConfig.HomePageBanner.Id}/large")></MudImage>
<div class="floating-buttons">
<HomePageButtons></HomePageButtons>
</div>
</div>
<MudDivider></MudDivider>
}
else
{
<HomePageButtons></HomePageButtons>
}
@if (!string.IsNullOrEmpty(_homePageConfig.Content)) {
// Uses a custom CSS class to force the content to the width of the page regardless of what is in it
// ql-editor class tells the quill css that it should apply its classes in this div. Quill is used by the rich text editor this
// project uses
<div class="dynamic-content-container ql-editor">
@((MarkupString)_homePageConfig.Content)
</div>
}
<LatestBlogPostsSlider />
@if (_homePageConfig.SliderEntries != null)
{
@foreach (var sliderEntry in _homePageConfig.SliderEntries)
{
<SearchPageSlider SliderEntry="sliderEntry" />
}
}
}
@inject IOptions<ApplicationOptions> AppOptions;
@inject IMemoryCache MemoryCache;
@inject IDbContextFactory<ApplicationDbContext> ContextFactory;
@code {
private string _htmlContent = $"<h1>HTML file not found for homepage. Create one at /admin/homepageeditor</h1>";
private HomePageConfiguration? _homePageConfig = null;
protected override async void OnInitialized()
protected override async Task OnInitializedAsync()
{
try
_homePageConfig = await MemoryCache.GetOrCreateAsync(OpenArchivalConstants.HomePageConfigurationCacheKey, async entry =>
{
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>";
}
await using var context = await ContextFactory.CreateDbContextAsync();
HomePageConfiguration? config = await context.HomePageConfiguration
.Include(conf=>conf.HomePageBanner)
.Include(conf=>conf.SliderEntries)
.ThenInclude(se => se.FilterTags)
.FirstOrDefaultAsync();
if (config is null)
{
return new HomePageConfiguration() { Content = "Failed to load HomePageConfiguration from the database!" };
}
return config;
});
StateHasChanged();
}
}

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);
}
}