💄 Optimize hosted page index

This commit is contained in:
2025-11-22 14:16:40 +08:00
parent f4505d2ecc
commit ef02265ccd
8 changed files with 484 additions and 181 deletions

View File

@@ -0,0 +1,89 @@
@using DysonNetwork.Shared.Models
@model DysonNetwork.Shared.Models.SnPost
<div class="card bg-base-200 shadow-md">
<div class="card-body flex flex-col gap-5">
<div>
@if (!string.IsNullOrWhiteSpace(Model.Title) || !string.IsNullOrWhiteSpace(Model.Description))
{
<section class="mb-1">
@if (!string.IsNullOrWhiteSpace(Model.Title))
{
<h2 class="text-lg font-bold">
<a asp-page="/Posts/Details"
asp-route-slug="@(Model.Slug ?? Model.Id.ToString())">@Model.Title</a>
</h2>
}
@if (!string.IsNullOrWhiteSpace(Model.Description))
{
<p>@Model.Description</p>
}
</section>
}
<p>@Html.Raw(Model.Content)</p>
</div>
@if (Model.Attachments.Any())
{
<div class="flex flex-col gap-4">
@foreach (var attachment in Model.Attachments)
{
<div>
@if (attachment.MimeType!.StartsWith("image"))
{
<figure>
<img src="/drive/files/@attachment.Id" alt="@attachment.Name"
class="max-w-full h-auto rounded-lg"/>
</figure>
}
else if (attachment.MimeType!.StartsWith("video"))
{
<video controls src="/drive/files/@attachment.Id"
class="max-w-full h-auto rounded-lg"></video>
}
else if (attachment.MimeType!.StartsWith("audio"))
{
<audio controls src="/drive/files/@attachment.Id"
class="max-w-full h-auto rounded-lg"></audio>
}
else
{
<a href="/drive/files/@attachment.Id" target="_blank"
class="text-blue-500 hover:underline">@attachment.Name</a>
}
</div>
}
</div>
}
@if (Model.Categories.Any() || Model.Tags.Any())
{
<div>
@foreach (var category in Model.Categories)
{
<span class="badge badge-primary">
<span class="mdi mdi-shape"></span>
@(!string.IsNullOrEmpty(category.Name) ? category.Name : category.Slug)
</span>
}
@foreach (var tag in Model.Tags)
{
<span class="badge badge-info">
<span class="mdi mdi-tag"></span>
@(!string.IsNullOrEmpty(tag.Name) ? tag.Name : tag.Slug)
</span>
}
</div>
}
<div class="card-actions justify-end items-center">
<div class="text-sm text-base-content/60">
Posted on @Model.CreatedAt.ToDateTimeOffset().ToString("yyyy-MM-dd")
</div>
<a asp-page="/Posts/Details" asp-route-slug="@(Model.Slug ?? Model.Id.ToString())"
class="btn btn-sm btn-ghost btn-circle">
<span class="mdi mdi-arrow-right text-lg"></span>
</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,36 @@
@using DysonNetwork.Shared.Models
@model DysonNetwork.Shared.Models.SnPublisher
@{
const string defaultAvatar = "https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp";
}
<div class="card bg-base-200 shadow-md">
@if (Model.Background != null)
{
<figure class="relative">
<img
src="/drive/files/@Model.Background.Id"
alt="Background"/>
</figure>
}
<div class="card-body">
<div class="flex gap-4 card-title">
<div class="avatar">
<div class="w-16 rounded-full">
<img
src="@(Model.Picture is null ? defaultAvatar : "/drive/files/" + Model.Picture!.Id)"
alt="Avatar"/>
</div>
</div>
<h2 class="flex-1 flex flex-col">
@Model.Nick
<span class="text-xs">@@@Model.Name</span>
</h2>
</div>
@if (!string.IsNullOrWhiteSpace(Model.Bio))
{
<p>@Model.Bio</p>
}
</div>
</div>

View File

@@ -0,0 +1,58 @@
@using DysonNetwork.Shared.Models
@model DysonNetwork.Shared.Models.SnPublicationSite
<div class="flex flex-col md:flex-row gap-6">
<div class="flex flex-col gap-4 flex-1">
<div class="card bg-base-100 border">
<div class="card-body">
<h3 class="card-title"><span class="mdi mdi-home"></span> Info</h3>
<div class="space-y-2">
<div class="flex justify-between">
<span class="flex gap-2">
<span class="mdi mdi-label"></span>
Name
</span>
<span class="text-right">@Model.Name</span>
</div>
</div>
<div class="space-y-2">
<div class="flex justify-between">
<span class="flex gap-2">
<span class="mdi mdi-tag"></span>
Slug
</span>
<span class="text-right font-mono">@Model.Slug</span>
</div>
</div>
</div>
</div>
</div>
<div class="flex flex-col gap-4 flex-1">
@if (!string.IsNullOrEmpty(Model.Description))
{
<div class="flex-1">
<div class="card bg-base-100 border">
<div class="card-body">
<h3 class="card-title">
<span class="mdi mdi-information"></span> Description
</h3>
<div class="prose prose-sm max-w-none">
@Model.Description
</div>
</div>
</div>
</div>
}
<div class="flex-1">
<div class="flex flex-col p-5 opacity-80 text-sm">
<p>Proudly powered by the Solar Network Pages</p>
<p>Hosted on the Solar Network</p>
<p class="mt-2">Network powered by Cloudflare</p>
<p>Therefore, if the site is down, 99% is Cloudflare's fault</p>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,70 @@
@model DysonNetwork.Zone.Pages.IndexModel
@if (Model.UserAccount != null)
{
<div class="card bg-base-100 border">
<div class="card-body">
<div class="flex items-center gap-6 mb-8">
@if (!string.IsNullOrEmpty(Model.UserPictureUrl))
{
<img src="@Model.UserPictureUrl" class="w-20 h-20 rounded-full object-cover" alt="Avatar"/>
}
else
{
<div class="w-20 h-20 rounded-full bg-gray-300 flex items-center justify-center">
<span class="text-2xl">@(Model.UserAccount.Name != null ? Model.UserAccount.Name[0] : '?')</span>
</div>
}
<div>
<div class="text-2xl font-bold">
@(Model.UserAccount.Nick ?? Model.UserAccount.Name)
</div>
<div class="text-body-2 text-base-content/60">@@@Model.UserAccount.Name</div>
</div>
</div>
<div class="space-y-2">
@if (!string.IsNullOrEmpty(Model.UserAccount.Profile?.TimeZone))
{
<div class="flex justify-between">
<span class="flex gap-2">
<span class="mdi mdi-map-clock"></span>
Time Zone
</span>
<span class="text-right">
@Model.GetCurrentTimeInTimeZone(Model.UserAccount.Profile.TimeZone)
<span class="text-base-content/50">·</span>
@Model.GetOffsetUtcString(Model.UserAccount.Profile.TimeZone)
<span class="text-base-content/50">·</span>
@Model.UserAccount.Profile.TimeZone
</span>
</div>
}
@if (!string.IsNullOrEmpty(Model.UserAccount.Profile?.Location))
{
<div class="flex justify-between">
<span class="flex gap-2">
<span class="mdi mdi-map-marker"></span> Location
</span>
<span>@Model.UserAccount.Profile.Location</span>
</div>
}
@if (!string.IsNullOrEmpty(Model.UserAccount.Profile?.FirstName) || !string.IsNullOrEmpty(Model.UserAccount.Profile?.LastName))
{
<div class="flex justify-between">
<span class="flex gap-2">
<span class="mdi mdi-card-bulleted-outline"></span> Name
</span>
<span>
@string.Join(" ", new[]
{
Model.UserAccount.Profile.FirstName,
Model.UserAccount.Profile.MiddleName,
Model.UserAccount.Profile.LastName
}.Where(s => !string.IsNullOrEmpty(s)))
</span>
</div>
}
</div>
</div>
</div>
}