diff --git a/CustomAuthenticationStateProvider.cs b/Classes/CustomAuthenticationStateProvider.cs similarity index 100% rename from CustomAuthenticationStateProvider.cs rename to Classes/CustomAuthenticationStateProvider.cs diff --git a/NavigatorService.cs b/Classes/NavigatorService.cs similarity index 100% rename from NavigatorService.cs rename to Classes/NavigatorService.cs diff --git a/RestService.cs b/Classes/RestService.cs similarity index 98% rename from RestService.cs rename to Classes/RestService.cs index 01a5dec..cbbfb8c 100644 --- a/RestService.cs +++ b/Classes/RestService.cs @@ -1,17 +1,15 @@ -using Markdig; -using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Neighbourhood.omg.lol.Models; using System.Diagnostics; -using System.Net; using System.Net.Http.Json; -using System.Reflection; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; -namespace Neighbourhood.omg.lol { - public class RestService { +namespace Neighbourhood.omg.lol +{ + public class RestService { HttpClient _client; JsonSerializerOptions _serializerOptions; public const string BaseUrl = "https://api.omg.lol"; diff --git a/Models/State.cs b/Classes/State.cs similarity index 99% rename from Models/State.cs rename to Classes/State.cs index d3f8934..fceddda 100644 --- a/Models/State.cs +++ b/Classes/State.cs @@ -2,8 +2,9 @@ using System.ComponentModel; using System.Globalization; using System.Text.Json; +using Neighbourhood.omg.lol.Models; -namespace Neighbourhood.omg.lol.Models { +namespace Neighbourhood.omg.lol { public class State : INotifyPropertyChanged { // Feature flags public bool FeatureFollowing { get; } = false; diff --git a/Classes/Utilities.cs b/Classes/Utilities.cs new file mode 100644 index 0000000..496ea60 --- /dev/null +++ b/Classes/Utilities.cs @@ -0,0 +1,56 @@ +using Markdig; +using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Neighbourhood.omg.lol +{ + public static class Utilities + { + + private static MarkdownPipeline markdownPipeline { get; } + = new MarkdownPipelineBuilder().UseAutoLinks().Build(); + + public static string MdToHtml(string markdown) => + Markdown.ToHtml(markdown, markdownPipeline); + + public static MarkupString MdToHtmlMarkup(string markdown) => + (MarkupString)MdToHtml(markdown); + + public static async Task FileSize(FileResult file) + { + using var fileStream = await file.OpenReadAsync(); + return fileStream.Length; + } + + public static async Task Base64FromFile(FileResult file) + { + using var memoryStream = new MemoryStream(); + using var fileStream = await file.OpenReadAsync(); + await fileStream.CopyToAsync(memoryStream); + byte[] bytes = memoryStream.ToArray(); + return Convert.ToBase64String(bytes); + } + + public static string RelativeTimeFromUnix(long unix) + { + DateTimeOffset createdTime = DateTimeOffset.UnixEpoch.AddSeconds(unix); + TimeSpan offset = DateTimeOffset.UtcNow - createdTime; + + var offsetString = string.Empty; + if (Math.Floor(offset.TotalDays) == 1) offsetString = $"{Math.Floor(offset.TotalDays)} day ago"; + else if (offset.TotalDays > 1) offsetString = $"{Math.Floor(offset.TotalDays)} days ago"; + else if (Math.Floor(offset.TotalHours) == 1) offsetString = $"{Math.Floor(offset.TotalHours)} hour ago"; + else if (offset.TotalHours > 1) offsetString = $"{Math.Floor(offset.TotalHours)} hours ago"; + else if (Math.Floor(offset.TotalMinutes) == 1) offsetString = $"{Math.Floor(offset.TotalMinutes)} minute ago"; + else if (offset.TotalMinutes > 1) offsetString = $"{Math.Floor(offset.TotalMinutes)} minutes ago"; + else if (Math.Floor(offset.TotalSeconds) == 1) offsetString = $"{Math.Floor(offset.TotalSeconds)} second ago"; + else offsetString = $"{Math.Floor(offset.TotalSeconds)} seconds ago"; + + return offsetString; + } + } +} diff --git a/EphemeralWebPage.xaml b/EphemeralWebPage.xaml deleted file mode 100644 index 38e17d6..0000000 --- a/EphemeralWebPage.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/EphemeralWebPage.xaml.cs b/EphemeralWebPage.xaml.cs deleted file mode 100644 index 0fabee0..0000000 --- a/EphemeralWebPage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Neighbourhood.omg.lol; - -public partial class EphemeralWebPage : ContentPage -{ - private NavigatorService NavigatorService { get; set; } - - public EphemeralWebPage(NavigatorService navigatorService) - { - this.NavigatorService = navigatorService; - InitializeComponent(); - this.webview.Source = $"https://home.omg.lol/ephemeral"; - } - - public async void webview_Navigating(object sender, WebNavigatingEventArgs e) { - var cookies = this.webview.Cookies; - Uri uri = new Uri(e.Url); - } -} \ No newline at end of file diff --git a/MauiProgram.cs b/MauiProgram.cs index 5202399..b6ff3df 100644 --- a/MauiProgram.cs +++ b/MauiProgram.cs @@ -17,7 +17,6 @@ namespace Neighbourhood.omg.lol { builder.Services.AddMauiBlazorWebView(); builder.Services.AddTransient(); - builder.Services.AddTransient(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -25,12 +24,7 @@ namespace Neighbourhood.omg.lol { //ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); //builder.Services.AddSingleton(configurationBuilder.AddUserSecrets().Build()); - var assembly = Assembly.GetExecutingAssembly(); - var details = assembly.GetName(); - App.Name = details.Name!; - App.Version = details.Version!.ToString(); - var appSettings = $"{App.Name}.appsettings.json"; - using var stream = assembly.GetManifestResourceStream(appSettings); + using Stream stream = App.Assembly.GetManifestResourceStream($"{App.Name}.appsettings.json")!; var config = new ConfigurationBuilder().AddJsonStream(stream).Build(); builder.Configuration.AddConfiguration(config); diff --git a/Models/AccountResponseData.cs b/Models/API/AccountResponseData.cs similarity index 100% rename from Models/AccountResponseData.cs rename to Models/API/AccountResponseData.cs diff --git a/Models/AddressResponseData.cs b/Models/API/AddressResponseData.cs similarity index 100% rename from Models/AddressResponseData.cs rename to Models/API/AddressResponseData.cs diff --git a/Models/AddressResponseList.cs b/Models/API/AddressResponseList.cs similarity index 100% rename from Models/AddressResponseList.cs rename to Models/API/AddressResponseList.cs diff --git a/Models/BasicResponseData.cs b/Models/API/BasicResponseData.cs similarity index 100% rename from Models/BasicResponseData.cs rename to Models/API/BasicResponseData.cs diff --git a/Models/DirectoryResponseData.cs b/Models/API/DirectoryResponseData.cs similarity index 100% rename from Models/DirectoryResponseData.cs rename to Models/API/DirectoryResponseData.cs diff --git a/Models/EphemeralData.cs b/Models/API/EphemeralData.cs similarity index 100% rename from Models/EphemeralData.cs rename to Models/API/EphemeralData.cs diff --git a/Models/EphemeralResponseData.cs b/Models/API/EphemeralResponseData.cs similarity index 100% rename from Models/EphemeralResponseData.cs rename to Models/API/EphemeralResponseData.cs diff --git a/Models/IOmgLolResponseData.cs b/Models/API/IOmgLolResponseData.cs similarity index 100% rename from Models/IOmgLolResponseData.cs rename to Models/API/IOmgLolResponseData.cs diff --git a/Models/IOmgLolResponseList.cs b/Models/API/IOmgLolResponseList.cs similarity index 100% rename from Models/IOmgLolResponseList.cs rename to Models/API/IOmgLolResponseList.cs diff --git a/Models/NowContentData.cs b/Models/API/NowContentData.cs similarity index 100% rename from Models/NowContentData.cs rename to Models/API/NowContentData.cs diff --git a/Models/NowData.cs b/Models/API/NowData.cs similarity index 57% rename from Models/NowData.cs rename to Models/API/NowData.cs index 3975760..1fa2145 100644 --- a/Models/NowData.cs +++ b/Models/API/NowData.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neighbourhood.omg.lol.Models { - public class NowData { +namespace Neighbourhood.omg.lol.Models +{ + public class NowData { public string Address { get; set; } public string Url { get; set; } public TimeData Updated { get; set; } diff --git a/Models/NowPageResponseData.cs b/Models/API/NowPageResponseData.cs similarity index 100% rename from Models/NowPageResponseData.cs rename to Models/API/NowPageResponseData.cs diff --git a/Models/NowResponseData.cs b/Models/API/NowResponseData.cs similarity index 100% rename from Models/NowResponseData.cs rename to Models/API/NowResponseData.cs diff --git a/Models/OmgLolRequestData.cs b/Models/API/OmgLolRequestData.cs similarity index 100% rename from Models/OmgLolRequestData.cs rename to Models/API/OmgLolRequestData.cs diff --git a/Models/OmgLolResponse.cs b/Models/API/OmgLolResponse.cs similarity index 100% rename from Models/OmgLolResponse.cs rename to Models/API/OmgLolResponse.cs diff --git a/Models/PatchStatus.cs b/Models/API/PatchStatus.cs similarity index 100% rename from Models/PatchStatus.cs rename to Models/API/PatchStatus.cs diff --git a/Models/PatchStatusResponseData.cs b/Models/API/PatchStatusResponseData.cs similarity index 100% rename from Models/PatchStatusResponseData.cs rename to Models/API/PatchStatusResponseData.cs diff --git a/Models/PostPic.cs b/Models/API/PostPic.cs similarity index 100% rename from Models/PostPic.cs rename to Models/API/PostPic.cs diff --git a/Models/PutPic.cs b/Models/API/PutPic.cs similarity index 100% rename from Models/PutPic.cs rename to Models/API/PutPic.cs diff --git a/Models/PutPicResponseData.cs b/Models/API/PutPicResponseData.cs similarity index 100% rename from Models/PutPicResponseData.cs rename to Models/API/PutPicResponseData.cs diff --git a/Models/SomePicsResponseData.cs b/Models/API/SomePicsResponseData.cs similarity index 100% rename from Models/SomePicsResponseData.cs rename to Models/API/SomePicsResponseData.cs diff --git a/Models/StatusBioResponseData.cs b/Models/API/StatusBioResponseData.cs similarity index 100% rename from Models/StatusBioResponseData.cs rename to Models/API/StatusBioResponseData.cs diff --git a/Models/StatusPost.cs b/Models/API/StatusPost.cs similarity index 100% rename from Models/StatusPost.cs rename to Models/API/StatusPost.cs diff --git a/Models/StatusPostResponseData.cs b/Models/API/StatusPostResponseData.cs similarity index 100% rename from Models/StatusPostResponseData.cs rename to Models/API/StatusPostResponseData.cs diff --git a/Models/StatusResponseData.cs b/Models/API/StatusResponseData.cs similarity index 100% rename from Models/StatusResponseData.cs rename to Models/API/StatusResponseData.cs diff --git a/Models/TokenResponseData.cs b/Models/API/TokenResponseData.cs similarity index 100% rename from Models/TokenResponseData.cs rename to Models/API/TokenResponseData.cs diff --git a/Models/Pic.cs b/Models/Pic.cs index dd40e0e..db68493 100644 --- a/Models/Pic.cs +++ b/Models/Pic.cs @@ -1,15 +1,9 @@ -using Markdig; -using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Serialization; -using System.Threading.Tasks; -namespace Neighbourhood.omg.lol.Models { - public class Pic { +namespace Neighbourhood.omg.lol.Models +{ + public class Pic { public string Id { get; set; } public string Url { get; set; } public string Address { get; set; } diff --git a/Models/Status.cs b/Models/Status.cs index 8e1297e..fa314f7 100644 --- a/Models/Status.cs +++ b/Models/Status.cs @@ -1,8 +1,8 @@ -using Markdig; -using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components; -namespace Neighbourhood.omg.lol.Models { - public class Status { +namespace Neighbourhood.omg.lol.Models +{ + public class Status { public string Id { get; set; } public string Address { get; set; } public string Created { get; set; } diff --git a/Models/Utilities.cs b/Models/Utilities.cs deleted file mode 100644 index a5e10e8..0000000 --- a/Models/Utilities.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Markdig; -using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Neighbourhood.omg.lol { - public static class Utilities { - - private static MarkdownPipeline markdownPipeline { get; } - = new MarkdownPipelineBuilder().UseAutoLinks().Build(); - - public static string MdToHtml(string markdown) => - Markdown.ToHtml(markdown, markdownPipeline); - - public static MarkupString MdToHtmlMarkup(string markdown) => - (MarkupString)MdToHtml(markdown); - - public static async Task FileSize(FileResult file) { - using var fileStream = await file.OpenReadAsync(); - return fileStream.Length; - } - - public static async Task Base64FromFile(FileResult file) { - using var memoryStream = new MemoryStream(); - using var fileStream = await file.OpenReadAsync(); - await fileStream.CopyToAsync(memoryStream); - byte[] bytes = memoryStream.ToArray(); - return Convert.ToBase64String(bytes); - } - - public static string RelativeTimeFromUnix(long unix) { - DateTimeOffset createdTime = DateTimeOffset.UnixEpoch.AddSeconds(unix); - TimeSpan offset = DateTimeOffset.UtcNow - createdTime; - - var offsetString = string.Empty; - if (Math.Floor(offset.TotalDays) == 1) offsetString = $"{Math.Floor(offset.TotalDays)} day ago"; - else if (offset.TotalDays > 1) offsetString = $"{Math.Floor(offset.TotalDays)} days ago"; - else if (Math.Floor(offset.TotalHours) == 1) offsetString = $"{Math.Floor(offset.TotalHours)} hour ago"; - else if (offset.TotalHours > 1) offsetString = $"{Math.Floor(offset.TotalHours)} hours ago"; - else if (Math.Floor(offset.TotalMinutes) == 1) offsetString = $"{Math.Floor(offset.TotalMinutes)} minute ago"; - else if (offset.TotalMinutes > 1) offsetString = $"{Math.Floor(offset.TotalMinutes)} minutes ago"; - else if (Math.Floor(offset.TotalSeconds) == 1) offsetString = $"{Math.Floor(offset.TotalSeconds)} second ago"; - else offsetString = $"{Math.Floor(offset.TotalSeconds)} seconds ago"; - - return offsetString; - } - } -} diff --git a/Neighbourhood.omg.lol.csproj b/Neighbourhood.omg.lol.csproj index ebfe3fa..a9946ae 100644 --- a/Neighbourhood.omg.lol.csproj +++ b/Neighbourhood.omg.lol.csproj @@ -241,13 +241,10 @@ - + MSBuild:Compile - - MSBuild:Compile - - + MSBuild:Compile diff --git a/App.xaml b/XamlComponents/App.xaml similarity index 100% rename from App.xaml rename to XamlComponents/App.xaml diff --git a/App.xaml.cs b/XamlComponents/App.xaml.cs similarity index 65% rename from App.xaml.cs rename to XamlComponents/App.xaml.cs index 147c72f..c8f0e75 100644 --- a/App.xaml.cs +++ b/XamlComponents/App.xaml.cs @@ -1,13 +1,15 @@ -namespace Neighbourhood.omg.lol { +using System.Reflection; + +namespace Neighbourhood.omg.lol { public partial class App : Application { - public static string Name { get; set; } - public static string Version { get; set; } + public static Assembly Assembly { get; } = Assembly.GetExecutingAssembly(); + public static string Name { get; } = App.Assembly.GetName().Name!; + public static string Version { get; } = App.Assembly.GetName().Version!.ToString(); public App(NavigatorService navigatorService) { InitializeComponent(); - //MainPage = new AppShell(); NavigatorService = navigatorService; } diff --git a/AppShell.xaml b/XamlComponents/AppShell.xaml similarity index 100% rename from AppShell.xaml rename to XamlComponents/AppShell.xaml diff --git a/AppShell.xaml.cs b/XamlComponents/AppShell.xaml.cs similarity index 72% rename from AppShell.xaml.cs rename to XamlComponents/AppShell.xaml.cs index 6276b06..c07ae1e 100644 --- a/AppShell.xaml.cs +++ b/XamlComponents/AppShell.xaml.cs @@ -7,6 +7,5 @@ public partial class AppShell : Shell InitializeComponent(); Routing.RegisterRoute(nameof(LoginWebViewPage), typeof(LoginWebViewPage)); - Routing.RegisterRoute(nameof(EphemeralWebPage), typeof(EphemeralWebPage)); } } \ No newline at end of file diff --git a/LoginWebViewPage.xaml b/XamlComponents/LoginWebViewPage.xaml similarity index 100% rename from LoginWebViewPage.xaml rename to XamlComponents/LoginWebViewPage.xaml diff --git a/LoginWebViewPage.xaml.cs b/XamlComponents/LoginWebViewPage.xaml.cs similarity index 97% rename from LoginWebViewPage.xaml.cs rename to XamlComponents/LoginWebViewPage.xaml.cs index 7cec6ca..95ea2ee 100644 --- a/LoginWebViewPage.xaml.cs +++ b/XamlComponents/LoginWebViewPage.xaml.cs @@ -1,6 +1,4 @@ -using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -using System.Diagnostics; using System.Web; using Microsoft.Extensions.Configuration; diff --git a/MainPage.xaml b/XamlComponents/MainPage.xaml similarity index 100% rename from MainPage.xaml rename to XamlComponents/MainPage.xaml diff --git a/MainPage.xaml.cs b/XamlComponents/MainPage.xaml.cs similarity index 72% rename from MainPage.xaml.cs rename to XamlComponents/MainPage.xaml.cs index 5df0b19..99ffa16 100644 --- a/MainPage.xaml.cs +++ b/XamlComponents/MainPage.xaml.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.WebView; -using Microsoft.AspNetCore.Components.WebView.Maui; -using System.Diagnostics; +using Microsoft.AspNetCore.Components.WebView; namespace Neighbourhood.omg.lol { public partial class MainPage : ContentPage {