From 23d39506955040fc849396595cef22d7254c8f1e Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 5 May 2024 21:10:23 +0100 Subject: [PATCH] chore: add launchSettings.json to make development not suck This workflow allows the possibility to reload a changed page without reloading the entire app. I hate launchSettings.json, but whatever. --- OliverBooth/OliverBooth.csproj | 1 - OliverBooth/Program.cs | 2 +- OliverBooth/Properties/launchSettings.json | 30 ++++++++++++++++++++++ OliverBooth/Services/MastodonService.cs | 8 +++--- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 OliverBooth/Properties/launchSettings.json diff --git a/OliverBooth/OliverBooth.csproj b/OliverBooth/OliverBooth.csproj index 521bc81..f822f33 100644 --- a/OliverBooth/OliverBooth.csproj +++ b/OliverBooth/OliverBooth.csproj @@ -33,7 +33,6 @@ - diff --git a/OliverBooth/Program.cs b/OliverBooth/Program.cs index 2017340..472e602 100644 --- a/OliverBooth/Program.cs +++ b/OliverBooth/Program.cs @@ -69,7 +69,7 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddRazorPages().AddRazorRuntimeCompilation(); +builder.Services.AddRazorPages(); builder.Services.AddControllersWithViews(); builder.Services.AddRouting(options => options.LowercaseUrls = true); builder.Services.AddReCaptcha(builder.Configuration.GetSection("ReCaptcha")); diff --git a/OliverBooth/Properties/launchSettings.json b/OliverBooth/Properties/launchSettings.json new file mode 100644 index 0000000..3012f63 --- /dev/null +++ b/OliverBooth/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5000", + "sslPort": 2845 + } + }, + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "workingDirectory": "bin/Debug/net8.0/", + "applicationUrl": "https://localhost:2845", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/OliverBooth/Services/MastodonService.cs b/OliverBooth/Services/MastodonService.cs index b169e2b..1e4c9d3 100644 --- a/OliverBooth/Services/MastodonService.cs +++ b/OliverBooth/Services/MastodonService.cs @@ -15,18 +15,20 @@ internal sealed class MastodonService : IMastodonService PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower }; + private readonly IConfiguration _configuration; private readonly HttpClient _httpClient; - public MastodonService(HttpClient httpClient) + public MastodonService(IConfiguration configuration, HttpClient httpClient) { + _configuration = configuration; _httpClient = httpClient; } /// public IMastodonStatus GetLatestStatus() { - string token = Environment.GetEnvironmentVariable("MASTODON_TOKEN") ?? string.Empty; - string account = Environment.GetEnvironmentVariable("MASTODON_ACCOUNT") ?? string.Empty; + string token = _configuration.GetSection("Mastodon:Token").Value ?? string.Empty; + string account = _configuration.GetSection("Mastodon:Account").Value ?? string.Empty; using var request = new HttpRequestMessage(); request.Headers.Add("Authorization", $"Bearer {token}"); request.RequestUri = new Uri($"https://mastodon.olivr.me/api/v1/accounts/{account}/statuses");