mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add website root URL and update most links to use it
For what it's worth, I intentionally didn't include news / changelog / supporter, because these should never change.
This commit is contained in:
@ -28,7 +28,9 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private readonly Queue<APIRequest> queue = new Queue<APIRequest>();
|
private readonly Queue<APIRequest> queue = new Queue<APIRequest>();
|
||||||
|
|
||||||
public string Endpoint { get; }
|
public string APIEndpointUrl { get; }
|
||||||
|
|
||||||
|
public string WebsiteRootUrl { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The username/email provided by the user when initiating a login.
|
/// The username/email provided by the user when initiating a login.
|
||||||
@ -57,9 +59,10 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
Endpoint = endpointConfiguration.APIEndpoint;
|
APIEndpointUrl = endpointConfiguration.APIEndpointUrl;
|
||||||
|
WebsiteRootUrl = endpointConfiguration.WebsiteRootUrl;
|
||||||
|
|
||||||
authentication = new OAuth(endpointConfiguration.APIClientID, endpointConfiguration.APIClientSecret, Endpoint);
|
authentication = new OAuth(endpointConfiguration.APIClientID, endpointConfiguration.APIClientSecret, APIEndpointUrl);
|
||||||
log = Logger.GetLogger(LoggingTarget.Network);
|
log = Logger.GetLogger(LoggingTarget.Network);
|
||||||
|
|
||||||
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
||||||
@ -245,7 +248,7 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
var req = new RegistrationRequest
|
var req = new RegistrationRequest
|
||||||
{
|
{
|
||||||
Url = $@"{Endpoint}/users",
|
Url = $@"{APIEndpointUrl}/users",
|
||||||
Method = HttpMethod.Post,
|
Method = HttpMethod.Post,
|
||||||
Username = username,
|
Username = username,
|
||||||
Email = email,
|
Email = email,
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
protected virtual WebRequest CreateWebRequest() => new OsuWebRequest(Uri);
|
protected virtual WebRequest CreateWebRequest() => new OsuWebRequest(Uri);
|
||||||
|
|
||||||
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
protected virtual string Uri => $@"{API.APIEndpointUrl}/api/v2/{Target}";
|
||||||
|
|
||||||
protected APIAccess API;
|
protected APIAccess API;
|
||||||
protected WebRequest WebRequest;
|
protected WebRequest WebRequest;
|
||||||
|
@ -28,7 +28,9 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public string ProvidedUsername => LocalUser.Value.Username;
|
public string ProvidedUsername => LocalUser.Value.Username;
|
||||||
|
|
||||||
public string Endpoint => "http://localhost";
|
public string APIEndpointUrl => "http://localhost";
|
||||||
|
|
||||||
|
public string WebsiteRootUrl => "http://localhost";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provide handling logic for an arbitrary API request.
|
/// Provide handling logic for an arbitrary API request.
|
||||||
|
@ -46,7 +46,12 @@ namespace osu.Game.Online.API
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The URL endpoint for this API. Does not include a trailing slash.
|
/// The URL endpoint for this API. Does not include a trailing slash.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string Endpoint { get; }
|
string APIEndpointUrl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The root URL of of the website, excluding the trailing slash.
|
||||||
|
/// </summary>
|
||||||
|
public string WebsiteRootUrl { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current connection state of the API.
|
/// The current connection state of the API.
|
||||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Online.Chat
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var beatmapString = beatmap.OnlineBeatmapID.HasValue ? $"[https://osu.ppy.sh/b/{beatmap.OnlineBeatmapID} {beatmap}]" : beatmap.ToString();
|
var beatmapString = beatmap.OnlineBeatmapID.HasValue ? $"[{api.WebsiteRootUrl}/b/{beatmap.OnlineBeatmapID} {beatmap}]" : beatmap.ToString();
|
||||||
|
|
||||||
channelManager.PostMessage($"is {verb} {beatmapString}", true);
|
channelManager.PostMessage($"is {verb} {beatmapString}", true);
|
||||||
Expire();
|
Expire();
|
||||||
|
@ -7,11 +7,11 @@ namespace osu.Game.Online
|
|||||||
{
|
{
|
||||||
public DevelopmentEndpointConfiguration()
|
public DevelopmentEndpointConfiguration()
|
||||||
{
|
{
|
||||||
APIEndpoint = @"https://dev.ppy.sh";
|
WebsiteRootUrl = APIEndpointUrl = @"https://dev.ppy.sh";
|
||||||
APIClientSecret = @"3LP2mhUrV89xxzD1YKNndXHEhWWCRLPNKioZ9ymT";
|
APIClientSecret = @"3LP2mhUrV89xxzD1YKNndXHEhWWCRLPNKioZ9ymT";
|
||||||
APIClientID = "5";
|
APIClientID = "5";
|
||||||
SpectatorEndpoint = $"{APIEndpoint}/spectator";
|
SpectatorEndpointUrl = $"{APIEndpointUrl}/spectator";
|
||||||
MultiplayerEndpoint = $"{APIEndpoint}/multiplayer";
|
MultiplayerEndpointUrl = $"{APIEndpointUrl}/multiplayer";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,15 @@ namespace osu.Game.Online
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EndpointConfiguration
|
public class EndpointConfiguration
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The base URL for the website.
|
||||||
|
/// </summary>
|
||||||
|
public string WebsiteRootUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The endpoint for the main (osu-web) API.
|
/// The endpoint for the main (osu-web) API.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string APIEndpoint { get; set; }
|
public string APIEndpointUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The OAuth client secret.
|
/// The OAuth client secret.
|
||||||
@ -23,8 +28,14 @@ namespace osu.Game.Online
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string APIClientID { get; set; }
|
public string APIClientID { get; set; }
|
||||||
|
|
||||||
public string SpectatorEndpoint { get; set; }
|
/// <summary>
|
||||||
|
/// The endpoint for the SignalR spectator server.
|
||||||
|
/// </summary>
|
||||||
|
public string SpectatorEndpointUrl { get; set; }
|
||||||
|
|
||||||
public string MultiplayerEndpoint { get; set; }
|
/// <summary>
|
||||||
|
/// The endpoint for the SignalR multiplayer server.
|
||||||
|
/// </summary>
|
||||||
|
public string MultiplayerEndpointUrl { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ namespace osu.Game.Online
|
|||||||
{
|
{
|
||||||
public ProductionEndpointConfiguration()
|
public ProductionEndpointConfiguration()
|
||||||
{
|
{
|
||||||
APIEndpoint = @"https://osu.ppy.sh";
|
WebsiteRootUrl = APIEndpointUrl = @"https://osu.ppy.sh";
|
||||||
APIClientSecret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
APIClientSecret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
||||||
APIClientID = "5";
|
APIClientID = "5";
|
||||||
SpectatorEndpoint = "https://spectator.ppy.sh/spectator";
|
SpectatorEndpointUrl = "https://spectator.ppy.sh/spectator";
|
||||||
MultiplayerEndpoint = "https://spectator.ppy.sh/multiplayer";
|
MultiplayerEndpointUrl = "https://spectator.ppy.sh/multiplayer";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
public RealtimeMultiplayerClient(EndpointConfiguration endpoints)
|
public RealtimeMultiplayerClient(EndpointConfiguration endpoints)
|
||||||
{
|
{
|
||||||
endpoint = endpoints.MultiplayerEndpoint;
|
endpoint = endpoints.MultiplayerEndpointUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
public SpectatorStreamingClient(EndpointConfiguration endpoints)
|
public SpectatorStreamingClient(EndpointConfiguration endpoints)
|
||||||
{
|
{
|
||||||
endpoint = endpoints.SpectatorEndpoint;
|
endpoint = endpoints.SpectatorEndpointUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -294,7 +294,7 @@ namespace osu.Game
|
|||||||
public void OpenUrlExternally(string url) => waitForReady(() => externalLinkOpener, _ =>
|
public void OpenUrlExternally(string url) => waitForReady(() => externalLinkOpener, _ =>
|
||||||
{
|
{
|
||||||
if (url.StartsWith('/'))
|
if (url.StartsWith('/'))
|
||||||
url = $"{API.Endpoint}{url}";
|
url = $"{API.APIEndpointUrl}{url}";
|
||||||
|
|
||||||
externalLinkOpener.OpenUrlExternally(url);
|
externalLinkOpener.OpenUrlExternally(url);
|
||||||
});
|
});
|
||||||
|
@ -15,6 +15,7 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online;
|
using osu.Game.Online;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays.BeatmapListing.Panels;
|
using osu.Game.Overlays.BeatmapListing.Panels;
|
||||||
using osu.Game.Overlays.BeatmapSet.Buttons;
|
using osu.Game.Overlays.BeatmapSet.Buttons;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -40,6 +41,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
public bool DownloadButtonsVisible => downloadButtonsContainer.Any();
|
public bool DownloadButtonsVisible => downloadButtonsContainer.Any();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
public BeatmapRulesetSelector RulesetSelector => beatmapSetHeader.RulesetSelector;
|
public BeatmapRulesetSelector RulesetSelector => beatmapSetHeader.RulesetSelector;
|
||||||
public readonly BeatmapPicker Picker;
|
public readonly BeatmapPicker Picker;
|
||||||
|
|
||||||
@ -213,7 +217,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Picker.Beatmap.ValueChanged += b =>
|
Picker.Beatmap.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
Details.Beatmap = b.NewValue;
|
Details.Beatmap = b.NewValue;
|
||||||
externalLink.Link = $@"https://osu.ppy.sh/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}";
|
externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -27,6 +28,9 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
|
|
||||||
private Color4 iconColour;
|
private Color4 iconColour;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
public BottomHeaderContainer()
|
public BottomHeaderContainer()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
@ -109,7 +113,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
}
|
}
|
||||||
|
|
||||||
topLinkContainer.AddText("Contributed ");
|
topLinkContainer.AddText("Contributed ");
|
||||||
topLinkContainer.AddLink($@"{user.PostCount:#,##0} forum posts", $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: embolden);
|
topLinkContainer.AddLink($@"{user.PostCount:#,##0} forum posts", $"{api.WebsiteRootUrl}/users/{user.Id}/posts", creationParameters: embolden);
|
||||||
|
|
||||||
string websiteWithoutProtocol = user.Website;
|
string websiteWithoutProtocol = user.Website;
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays.Profile.Header.Components;
|
using osu.Game.Overlays.Profile.Header.Components;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Game.Users.Drawables;
|
using osu.Game.Users.Drawables;
|
||||||
@ -23,6 +24,9 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
|
|
||||||
public readonly Bindable<User> User = new Bindable<User>();
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
private SupporterIcon supporterTag;
|
private SupporterIcon supporterTag;
|
||||||
private UpdateableAvatar avatar;
|
private UpdateableAvatar avatar;
|
||||||
private OsuSpriteText usernameText;
|
private OsuSpriteText usernameText;
|
||||||
@ -166,7 +170,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
{
|
{
|
||||||
avatar.User = user;
|
avatar.User = user;
|
||||||
usernameText.Text = user?.Username ?? string.Empty;
|
usernameText.Text = user?.Username ?? string.Empty;
|
||||||
openUserExternally.Link = $@"https://osu.ppy.sh/users/{user?.Id ?? 0}";
|
openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}";
|
||||||
userFlag.Country = user?.Country;
|
userFlag.Country = user?.Country;
|
||||||
userCountryText.Text = user?.Country?.FullName ?? "Alien";
|
userCountryText.Text = user?.Country?.FullName ?? "Alien";
|
||||||
supporterTag.SupportLevel = user?.SupportLevel ?? 0;
|
supporterTag.SupportLevel = user?.SupportLevel ?? 0;
|
||||||
|
@ -216,7 +216,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
private void addBeatmapsetLink()
|
private void addBeatmapsetLink()
|
||||||
=> content.AddLink(activity.Beatmapset?.Title, LinkAction.OpenBeatmapSet, getLinkArgument(activity.Beatmapset?.Url), creationParameters: t => t.Font = getLinkFont());
|
=> content.AddLink(activity.Beatmapset?.Title, LinkAction.OpenBeatmapSet, getLinkArgument(activity.Beatmapset?.Url), creationParameters: t => t.Font = getLinkFont());
|
||||||
|
|
||||||
private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.Endpoint}{url}").Argument;
|
private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.APIEndpointUrl}{url}").Argument;
|
||||||
|
|
||||||
private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
|
private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
|
||||||
=> OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true);
|
=> OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true);
|
||||||
|
Reference in New Issue
Block a user