diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-07-29 12:43:04 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-07-29 12:43:04 -0400 |
commit | 84d52b1735204550c6369270c03f61944c2c88bd (patch) | |
tree | 7a9a408718cd93b2696c1e73345a27a2be42c0c1 /src/SMAPI.Web/Controllers | |
parent | 670ff77363bae56c7514b83e7c126cacd318f440 (diff) | |
download | SMAPI-84d52b1735204550c6369270c03f61944c2c88bd.tar.gz SMAPI-84d52b1735204550c6369270c03f61944c2c88bd.tar.bz2 SMAPI-84d52b1735204550c6369270c03f61944c2c88bd.zip |
make beta version on smapi.io optional (#569)
Diffstat (limited to 'src/SMAPI.Web/Controllers')
-rw-r--r-- | src/SMAPI.Web/Controllers/IndexController.cs | 11 | ||||
-rw-r--r-- | src/SMAPI.Web/Controllers/LogParserController.cs | 10 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/SMAPI.Web/Controllers/IndexController.cs b/src/SMAPI.Web/Controllers/IndexController.cs index 09bad112..8c4a0332 100644 --- a/src/SMAPI.Web/Controllers/IndexController.cs +++ b/src/SMAPI.Web/Controllers/IndexController.cs @@ -6,8 +6,10 @@ using System.Threading.Tasks; using HtmlAgilityPack; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Options; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Web.Framework.Clients.GitHub; +using StardewModdingAPI.Web.Framework.ConfigModels; using StardewModdingAPI.Web.ViewModels; namespace StardewModdingAPI.Web.Controllers @@ -20,6 +22,9 @@ namespace StardewModdingAPI.Web.Controllers /********* ** Properties *********/ + /// <summary>The site config settings.</summary> + private readonly SiteConfig SiteConfig; + /// <summary>The cache in which to store release data.</summary> private readonly IMemoryCache Cache; @@ -39,10 +44,12 @@ namespace StardewModdingAPI.Web.Controllers /// <summary>Construct an instance.</summary> /// <param name="cache">The cache in which to store release data.</param> /// <param name="github">The GitHub API client.</param> - public IndexController(IMemoryCache cache, IGitHubClient github) + /// <param name="siteConfig">The context config settings.</param> + public IndexController(IMemoryCache cache, IGitHubClient github, IOptions<SiteConfig> siteConfig) { this.Cache = cache; this.GitHub = github; + this.SiteConfig = siteConfig.Value; } /// <summary>Display the index page.</summary> @@ -60,7 +67,7 @@ namespace StardewModdingAPI.Web.Controllers IndexVersionModel stableVersionModel = stableVersion != null ? new IndexVersionModel(stableVersion.Version.ToString(), stableVersion.Release.Body, stableVersion.Asset.DownloadUrl, stableVersionForDevs?.Asset.DownloadUrl) : new IndexVersionModel("unknown", "", "https://github.com/Pathoschild/SMAPI/releases", null); // just in case something goes wrong) - IndexVersionModel betaVersionModel = betaVersion != null + IndexVersionModel betaVersionModel = betaVersion != null && this.SiteConfig.EnableSmapiBeta ? new IndexVersionModel(betaVersion.Version.ToString(), betaVersion.Release.Body, betaVersion.Asset.DownloadUrl, betaVersionForDevs?.Asset.DownloadUrl) : null; diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs index 354bdb06..17f8d3aa 100644 --- a/src/SMAPI.Web/Controllers/LogParserController.cs +++ b/src/SMAPI.Web/Controllers/LogParserController.cs @@ -21,8 +21,8 @@ namespace StardewModdingAPI.Web.Controllers /********* ** Properties *********/ - /// <summary>The log parser config settings.</summary> - private readonly ContextConfig Config; + /// <summary>The site config settings.</summary> + private readonly SiteConfig Config; /// <summary>The underlying Pastebin client.</summary> private readonly IPastebinClient Pastebin; @@ -39,11 +39,11 @@ namespace StardewModdingAPI.Web.Controllers ** Constructor ***/ /// <summary>Construct an instance.</summary> - /// <param name="contextProvider">The context config settings.</param> + /// <param name="siteConfig">The context config settings.</param> /// <param name="pastebin">The Pastebin API client.</param> - public LogParserController(IOptions<ContextConfig> contextProvider, IPastebinClient pastebin) + public LogParserController(IOptions<SiteConfig> siteConfig, IPastebinClient pastebin) { - this.Config = contextProvider.Value; + this.Config = siteConfig.Value; this.Pastebin = pastebin; } |