@page "/notes/{id}"
@using Iceshrimp.Backend.Core.Database.Tables
@using Iceshrimp.Backend.Core.Extensions
@model Iceshrimp.Backend.Pages.NoteModel
@if (Model.Note == null)
{
Response.StatusCode = 404;
Not found
This note either doesn't exist or is only accessible to authenticated users
}
else
{
async Task RenderNote(string name, Note note)
{
Model.TextContent.TryGetValue(note.Id, out var textContent);
var acct = "@" + note.User.Username + (note.User.Host == null ? "" : "@" + note.User.Host);
var displayName = note.User.DisplayName;
var username = note.User.Username;
@name by @(displayName ?? username)
@acct
Published at: @note.CreatedAt.ToDisplayString()
@if (note.UpdatedAt != null)
{
Edited at: @note.UpdatedAt.Value.ToDisplayString()
}
if (textContent != null)
{
@if (note.Cw != null)
{
@note.Cw
@Html.Raw(textContent)
}
else
{
@Html.Raw(textContent)
}
}
if (!Model.MediaAttachments.TryGetValue(note.Id, out var files)) return;
@foreach (var file in files)
{
if (file.Type.StartsWith("image/"))
{
}
else if (file.Type.StartsWith("video/"))
{
@(file.Comment ?? "No alt text.")
}
else
{
}
}
}
async Task RenderQuoteUrl(string url)
{
var displayUrl = url.StartsWith("https://") ? url[8..] : url[7..];
This post is quoting @displayUrl , but that post either has been deleted or is not publicly visible.
}
ViewData["title"] = $"Note by @{Model.Note.User.Username} - Iceshrimp.NET";
@section head
{
@if (Model.Note.Cw != null)
{
}
else
{
}
@if (Model.MediaAttachments.TryGetValue(Model.Note.Id, out var attachments))
{
if (attachments.Any(p => p.Type.StartsWith("image/")))
{
}
}
}
@{
await RenderNote("Note", Model.Note);
if (Model.Note.Renote != null)
await RenderNote("Quote", Model.Note.Renote);
else if (Model.QuoteUrl != null)
await RenderQuoteUrl(Model.QuoteUrl);
}
}