@page "/notes/{id}"
@using AngleSharp
@using Iceshrimp.Backend.Core.Database.Tables
@using Iceshrimp.Backend.Core.Extensions
@model NoteModel
@section styles
{
}
@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.IsLocalUser ? "" : "@" + note.User.Host);
var displayName = await RenderDisplayName(note.User.DisplayName ?? note.User.Username);
var url = note.User.UserProfile?.Url ?? note.User.Uri ?? note.User.GetPublicUrl(Model.WebDomain);
var avatarUrl = note.User.AvatarUrl == null || !Model.ShowMedia ? note.User.IdenticonUrlPath : note.User.AvatarUrl;
@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;
if (!Model.ShowMedia)
{
This post has attachments, but this server's configuration prevents them from being displayed here.
return;
}
@foreach (var file in files)
{
if (file.Type.StartsWith("image/"))
{
}
else if (file.Type.StartsWith("video/"))
{
}
else
{
}
}
return;
async Task RenderDisplayName(string input)
{
var res = Html.Encode(input);
var emojis = Model.UserEmoji[note.User.Id];
if (emojis is []) return res;
var context = BrowsingContext.New();
var document = await context.OpenNewAsync();
foreach (var emoji in emojis)
{
var el = document.CreateElement("span");
var inner = document.CreateElement("img");
inner.SetAttribute("src", emoji.PublicUrl);
el.AppendChild(inner);
el.ClassList.Add("emoji");
res = res.Replace($":{emoji.Name.Trim(':')}:", el.OuterHtml);
}
return res;
}
}
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} - {Model.InstanceName}";
@section head
{
@{
Model.MediaAttachments.TryGetValue(Model.Note.Id, out var attachments);
}
@if (Model.Note.Cw != null)
{
}
else
{
var text = Model.Note.Text;
if (attachments is { Count: > 0 })
{
var attachmentText = $"({attachments.Count} attachments)";
if (string.IsNullOrWhiteSpace(text))
text = attachmentText;
else
text += $"\n{attachmentText}";
}
}
@if (Model.ShowMedia && attachments != null)
{
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);
}
if (!Model.ShowRemoteReplies)
{
This server's configuration is preventing remotely originating content from being shown. This view may therefore be incomplete.
}
}