From 1ae1a2620ea0a9bda730b9b1a92145a9e255f9b3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 Jun 2018 15:02:25 -0400 Subject: make web layout more responsive --- src/SMAPI.Web/Views/Shared/_Layout.cshtml | 1 + 1 file changed, 1 insertion(+) (limited to 'src/SMAPI.Web/Views/Shared') diff --git a/src/SMAPI.Web/Views/Shared/_Layout.cshtml b/src/SMAPI.Web/Views/Shared/_Layout.cshtml index ac98c71b..d435e760 100644 --- a/src/SMAPI.Web/Views/Shared/_Layout.cshtml +++ b/src/SMAPI.Web/Views/Shared/_Layout.cshtml @@ -6,6 +6,7 @@ + @ViewData["Title"] - SMAPI.io @RenderSection("Head", required: false) -- cgit From 84d52b1735204550c6369270c03f61944c2c88bd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 29 Jul 2018 12:43:04 -0400 Subject: make beta version on smapi.io optional (#569) --- src/SMAPI.Web/Controllers/IndexController.cs | 11 +++++++++-- src/SMAPI.Web/Controllers/LogParserController.cs | 10 +++++----- src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs | 15 --------------- src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs | 18 ++++++++++++++++++ src/SMAPI.Web/Startup.cs | 2 +- src/SMAPI.Web/Views/Shared/_Layout.cshtml | 6 +++--- src/SMAPI.Web/appsettings.Development.json | 7 +++++-- src/SMAPI.Web/appsettings.json | 9 ++++++--- 8 files changed, 47 insertions(+), 31 deletions(-) delete mode 100644 src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs create mode 100644 src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs (limited to 'src/SMAPI.Web/Views/Shared') 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 *********/ + /// The site config settings. + private readonly SiteConfig SiteConfig; + /// The cache in which to store release data. private readonly IMemoryCache Cache; @@ -39,10 +44,12 @@ namespace StardewModdingAPI.Web.Controllers /// Construct an instance. /// The cache in which to store release data. /// The GitHub API client. - public IndexController(IMemoryCache cache, IGitHubClient github) + /// The context config settings. + public IndexController(IMemoryCache cache, IGitHubClient github, IOptions siteConfig) { this.Cache = cache; this.GitHub = github; + this.SiteConfig = siteConfig.Value; } /// Display the index page. @@ -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 *********/ - /// The log parser config settings. - private readonly ContextConfig Config; + /// The site config settings. + private readonly SiteConfig Config; /// The underlying Pastebin client. private readonly IPastebinClient Pastebin; @@ -39,11 +39,11 @@ namespace StardewModdingAPI.Web.Controllers ** Constructor ***/ /// Construct an instance. - /// The context config settings. + /// The context config settings. /// The Pastebin API client. - public LogParserController(IOptions contextProvider, IPastebinClient pastebin) + public LogParserController(IOptions 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/ContextConfig.cs deleted file mode 100644 index 117462f4..00000000 --- a/src/SMAPI.Web/Framework/ConfigModels/ContextConfig.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace StardewModdingAPI.Web.Framework.ConfigModels -{ - /// The config settings for the app context. - public class ContextConfig // must be public to pass into views - { - /********* - ** Accessors - *********/ - /// The root URL for the app. - public string RootUrl { get; set; } - - /// The root URL for the log parser. - public string LogParserUrl { get; set; } - } -} diff --git a/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs new file mode 100644 index 00000000..3d428015 --- /dev/null +++ b/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs @@ -0,0 +1,18 @@ +namespace StardewModdingAPI.Web.Framework.ConfigModels +{ + /// The site config settings. + public class SiteConfig // must be public to pass into views + { + /********* + ** Accessors + *********/ + /// The root URL for the app. + public string RootUrl { get; set; } + + /// The root URL for the log parser. + public string LogParserUrl { get; set; } + + /// Whether to show SMAPI beta versions on the main page, if any. + 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(this.Configuration.GetSection("ModUpdateCheck")) - .Configure(this.Configuration.GetSection("Context")) + .Configure(this.Configuration.GetSection("Site")) .Configure(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 +@inject IOptions SiteConfig @@ -15,8 +15,8 @@ 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)", -- cgit