oliverbooth.dev/OliverBooth/Pages/Blog/Index.cshtml

95 lines
3.2 KiB
Plaintext
Raw Permalink Normal View History

@page
2024-02-23 03:23:57 +00:00
@using Humanizer
2024-02-23 05:36:31 +00:00
@using OliverBooth.Data.Mastodon
2024-02-23 03:23:57 +00:00
@using OliverBooth.Services
@model Index
2024-02-23 03:23:57 +00:00
@inject IMastodonService MastodonService
@{
ViewData["Title"] = "Blog";
2024-02-23 05:36:31 +00:00
MastodonStatus latestStatus = MastodonService.GetLatestStatus();
2024-02-29 18:59:30 +00:00
bool doAprilFools = DateOnly.FromDateTime(DateTime.UtcNow) == new DateOnly(2024, 04, 01) || Environment.GetEnvironmentVariable("DO_AF") == "1";
}
2024-02-29 18:59:30 +00:00
@if (doAprilFools)
{
<h1>UNDER CONSTRUCTION</h1>
<div style="text-align: center">
<img src="~/img/construction_90x85.gif">
<img src="~/img/underconstruction_323x118.gif">
<img src="~/img/construction_90x85.gif">
<p>Coming soon WATCH THIS SPACE</p>
</div>
}
else
{
<div class="card text-center mastodon-update-card">
<div class="card-body">
@Html.Raw(latestStatus.Content)
@foreach (MediaAttachment attachment in latestStatus.MediaAttachments)
2024-02-23 05:36:31 +00:00
{
2024-02-29 18:59:30 +00:00
switch (attachment.Type)
{
case AttachmentType.Audio:
<p><audio controls="controls" src="@attachment.Url"></audio></p>
break;
2024-02-23 05:36:31 +00:00
2024-02-29 18:59:30 +00:00
case AttachmentType.Video:
<p><video controls="controls" class="figure-img img-fluid" src="@attachment.Url"></video></p>
break;
2024-02-23 05:36:31 +00:00
2024-02-29 18:59:30 +00:00
case AttachmentType.Image:
case AttachmentType.GifV:
<p><img class="figure-img img-fluid" src="@attachment.Url"></p>
break;
}
2024-02-23 05:36:31 +00:00
}
2024-02-29 18:59:30 +00:00
</div>
<div class="card-footer text-muted">
<abbr title="@latestStatus.CreatedAt.ToString("F")">@latestStatus.CreatedAt.Humanize()</abbr>
&bull;
<a href="@latestStatus.OriginalUri" target="_blank">View on Mastodon</a>
</div>
2024-02-23 03:23:57 +00:00
</div>
2024-02-29 18:59:30 +00:00
<div id="all-blog-posts">
@await Html.PartialAsync("_LoadingSpinner")
</div>
2024-02-29 18:59:30 +00:00
<script id="blog-post-template" type="text/x-handlebars-template">
<div class="card-header">
<span class="text-muted">
<img class="blog-author-icon" src="{{author.avatar}}" alt="{{author.name}}">
<span>{{author.name}}<span>
<span> &bull; </span>
2024-02-29 18:59:30 +00:00
<abbr title="{{ post.formattedDate }}">{{ post.date_humanized }}</abbr>
{{#if post.enable_comments}}
<span> &bull; </span>
<a href="{{post.url}}#disqus_thread" data-disqus-identifier="{{post.disqus_identifier}}">
Loading comment count &hellip;
</a>
{{/if}}
</span>
</div>
<div class="card-body">
<h2>
<a href="{{post.url}}"> {{post.title}}</a>
</h2>
2024-02-29 18:59:30 +00:00
<p>{{{post.excerpt}}}</p>
2024-02-29 18:59:30 +00:00
{{#if post.trimmed}}
<p>
<a href="{{post.url}}">
Read more...
</a>
</p>
{{/if}}
</div>
<div class="card-footer">
{{#each post.tags}}
<a href="?tag={{urlEncode this}}" class="badge text-bg-dark">{{this}}</a>
{{/each}}
</div>
</script>
}