refactor: move Mastodon status to partial
This commit is contained in:
parent
2ec2c0befc
commit
435cae95db
@ -1,49 +1,12 @@
|
|||||||
@page
|
@page
|
||||||
@using Humanizer
|
|
||||||
@using OliverBooth.Common.Data.Mastodon
|
|
||||||
@using OliverBooth.Common.Services
|
@using OliverBooth.Common.Services
|
||||||
@model Index
|
@model Index
|
||||||
@inject IMastodonService MastodonService
|
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Blog";
|
ViewData["Title"] = "Blog";
|
||||||
IMastodonStatus latestStatus = MastodonService.GetLatestStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="card text-center mastodon-update-card">
|
@await Html.PartialAsync("Partials/_MastodonStatus")
|
||||||
<div class="card-body">
|
|
||||||
@Html.Raw(latestStatus.Content)
|
|
||||||
@foreach (MediaAttachment attachment in latestStatus.MediaAttachments)
|
|
||||||
{
|
|
||||||
switch (attachment.Type)
|
|
||||||
{
|
|
||||||
case AttachmentType.Audio:
|
|
||||||
<p>
|
|
||||||
<audio controls="controls" src="@attachment.Url"></audio>
|
|
||||||
</p>
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AttachmentType.Video:
|
|
||||||
<p>
|
|
||||||
<video controls="controls" class="figure-img img-fluid" src="@attachment.Url"></video>
|
|
||||||
</p>
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AttachmentType.Image:
|
|
||||||
case AttachmentType.GifV:
|
|
||||||
<p>
|
|
||||||
<img class="figure-img img-fluid" src="@attachment.Url">
|
|
||||||
</p>
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="card-footer text-muted">
|
|
||||||
<abbr title="@latestStatus.CreatedAt.ToString("F")">@latestStatus.CreatedAt.Humanize()</abbr>
|
|
||||||
•
|
|
||||||
<a href="@latestStatus.OriginalUri" target="_blank">View on Mastodon</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="all-blog-posts">
|
<div id="all-blog-posts">
|
||||||
@await Html.PartialAsync("_LoadingSpinner")
|
@await Html.PartialAsync("_LoadingSpinner")
|
||||||
|
42
OliverBooth/Pages/Shared/Partials/_MastodonStatus.cshtml
Normal file
42
OliverBooth/Pages/Shared/Partials/_MastodonStatus.cshtml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@using Humanizer
|
||||||
|
@using OliverBooth.Common.Data.Mastodon
|
||||||
|
@using OliverBooth.Common.Services
|
||||||
|
@inject IMastodonService MastodonService
|
||||||
|
@{
|
||||||
|
IMastodonStatus latestStatus = MastodonService.GetLatestStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="card text-center mastodon-update-card">
|
||||||
|
<div class="card-body">
|
||||||
|
@Html.Raw(latestStatus.Content)
|
||||||
|
@foreach (MediaAttachment attachment in latestStatus.MediaAttachments)
|
||||||
|
{
|
||||||
|
switch (attachment.Type)
|
||||||
|
{
|
||||||
|
case AttachmentType.Audio:
|
||||||
|
<p>
|
||||||
|
<audio controls="controls" src="@attachment.Url"></audio>
|
||||||
|
</p>
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AttachmentType.Video:
|
||||||
|
<p>
|
||||||
|
<video controls="controls" class="figure-img img-fluid" src="@attachment.Url"></video>
|
||||||
|
</p>
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AttachmentType.Image:
|
||||||
|
case AttachmentType.GifV:
|
||||||
|
<p>
|
||||||
|
<img class="figure-img img-fluid" src="@attachment.Url">
|
||||||
|
</p>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-muted">
|
||||||
|
<abbr title="@latestStatus.CreatedAt.ToString("F")">@latestStatus.CreatedAt.Humanize()</abbr>
|
||||||
|
•
|
||||||
|
<a href="@latestStatus.OriginalUri" target="_blank">View on Mastodon</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user