diff --git a/OliverBooth/Data/IMastodonStatus.cs b/OliverBooth/Data/IMastodonStatus.cs deleted file mode 100644 index 0ef875d..0000000 --- a/OliverBooth/Data/IMastodonStatus.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace OliverBooth.Data; - -public interface IMastodonStatus -{ - /// - /// Gets the content of the status. - /// - /// The content. - string Content { get; } - - /// - /// Gets the date and time at which this status was posted. - /// - /// The post timestamp. - DateTimeOffset CreatedAt { get; } - - /// - /// Gets the original URI of the status. - /// - /// The original URI. - Uri OriginalUri { get; } -} \ No newline at end of file diff --git a/OliverBooth/Data/Mastodon/AttachmentType.cs b/OliverBooth/Data/Mastodon/AttachmentType.cs new file mode 100644 index 0000000..6d0b5e1 --- /dev/null +++ b/OliverBooth/Data/Mastodon/AttachmentType.cs @@ -0,0 +1,10 @@ +namespace OliverBooth.Data.Mastodon; + +public enum AttachmentType +{ + Unknown, + Image, + GifV, + Video, + Audio +} diff --git a/OliverBooth/Data/Mastodon/MastodonStatus.cs b/OliverBooth/Data/Mastodon/MastodonStatus.cs new file mode 100644 index 0000000..a4d3ebf --- /dev/null +++ b/OliverBooth/Data/Mastodon/MastodonStatus.cs @@ -0,0 +1,34 @@ +using System.Text.Json.Serialization; + +namespace OliverBooth.Data.Mastodon; + +public sealed class MastodonStatus +{ + /// + /// Gets the content of the status. + /// + /// The content. + [JsonPropertyName("content")] + public string Content { get; set; } = string.Empty; + + /// + /// Gets the date and time at which this status was posted. + /// + /// The post timestamp. + [JsonPropertyName("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + /// + /// Gets the media attachments for this status. + /// + /// The media attachments. + [JsonPropertyName("media_attachments")] + public IReadOnlyList MediaAttachments { get; set; } = ArraySegment.Empty; + + /// + /// Gets the original URI of the status. + /// + /// The original URI. + [JsonPropertyName("url")] + public Uri OriginalUri { get; set; } = null!; +} diff --git a/OliverBooth/Data/Mastodon/MediaAttachment.cs b/OliverBooth/Data/Mastodon/MediaAttachment.cs new file mode 100644 index 0000000..ddc3307 --- /dev/null +++ b/OliverBooth/Data/Mastodon/MediaAttachment.cs @@ -0,0 +1,22 @@ +namespace OliverBooth.Data.Mastodon; + +public sealed class MediaAttachment +{ + /// + /// Gets the preview URL of the attachment. + /// + /// The preview URL. + public Uri PreviewUrl { get; set; } = null!; + + /// + /// Gets the type of this attachment. + /// + /// The attachment type. + public AttachmentType Type { get; set; } = AttachmentType.Unknown; + + /// + /// Gets the URL of the attachment. + /// + /// The URL. + public Uri Url { get; set; } = null!; +} \ No newline at end of file diff --git a/OliverBooth/Data/MastodonStatus.cs b/OliverBooth/Data/MastodonStatus.cs deleted file mode 100644 index bb02662..0000000 --- a/OliverBooth/Data/MastodonStatus.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.Json.Serialization; - -namespace OliverBooth.Data; - -internal sealed class MastodonStatus : IMastodonStatus -{ - /// - [JsonPropertyName("content")] - public string Content { get; set; } = string.Empty; - - /// - [JsonPropertyName("created_at")] - public DateTimeOffset CreatedAt { get; set; } - - /// - [JsonPropertyName("url")] - public Uri OriginalUri { get; set; } = null!; -} diff --git a/OliverBooth/Pages/Blog/Index.cshtml b/OliverBooth/Pages/Blog/Index.cshtml index 6d7d37b..1109038 100644 --- a/OliverBooth/Pages/Blog/Index.cshtml +++ b/OliverBooth/Pages/Blog/Index.cshtml @@ -1,18 +1,36 @@ @page @using Humanizer -@using OliverBooth.Data +@using OliverBooth.Data.Mastodon @using OliverBooth.Services @model Index @inject IMastodonService MastodonService @{ ViewData["Title"] = "Blog"; - IMastodonStatus latestStatus = MastodonService.GetLatestStatus(); + MastodonStatus 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; + } + }