From 93df8755ac65429cc105cd1a411516658ab5b7c5 Mon Sep 17 00:00:00 2001 From: pancakes Date: Sat, 29 Mar 2025 14:24:26 +1000 Subject: [PATCH] [backend/razor] Add instance icon and banner to home page --- Iceshrimp.Backend/Pages/Index.cshtml | 16 +++++++++++++--- Iceshrimp.Backend/Pages/Index.cshtml.cs | 4 ++++ Iceshrimp.Backend/Pages/Index.cshtml.css | 24 +++++++++++++++++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Iceshrimp.Backend/Pages/Index.cshtml b/Iceshrimp.Backend/Pages/Index.cshtml index aa5c23c1..cc9b7f3e 100644 --- a/Iceshrimp.Backend/Pages/Index.cshtml +++ b/Iceshrimp.Backend/Pages/Index.cshtml @@ -3,8 +3,6 @@ @* ReSharper disable Html.PathError *@ @{ ViewData["title"] = $"Home - {Model.InstanceName}"; - - //TODO: logo / banner & favicon } @section head @@ -16,11 +14,23 @@ }
-

@Model.InstanceName

+ + @if (Model.IconUrl != null) + { + icon + } +

@Model.InstanceName

+
Iceshrimp
+ +@if (Model.BannerUrl != null) +{ + +} +

@Model.InstanceDescription

@if (Model.Rules.Count != 0) diff --git a/Iceshrimp.Backend/Pages/Index.cshtml.cs b/Iceshrimp.Backend/Pages/Index.cshtml.cs index a1460bc8..46d716e0 100644 --- a/Iceshrimp.Backend/Pages/Index.cshtml.cs +++ b/Iceshrimp.Backend/Pages/Index.cshtml.cs @@ -13,6 +13,8 @@ public class IndexModel(MetaService meta, InstanceService instance, IOptionsSnap public string? ContactEmail; public string InstanceDescription = null!; public string InstanceName = null!; + public string? IconUrl; + public string? BannerUrl; public List Rules = []; public async Task OnGet() @@ -32,6 +34,8 @@ public class IndexModel(MetaService meta, InstanceService instance, IOptionsSnap instanceDescription ?? "This Iceshrimp.NET instance does not appear to have a description"; ContactEmail = contactEmail; + (IconUrl, BannerUrl) = await instance.GetInstanceImageAsync(); + Rules = await instance.GetRulesAsync(); return Page(); diff --git a/Iceshrimp.Backend/Pages/Index.cshtml.css b/Iceshrimp.Backend/Pages/Index.cshtml.css index 12ac784e..ecd49efe 100644 --- a/Iceshrimp.Backend/Pages/Index.cshtml.css +++ b/Iceshrimp.Backend/Pages/Index.cshtml.css @@ -8,12 +8,34 @@ gap: 0 12px; } -.header>h1 { +.header span { + display: inline-flex; + align-items: center; + gap: 0.5rem; +} + +.header h1 { margin: 0; } +.header .icon { + width: 3rem; + height: 3rem; + border-radius: 8px; + line-height: 1; +} + .header>.wordmark { width: 160px; line-height: 0; padding-bottom: 4px; +} + +.banner { + display: block; + width: 100%; + height: auto; + object-fit: cover; + aspect-ratio: 21/9; + border-radius: 1rem; } \ No newline at end of file