From c3b0248242987265dff440fd57c06fe207d15469 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 1 Oct 2024 14:47:44 +1000 Subject: [PATCH 1/2] Change prefix to format string for `ViewDataDictionary.SetNavigation` also make these explicitly absolute paths, while still allowing relative paths --- TASVideos/Extensions/ViewDataDictionaryExtensions.cs | 4 ++-- TASVideos/Pages/Games/Index.cshtml | 2 +- TASVideos/Pages/Shared/_Layout.cshtml | 5 +++-- TASVideos/Pages/Submissions/View.cshtml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TASVideos/Extensions/ViewDataDictionaryExtensions.cs b/TASVideos/Extensions/ViewDataDictionaryExtensions.cs index 73f4e00f0..30cec757b 100644 --- a/TASVideos/Extensions/ViewDataDictionaryExtensions.cs +++ b/TASVideos/Extensions/ViewDataDictionaryExtensions.cs @@ -45,10 +45,10 @@ public static string GetHeading(this ViewDataDictionary viewData) public static void SetWikiPage(this ViewDataDictionary viewData, IWikiPage wikiPage) => viewData["WikiPage"] = wikiPage; - public static void SetNavigation(this ViewDataDictionary viewData, int id, string suffix) + public static void SetNavigation(this ViewDataDictionary viewData, int id, string fmtStr = "{0}") { viewData["NavigationId"] = id; - viewData["NavigationSuffix"] = suffix; + viewData["NavigationFmtStr"] = fmtStr; } public static string ActivePageClass(this ViewDataDictionary viewData, string page) diff --git a/TASVideos/Pages/Games/Index.cshtml b/TASVideos/Pages/Games/Index.cshtml index 1fbea0c10..38d5417be 100644 --- a/TASVideos/Pages/Games/Index.cshtml +++ b/TASVideos/Pages/Games/Index.cshtml @@ -20,7 +20,7 @@ if (int.TryParse(Model.Id, out int id)) { - ViewData.SetNavigation(id, "G"); + ViewData.SetNavigation(id, "/{0}G"); } } diff --git a/TASVideos/Pages/Shared/_Layout.cshtml b/TASVideos/Pages/Shared/_Layout.cshtml index b49393a5f..60f329138 100644 --- a/TASVideos/Pages/Shared/_Layout.cshtml +++ b/TASVideos/Pages/Shared/_Layout.cshtml @@ -89,6 +89,7 @@ var heading = ViewData.GetHeading(); int? prev = null; int? next = null; + string? fmtStr = ViewData["NavigationFmtStr"] as string; if (User.Has(PermissionTo.CatalogMovies)) { var id = ViewData.Int("NavigationId"); @@ -101,7 +102,7 @@

- + @if (IsSectionDefined("PageTitle")) { @await RenderSectionAsync("PageTitle") @@ -110,7 +111,7 @@ { @heading } - +

} diff --git a/TASVideos/Pages/Submissions/View.cshtml b/TASVideos/Pages/Submissions/View.cshtml index 416bee367..6ba44e675 100644 --- a/TASVideos/Pages/Submissions/View.cshtml +++ b/TASVideos/Pages/Submissions/View.cshtml @@ -4,7 +4,7 @@ @{ ViewData.SetTitle($"{Model.Submission.Title} - Submission #{Model.Id}"); ViewData.SetHeading($"Submission {Model.Submission.Title}"); - ViewData.SetNavigation(Model.Id, "S"); + ViewData.SetNavigation(Model.Id, "/{0}S"); bool hasEncode = !string.IsNullOrWhiteSpace(Model.Submission.EncodeEmbedLink); bool canEdit = User.Has(PermissionTo.EditSubmissions) || (Model.CanEdit && User.Has(PermissionTo.SubmitMovies)); From 1b4a801c445ba14138cb83515fccc7c725472590 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 1 Oct 2024 14:52:14 +1000 Subject: [PATCH 2/2] Add prev/next ID buttons for game groups --- TASVideos/Pages/GameGroups/Index.cshtml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TASVideos/Pages/GameGroups/Index.cshtml b/TASVideos/Pages/GameGroups/Index.cshtml index 23e5e6b7a..5506599ca 100644 --- a/TASVideos/Pages/GameGroups/Index.cshtml +++ b/TASVideos/Pages/GameGroups/Index.cshtml @@ -2,6 +2,10 @@ @model IndexModel @{ ViewData.SetTitle($"Games for Group: {Model.Name}"); + if (int.TryParse(Model.Id, out var id)) + { + ViewData.SetNavigation(id, "/GameGroups/{0}"); + } }