From 435cae95db4639cdfedcd6a6a01afd5b6e3d6a49 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 5 May 2024 13:48:01 +0100 Subject: [PATCH] refactor: move Mastodon status to partial --- OliverBooth/Pages/Blog/Index.cshtml | 39 +---------------- .../Shared/Partials/_MastodonStatus.cshtml | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 OliverBooth/Pages/Shared/Partials/_MastodonStatus.cshtml diff --git a/OliverBooth/Pages/Blog/Index.cshtml b/OliverBooth/Pages/Blog/Index.cshtml index 23024e7..248464f 100644 --- a/OliverBooth/Pages/Blog/Index.cshtml +++ b/OliverBooth/Pages/Blog/Index.cshtml @@ -1,49 +1,12 @@ @page -@using Humanizer -@using OliverBooth.Common.Data.Mastodon @using OliverBooth.Common.Services @model Index -@inject IMastodonService MastodonService @{ ViewData["Title"] = "Blog"; - IMastodonStatus latestStatus = MastodonService.GetLatestStatus(); } -
-
- @Html.Raw(latestStatus.Content) - @foreach (MediaAttachment attachment in latestStatus.MediaAttachments) - { - switch (attachment.Type) - { - case AttachmentType.Audio: -

- -

- break; - - case AttachmentType.Video: -

- -

- break; - - case AttachmentType.Image: - case AttachmentType.GifV: -

- -

- break; - } - } -
- -
+@await Html.PartialAsync("Partials/_MastodonStatus")
@await Html.PartialAsync("_LoadingSpinner") diff --git a/OliverBooth/Pages/Shared/Partials/_MastodonStatus.cshtml b/OliverBooth/Pages/Shared/Partials/_MastodonStatus.cshtml new file mode 100644 index 0000000..0a309ad --- /dev/null +++ b/OliverBooth/Pages/Shared/Partials/_MastodonStatus.cshtml @@ -0,0 +1,42 @@ +@using Humanizer +@using OliverBooth.Common.Data.Mastodon +@using OliverBooth.Common.Services +@inject IMastodonService MastodonService +@{ + IMastodonStatus latestStatus = MastodonService.GetLatestStatus(); +} + +
+
+ @Html.Raw(latestStatus.Content) + @foreach (MediaAttachment attachment in latestStatus.MediaAttachments) + { + switch (attachment.Type) + { + case AttachmentType.Audio: +

+ +

+ break; + + case AttachmentType.Video: +

+ +

+ break; + + case AttachmentType.Image: + case AttachmentType.GifV: +

+ +

+ break; + } + } +
+ +