Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wiki main page not displaying custom layout #26441

Merged
merged 7 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Online/TestSceneWikiHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public partial class TestSceneWikiHeader : OsuTestScene
[Cached]
private readonly Bindable<APIWikiPage> wikiPageData = new Bindable<APIWikiPage>(new APIWikiPage
{
Title = "Main Page",
Path = "Main_Page",
Title = "Main page",
Path = WikiOverlay.INDEX_PATH,
});

private TestHeader header;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Online/TestSceneWikiMainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TestSceneWikiMainPage()
};
}

// From https://osu.ppy.sh/api/v2/wiki/en/Main_Page
// From https://osu.ppy.sh/api/v2/wiki/en/Main_page
private const string main_page_markdown =
"---\nlayout: main_page\n---\n\n<!-- Do not add any empty lines inside this div. -->\n\n<div class=\"wiki-main-page__blurb\">\nWelcome to the osu! wiki, a project containing a wide range of osu! related information.\n</div>\n\n<div class=\"wiki-main-page__panels\">\n<div class=\"wiki-main-page-panel wiki-main-page-panel--full\">\n\n# Getting started\n\n[Welcome](/wiki/Welcome) • [Installation](/wiki/Installation) • [Registration](/wiki/Registration) • [Help Centre](/wiki/Help_Centre) • [FAQ](/wiki/FAQ)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Game client\n\n[Interface](/wiki/Interface) • [Options](/wiki/Options) • [Visual settings](/wiki/Visual_Settings) • [Shortcut key reference](/wiki/Shortcut_key_reference) • [Configuration file](/wiki/osu!_Program_Files/User_Configuration_File) • [Program files](/wiki/osu!_Program_Files)\n\n[File formats](/wiki/osu!_File_Formats): [.osz](/wiki/osu!_File_Formats/Osz_(file_format)) • [.osk](/wiki/osu!_File_Formats/Osk_(file_format)) • [.osr](/wiki/osu!_File_Formats/Osr_(file_format)) • [.osu](/wiki/osu!_File_Formats/Osu_(file_format)) • [.osb](/wiki/osu!_File_Formats/Osb_(file_format)) • [.db](/wiki/osu!_File_Formats/Db_(file_format))\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Gameplay\n\n[Game modes](/wiki/Game_mode): [osu!](/wiki/Game_mode/osu!) • [osu!taiko](/wiki/Game_mode/osu!taiko) • [osu!catch](/wiki/Game_mode/osu!catch) • [osu!mania](/wiki/Game_mode/osu!mania)\n\n[Beatmap](/wiki/Beatmap) • [Hit object](/wiki/Hit_object) • [Mods](/wiki/Game_modifier) • [Score](/wiki/Score) • [Replay](/wiki/Replay) • [Multi](/wiki/Multi)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# [Beatmap editor](/wiki/Beatmap_Editor)\n\nSections: [Compose](/wiki/Beatmap_Editor/Compose) • [Design](/wiki/Beatmap_Editor/Design) • [Timing](/wiki/Beatmap_Editor/Timing) • [Song setup](/wiki/Beatmap_Editor/Song_Setup)\n\nComponents: [AiMod](/wiki/Beatmap_Editor/AiMod) • [Beat snap divisor](/wiki/Beatmap_Editor/Beat_Snap_Divisor) • [Distance snap](/wiki/Beatmap_Editor/Distance_Snap) • [Menu](/wiki/Beatmap_Editor/Menu) • [SB load](/wiki/Beatmap_Editor/SB_Load) • [Timelines](/wiki/Beatmap_Editor/Timelines)\n\n[Beatmapping](/wiki/Beatmapping) • [Difficulty](/wiki/Beatmap/Difficulty) • [Mapping techniques](/wiki/Mapping_Techniques) • [Storyboarding](/wiki/Storyboarding)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Beatmap submission and ranking\n\n[Submission](/wiki/Submission) • [Modding](/wiki/Modding) • [Ranking procedure](/wiki/Beatmap_ranking_procedure) • [Mappers' Guild](/wiki/Mappers_Guild) • [Project Loved](/wiki/Project_Loved)\n\n[Ranking criteria](/wiki/Ranking_Criteria): [osu!](/wiki/Ranking_Criteria/osu!) • [osu!taiko](/wiki/Ranking_Criteria/osu!taiko) • [osu!catch](/wiki/Ranking_Criteria/osu!catch) • [osu!mania](/wiki/Ranking_Criteria/osu!mania)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Community\n\n[Tournaments](/wiki/Tournaments) • [Skinning](/wiki/Skinning) • [Projects](/wiki/Projects) • [Guides](/wiki/Guides) • [osu!dev Discord server](/wiki/osu!dev_Discord_server) • [How you can help](/wiki/How_You_Can_Help!) • [Glossary](/wiki/Glossary)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# People\n\n[The Team](/wiki/People/The_Team): [Developers](/wiki/People/The_Team/Developers) • [Global Moderation Team](/wiki/People/The_Team/Global_Moderation_Team) • [Support Team](/wiki/People/The_Team/Support_Team) • [Nomination Assessment Team](/wiki/People/The_Team/Nomination_Assessment_Team) • [Beatmap Nominators](/wiki/People/The_Team/Beatmap_Nominators) • [osu! Alumni](/wiki/People/The_Team/osu!_Alumni) • [Project Loved Team](/wiki/People/The_Team/Project_Loved_Team)\n\nOrganisations: [osu! UCI](/wiki/Organisations/osu!_UCI)\n\n[Community Contributors](/wiki/People/Community_Contributors) • [Users with unique titles](/wiki/People/Users_with_unique_titles)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# For developers\n\n[API](/wiki/osu!api) • [Bot account](/wiki/Bot_account) • [Brand identity guidelines](/wiki/Brand_identity_guidelines)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# About the wiki\n\n[Sitemap](/wiki/Sitemap) • [Contribution guide](/wiki/osu!_wiki_Contribution_Guide) • [Article styling criteria](/wiki/Article_Styling_Criteria) • [News styling criteria](/wiki/News_Styling_Criteria)\n\n</div>\n</div>\n";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void TestLink()
{
AddStep("set current path", () => markdownContainer.CurrentPath = $"{API.WebsiteRootUrl}/wiki/Article_styling_criteria/");

AddStep("set '/wiki/Main_Page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_Page)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Main_Page");
AddStep("set '/wiki/Main_page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_page)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Main_page");

AddStep("set '../FAQ''", () => markdownContainer.Text = "[FAQ](../FAQ)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/FAQ");
Expand Down
9 changes: 5 additions & 4 deletions osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Wiki;

Check failure on line 14 in osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

Check failure on line 14 in osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

namespace osu.Game.Tests.Visual.Online
{
Expand Down Expand Up @@ -107,12 +108,12 @@
};
});

// From https://osu.ppy.sh/api/v2/wiki/en/Main_Page
// From https://osu.ppy.sh/api/v2/wiki/en/Main_page
private APIWikiPage responseMainPage => new APIWikiPage
{
Title = "Main Page",
Layout = "main_page",
Path = "Main_Page",
Title = "Main page",
Layout = WikiOverlay.INDEX_PATH.ToLowerInvariant(), // custom classes are always lower snake.
Path = WikiOverlay.INDEX_PATH,
Locale = "en",
Subtitle = null,
Markdown =
Expand Down
4 changes: 1 addition & 3 deletions osu.Game/Overlays/Wiki/WikiHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace osu.Game.Overlays.Wiki
{
public partial class WikiHeader : BreadcrumbControlOverlayHeader
{
private const string index_path = "Main_page";

public static LocalisableString IndexPageString => LayoutStrings.HeaderHelpIndex;

public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
Expand All @@ -45,7 +43,7 @@ private void onWikiPageChange(ValueChangedEvent<APIWikiPage> e)

TabControl.AddItem(IndexPageString);

if (e.NewValue.Path == index_path)
if (e.NewValue.Path == WikiOverlay.INDEX_PATH)
{
Current.Value = IndexPageString;
return;
Expand Down
10 changes: 5 additions & 5 deletions osu.Game/Overlays/WikiOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ namespace osu.Game.Overlays
{
public partial class WikiOverlay : OnlineOverlay<WikiHeader>
{
private const string index_path = "Main_page";
public const string INDEX_PATH = @"Main_page";

public string CurrentPath => path.Value;

private readonly Bindable<string> path = new Bindable<string>(index_path);
private readonly Bindable<string> path = new Bindable<string>(INDEX_PATH);

private readonly Bindable<APIWikiPage> wikiData = new Bindable<APIWikiPage>();

Expand All @@ -43,7 +43,7 @@ public WikiOverlay()
{
}

public void ShowPage(string pagePath = index_path)
public void ShowPage(string pagePath = INDEX_PATH)
{
path.Value = pagePath.Trim('/');
Show();
Expand Down Expand Up @@ -137,7 +137,7 @@ private void onSuccess(APIWikiPage response)
wikiData.Value = response;
path.Value = response.Path;

if (response.Layout == index_path)
if (response.Layout.Equals(INDEX_PATH, StringComparison.OrdinalIgnoreCase))
{
LoadDisplay(new WikiMainPage
{
Expand All @@ -161,7 +161,7 @@ private void onFail(string originalPath)
path.Value = "error";

LoadDisplay(articlePage = new WikiArticlePage($@"{api.WebsiteRootUrl}/wiki/",
$"Something went wrong when trying to fetch page \"{originalPath}\".\n\n[Return to the main page](Main_page)."));
$"Something went wrong when trying to fetch page \"{originalPath}\".\n\n[Return to the main page]({INDEX_PATH})."));
}

private void showParentPage()
Expand Down