forked from OpenDreamProject/OpenDream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ports infolinks (OpenDreamProject#1579)
* Ports infolinks * Update OpenDreamRuntime/ServerInfoManager.cs * Update OpenDreamRuntime/ServerInfoManager.cs * breh --------- Co-authored-by: ike709 <[email protected]>
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Text.Json.Nodes; | ||
using OpenDreamShared; | ||
using Robust.Server.ServerStatus; | ||
using Robust.Shared.Configuration; | ||
|
||
namespace OpenDreamRuntime; | ||
|
||
/// <summary> | ||
/// Adds additional data like info links to the server info endpoint | ||
/// </summary> | ||
public sealed class ServerInfoManager { | ||
private static readonly (CVarDef<string> cVar, string icon, string name)[] Vars = { | ||
// @formatter:off | ||
(OpenDreamCVars.InfoLinksDiscord, "discord", "Discord"), | ||
(OpenDreamCVars.InfoLinksForum, "forum", "Forum"), | ||
(OpenDreamCVars.InfoLinksGithub, "github", "GitHub"), | ||
(OpenDreamCVars.InfoLinksWebsite, "web", "Website"), | ||
(OpenDreamCVars.InfoLinksWiki, "wiki", "Wiki") | ||
// @formatter:on | ||
}; | ||
|
||
[Dependency] private readonly IStatusHost _statusHost = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
|
||
public void Initialize() { | ||
_statusHost.OnInfoRequest += OnInfoRequest; | ||
} | ||
|
||
private void OnInfoRequest(JsonNode json) { | ||
foreach (var (cVar, icon, name) in Vars) { | ||
var url = _cfg.GetCVar(cVar); | ||
if (string.IsNullOrEmpty(url)) | ||
continue; | ||
|
||
StatusHostHelpers.AddLink(json, name, url, icon); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters