From e0ad032906e9dfe9a4d4d336ad0b25de77de4475 Mon Sep 17 00:00:00 2001 From: bhenrich Date: Tue, 20 Aug 2024 23:09:16 +0200 Subject: [PATCH 1/6] de --- ReplayBrowser/appsettings.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ReplayBrowser/appsettings.json b/ReplayBrowser/appsettings.json index 1ca6bca..21a06b6 100644 --- a/ReplayBrowser/appsettings.json +++ b/ReplayBrowser/appsettings.json @@ -9,7 +9,7 @@ "ReplayUrls": [ { "url": "http://cdn.harmony14.com:27690/replays/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "harmony", "fallBackServerId": "harmony", "replayRegex": "[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -17,7 +17,7 @@ }, { "url": "https://replays.rouny-ss14.com/replays/alamo/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "alamo", "fallBackServerId": "rmc14", "replayRegex": "(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip", @@ -25,7 +25,7 @@ }, { "url": "https://replays.rouny-ss14.com/replays/normandy/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "rouny_2", "fallBackServerId": "rmc14", "replayRegex": "(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip", @@ -65,7 +65,7 @@ }, { "url": "https://axolotl.yuniiworks.de/replays/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "axolotl", "fallBackServerId": "axolotl", "replayRegex": "^[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -73,7 +73,7 @@ }, { "url": "https://moon.spacestation14.com/replays/leviathan/", - "provider": "caddy", + "provider": "dummy", "fallBackServerName": "leviathan", "fallBackServerId": "wizards", "replayRegex": "[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -81,7 +81,7 @@ }, { "url": "https://moon.spacestation14.com/replays/lizard/", - "provider": "caddy", + "provider": "dummy", "fallBackServerName": "lizard", "fallBackServerId": "wizards", "replayRegex": "[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -89,7 +89,7 @@ }, { "url": "https://moon.spacestation14.com/replays/miros/", - "provider": "caddy", + "provider": "dummy", "fallBackServerName": "miros", "fallBackServerId": "wizards", "replayRegex": "[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -97,7 +97,7 @@ }, { "url": "https://moon.spacestation14.com/replays/salamander/", - "provider": "caddy", + "provider": "dummy", "fallBackServerName": "salamander", "fallBackServerId": "wizards", "replayRegex": "[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -105,7 +105,7 @@ }, { "url": "https://moon.spacestation14.com/replays/vulture/", - "provider": "caddy", + "provider": "dummy", "fallBackServerName": "vulture", "fallBackServerId": "wizards", "replayRegex": "[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -113,7 +113,7 @@ }, { "url": "https://replays.delta-v.org/apoapsis/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "Server 1", "fallBackServerId": "deltav", "replayRegex": "^[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -121,7 +121,7 @@ }, { "url": "https://replays.delta-v.org/periapsis/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "Server 2", "fallBackServerId": "deltav", "replayRegex": "^[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", @@ -129,7 +129,7 @@ }, { "url": "https://replays.delta-v.org/horizon/", - "provider": "nginx", + "provider": "dummy", "fallBackServerName": "Server 3", "fallBackServerId": "deltav", "replayRegex": "^[a-zA-Z0-9-]+-(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip$", From cf85134ad9f8e6c682107be9a1fceece40aa2d57 Mon Sep 17 00:00:00 2001 From: bhenrich Date: Wed, 21 Aug 2024 02:00:40 +0200 Subject: [PATCH 2/6] Add frontend, beginning of GH API implementation (wip, borked) --- ReplayBrowser/Helpers/GitHubApiHelper.cs | 78 +++++++++++++++++++ ReplayBrowser/Pages/Contributors.razor | 27 +++++++ .../Pages/Shared/ContributorCard.razor | 32 ++++++++ ReplayBrowser/Pages/Shared/MainLayout.razor | 2 +- ReplayBrowser/Startup.cs | 1 + 5 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 ReplayBrowser/Helpers/GitHubApiHelper.cs create mode 100644 ReplayBrowser/Pages/Contributors.razor create mode 100644 ReplayBrowser/Pages/Shared/ContributorCard.razor diff --git a/ReplayBrowser/Helpers/GitHubApiHelper.cs b/ReplayBrowser/Helpers/GitHubApiHelper.cs new file mode 100644 index 0000000..656edb1 --- /dev/null +++ b/ReplayBrowser/Helpers/GitHubApiHelper.cs @@ -0,0 +1,78 @@ +using System.Net.Mime; +using System.Text; +using Serilog; + +namespace ReplayBrowser.Helpers; + +public class GitHubApiHelper +{ + public GitHubAccount[] Contributors; + private string APIToken; + + public GitHubApiHelper(IConfiguration configuration) + { + try + { + APIToken = configuration.GetSection("GitHubAPIToken").ToString(); + } + catch (Exception e) + { + Log.Error("GitHubAPIToken not set, contributors cannot be fetched."); + } + } + + public async Task GetContributors() + { + try + { + /* + var client = new HttpClient(); + + client.DefaultRequestHeaders.Add("Accept", "application/vnd.github+json"); + client.DefaultRequestHeaders.Add("Authorization", $"Bearer {APIToken}"); + client.DefaultRequestHeaders.Add("X-GitHub-Api-Version", "2022-11-28"); + + var request = new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri("https://api.github.com/repos/Simyon264/ReplayBrowser/contributors") + }; + */ + + using (var httpClient = new HttpClient()) + { + using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.github.com/repos/Simyon264/ReplayBrowser/contributors")) + { + request.Headers.TryAddWithoutValidation("Accept", "application/vnd.github+json"); + request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {APIToken}"); + request.Headers.TryAddWithoutValidation("X-GitHub-Api-Version", "2022-11-28"); + + var response = await httpClient.SendAsync(request); + + Log.Debug(response.ToString()); + response.EnsureSuccessStatusCode(); + + var responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + Log.Information(responseBody); + + return []; // where is my debug + } + } + + //var response = await client.SendAsync(request).ConfigureAwait(false); + + } + catch (Exception e) + { + Log.Information($"Exception when querying GitHub: {e.Message}"); + return []; + } + } +} + +public struct GitHubAccount +{ + private string AccountName; + private string AccountImageURL; + private string AccountLink; +} \ No newline at end of file diff --git a/ReplayBrowser/Pages/Contributors.razor b/ReplayBrowser/Pages/Contributors.razor new file mode 100644 index 0000000..592d2b6 --- /dev/null +++ b/ReplayBrowser/Pages/Contributors.razor @@ -0,0 +1,27 @@ +@page "/contributors" + +@inject GitHubApiHelper GitHubApiHelper + +@using Microsoft.AspNetCore.Components.Web +@using ReplayBrowser.Pages.Shared +@using ReplayBrowser.Helpers + +Contributors + +

Contributors

+ +@foreach (var contrib in _contributors) +{ + +} + + + +@code { + private GitHubAccount[]? _contributors = []; + + protected async override Task OnInitializedAsync() + { + _contributors = await GitHubApiHelper.GetContributors(); + } +} \ No newline at end of file diff --git a/ReplayBrowser/Pages/Shared/ContributorCard.razor b/ReplayBrowser/Pages/Shared/ContributorCard.razor new file mode 100644 index 0000000..5be46bc --- /dev/null +++ b/ReplayBrowser/Pages/Shared/ContributorCard.razor @@ -0,0 +1,32 @@ +
+
+

@ContributorName

+
+ +
+
+ Profile Picture of the Contributor +
+ +
+ + + GitHub + +
+
+ + +@code { + [Parameter] public required string ContributorName { get; set; } + [Parameter] public required string ContributorImage { get; set; } + [Parameter] public required string ContributorLink { get; set; } + + + +} \ No newline at end of file diff --git a/ReplayBrowser/Pages/Shared/MainLayout.razor b/ReplayBrowser/Pages/Shared/MainLayout.razor index 59526df..6c43c49 100644 --- a/ReplayBrowser/Pages/Shared/MainLayout.razor +++ b/ReplayBrowser/Pages/Shared/MainLayout.razor @@ -109,7 +109,7 @@