summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-07-29 12:43:04 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-07-29 12:43:04 -0400
commit84d52b1735204550c6369270c03f61944c2c88bd (patch)
tree7a9a408718cd93b2696c1e73345a27a2be42c0c1 /src
parent670ff77363bae56c7514b83e7c126cacd318f440 (diff)
downloadSMAPI-84d52b1735204550c6369270c03f61944c2c88bd.tar.gz
SMAPI-84d52b1735204550c6369270c03f61944c2c88bd.tar.bz2
SMAPI-84d52b1735204550c6369270c03f61944c2c88bd.zip
make beta version on smapi.io optional (#569)
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Web/Controllers/IndexController.cs11
-rw-r--r--src/SMAPI.Web/Controllers/LogParserController.cs10
-rw-r--r--src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs (renamed from src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs)7
-rw-r--r--src/SMAPI.Web/Startup.cs2
-rw-r--r--src/SMAPI.Web/Views/Shared/_Layout.cshtml6
-rw-r--r--src/SMAPI.Web/appsettings.Development.json7
-rw-r--r--src/SMAPI.Web/appsettings.json9
7 files changed, 34 insertions, 18 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;
}
diff --git a/src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs
index 117462f4..3d428015 100644
--- a/src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs
+++ b/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs
@@ -1,7 +1,7 @@
namespace StardewModdingAPI.Web.Framework.ConfigModels
{
- /// <summary>The config settings for the app context.</summary>
- public class ContextConfig // must be public to pass into views
+ /// <summary>The site config settings.</summary>
+ public class SiteConfig // must be public to pass into views
{
/*********
** Accessors
@@ -11,5 +11,8 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels
/// <summary>The root URL for the log parser.</summary>
public string LogParserUrl { get; set; }
+
+ /// <summary>Whether to show SMAPI beta versions on the main page, if any.</summary>
+ public bool EnableSmapiBeta { get; set; }
}
}
diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs
index ced6e1c7..bf3ec9a1 100644
--- a/src/SMAPI.Web/Startup.cs
+++ b/src/SMAPI.Web/Startup.cs
@@ -50,7 +50,7 @@ namespace StardewModdingAPI.Web
// init configuration
services
.Configure<ModUpdateCheckConfig>(this.Configuration.GetSection("ModUpdateCheck"))
- .Configure<ContextConfig>(this.Configuration.GetSection("Context"))
+ .Configure<SiteConfig>(this.Configuration.GetSection("Site"))
.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 d435e760..29da9100 100644
--- a/src/SMAPI.Web/Views/Shared/_Layout.cshtml
+++ b/src/SMAPI.Web/Views/Shared/_Layout.cshtml
@@ -1,6 +1,6 @@
@using Microsoft.Extensions.Options
@using StardewModdingAPI.Web.Framework.ConfigModels
-@inject IOptions<ContextConfig> ContextConfig
+@inject IOptions<SiteConfig> SiteConfig
<!DOCTYPE html>
<html>
@@ -15,8 +15,8 @@
<div id="sidebar">
<h4>SMAPI</h4>
<ul>
- <li><a href="@ContextConfig.Value.RootUrl">About SMAPI</a></li>
- <li><a href="@ContextConfig.Value.LogParserUrl">Log parser</a></li>
+ <li><a href="@SiteConfig.Value.RootUrl">About SMAPI</a></li>
+ <li><a href="@SiteConfig.Value.LogParserUrl">Log parser</a></li>
<li><a href="https://stardewvalleywiki.com/Modding:Index">Docs</a></li>
</ul>
</div>
diff --git a/src/SMAPI.Web/appsettings.Development.json b/src/SMAPI.Web/appsettings.Development.json
index 495af120..67bb7748 100644
--- a/src/SMAPI.Web/appsettings.Development.json
+++ b/src/SMAPI.Web/appsettings.Development.json
@@ -16,10 +16,13 @@
"Microsoft": "Information"
}
},
- "Context": {
+
+ "Site": {
"RootUrl": "http://localhost:59482/",
- "LogParserUrl": "http://localhost:59482/log/"
+ "LogParserUrl": "http://localhost:59482/log/",
+ "EnableSmapiBeta": false
},
+
"ApiClients": {
"GitHubUsername": null,
"GitHubPassword": null,
diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json
index 837ba536..9e3270ae 100644
--- a/src/SMAPI.Web/appsettings.json
+++ b/src/SMAPI.Web/appsettings.json
@@ -13,10 +13,13 @@
"Default": "Warning"
}
},
- "Context": {
- "RootUrl": null, // see top note
- "LogParserUrl": null // see top note
+
+ "Site": {
+ "RootUrl": null, // see top note
+ "LogParserUrl": null, // see top note
+ "EnableSmapiBeta": null // see top note
},
+
"ApiClients": {
"UserAgent": "SMAPI/{0} (+https://smapi.io)",