diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.Web/Controllers/LogParserController.cs | 10 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs | 15 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs | 12 | ||||
-rw-r--r-- | src/SMAPI.Web/Startup.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Web/Views/Shared/_Layout.cshtml | 10 | ||||
-rw-r--r-- | src/SMAPI.Web/appsettings.Development.json | 7 | ||||
-rw-r--r-- | src/SMAPI.Web/appsettings.json | 7 |
7 files changed, 36 insertions, 27 deletions
diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs index ad979397..04a11a82 100644 --- a/src/SMAPI.Web/Controllers/LogParserController.cs +++ b/src/SMAPI.Web/Controllers/LogParserController.cs @@ -19,7 +19,7 @@ namespace StardewModdingAPI.Web.Controllers ** Properties *********/ /// <summary>The log parser config settings.</summary> - private readonly LogParserConfig Config; + private readonly ContextConfig Config; /// <summary>The underlying Pastebin client.</summary> private readonly IPastebinClient Pastebin; @@ -36,11 +36,11 @@ namespace StardewModdingAPI.Web.Controllers ** Constructor ***/ /// <summary>Construct an instance.</summary> - /// <param name="configProvider">The log parser config settings.</param> + /// <param name="contextProvider">The context config settings.</param> /// <param name="pastebin">The Pastebin API client.</param> - public LogParserController(IOptions<LogParserConfig> configProvider, IPastebinClient pastebin) + public LogParserController(IOptions<ContextConfig> contextProvider, IPastebinClient pastebin) { - this.Config = configProvider.Value; + this.Config = contextProvider.Value; this.Pastebin = pastebin; } @@ -54,7 +54,7 @@ namespace StardewModdingAPI.Web.Controllers [Route("log/{id}")] public ViewResult Index(string id = null) { - return this.View("Index", new LogParserModel(this.Config.SectionUrl, id)); + return this.View("Index", new LogParserModel(this.Config.LogParserUrl, id)); } /*** diff --git a/src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs new file mode 100644 index 00000000..117462f4 --- /dev/null +++ b/src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs @@ -0,0 +1,15 @@ +namespace StardewModdingAPI.Web.Framework.ConfigModels +{ + /// <summary>The config settings for the app context.</summary> + public class ContextConfig // must be public to pass into views + { + /********* + ** Accessors + *********/ + /// <summary>The root URL for the app.</summary> + public string RootUrl { get; set; } + + /// <summary>The root URL for the log parser.</summary> + public string LogParserUrl { get; set; } + } +} diff --git a/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs deleted file mode 100644 index 198274b2..00000000 --- a/src/SMAPI.Web/Framework/ConfigModels/LogParserConfig.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace StardewModdingAPI.Web.Framework.ConfigModels -{ - /// <summary>The config settings for the log parser.</summary> - internal class LogParserConfig - { - /********* - ** Accessors - *********/ - /// <summary>The root URL for the log parser controller.</summary> - public string SectionUrl { get; set; } - } -} diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs index c6e3f85d..e5e759e7 100644 --- a/src/SMAPI.Web/Startup.cs +++ b/src/SMAPI.Web/Startup.cs @@ -48,7 +48,7 @@ namespace StardewModdingAPI.Web // init configuration services .Configure<ModUpdateCheckConfig>(this.Configuration.GetSection("ModUpdateCheck")) - .Configure<LogParserConfig>(this.Configuration.GetSection("LogParser")) + .Configure<ContextConfig>(this.Configuration.GetSection("Context")) .Configure<RouteOptions>(options => options.ConstraintMap.Add("semanticVersion", typeof(VersionConstraint))) .AddMemoryCache() .AddMvc() diff --git a/src/SMAPI.Web/Views/Shared/_Layout.cshtml b/src/SMAPI.Web/Views/Shared/_Layout.cshtml index 547a8178..ac98c71b 100644 --- a/src/SMAPI.Web/Views/Shared/_Layout.cshtml +++ b/src/SMAPI.Web/Views/Shared/_Layout.cshtml @@ -1,3 +1,7 @@ +@using Microsoft.Extensions.Options +@using StardewModdingAPI.Web.Framework.ConfigModels +@inject IOptions<ContextConfig> ContextConfig + <!DOCTYPE html> <html> <head> @@ -10,9 +14,9 @@ <div id="sidebar"> <h4>SMAPI</h4> <ul> - <li><a href="https://stardewvalleywiki.com/Modding:Index">FAQs & guides</a></li> - <li><a href="https://github.com/pathoschild/SMAPI/releases">Download SMAPI</a></li> - <li><a href="https://discord.gg/stardewvalley">Get help on Discord</a></li> + <li><a href="@ContextConfig.Value.RootUrl">About SMAPI</a></li> + <li><a href="@ContextConfig.Value.LogParserUrl">Log parser</a></li> + <li><a href="https://stardewvalleywiki.com/Modding:Index">Docs</a></li> </ul> </div> <div id="content-column"> diff --git a/src/SMAPI.Web/appsettings.Development.json b/src/SMAPI.Web/appsettings.Development.json index 45fc30f3..495af120 100644 --- a/src/SMAPI.Web/appsettings.Development.json +++ b/src/SMAPI.Web/appsettings.Development.json @@ -16,14 +16,15 @@ "Microsoft": "Information" } }, + "Context": { + "RootUrl": "http://localhost:59482/", + "LogParserUrl": "http://localhost:59482/log/" + }, "ApiClients": { "GitHubUsername": null, "GitHubPassword": null, "PastebinUserKey": null, "PastebinDevKey": null - }, - "LogParser": { - "SectionUrl": "http://localhost:59482/log/" } } diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index 69b3b4f8..9758f4a7 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -13,6 +13,10 @@ "Default": "Warning" } }, + "Context": { + "RootUrl": null, // see top note + "LogParserUrl": null // see top note + }, "ApiClients": { "UserAgent": "SMAPI/{0} (+https://github.com/Pathoschild/SMAPI)", @@ -41,8 +45,5 @@ "ChucklefishKey": "Chucklefish", "GitHubKey": "GitHub", "NexusKey": "Nexus" - }, - "LogParser": { - "SectionUrl": null // see top note } } |