From b64cec918d1511b6b71c9d2e30f987e9b5cc24fd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 27 Nov 2021 22:45:14 -0500 Subject: remove direct download for beta versions With this change, only the main version has a direct download. Showing beta info here caused a few issues: * The vast majority of players don't use the game beta, so they were often confused about which version to download. * Beta versions typically have much longer release info (e.g. detailed summary, release notes, caveats and warnings, etc), and the extra download button made the player guide button under it less prominent and visible. Those both contributed to information overload and the above confusion. * Unlike main versions, beta versions aren't permanently archived on GitHub (since the beta branch is routinely rebased onto the latest stable update). That makes it messy to manage beta releases through GitHub. Instead there's now a message under the download button which clearly links to where the beta version can be downloaded. --- src/SMAPI.Web/Controllers/IndexController.cs | 52 +++++--------------- src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs | 7 +-- src/SMAPI.Web/ViewModels/IndexModel.cs | 15 ++---- src/SMAPI.Web/Views/Index/Index.cshtml | 57 +++++----------------- src/SMAPI.Web/appsettings.json | 3 +- src/SMAPI.Web/wwwroot/Content/css/index.css | 4 ++ 6 files changed, 35 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/SMAPI.Web/Controllers/IndexController.cs b/src/SMAPI.Web/Controllers/IndexController.cs index 080285ab..f2f4c342 100644 --- a/src/SMAPI.Web/Controllers/IndexController.cs +++ b/src/SMAPI.Web/Controllers/IndexController.cs @@ -57,21 +57,16 @@ namespace StardewModdingAPI.Web.Controllers { // choose versions ReleaseVersion[] versions = await this.GetReleaseVersionsAsync(); - ReleaseVersion stableVersion = versions.LastOrDefault(version => !version.IsBeta && !version.IsForDevs); - ReleaseVersion stableVersionForDevs = versions.LastOrDefault(version => !version.IsBeta && version.IsForDevs); - ReleaseVersion betaVersion = versions.LastOrDefault(version => version.IsBeta && !version.IsForDevs); - ReleaseVersion betaVersionForDevs = versions.LastOrDefault(version => version.IsBeta && version.IsForDevs); + ReleaseVersion stableVersion = versions.LastOrDefault(version => !version.IsForDevs); + ReleaseVersion stableVersionForDevs = versions.LastOrDefault(version => version.IsForDevs); // render view 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 && this.SiteConfig.BetaEnabled - ? new IndexVersionModel(betaVersion.Version.ToString(), betaVersion.Release.Body, betaVersion.Asset.DownloadUrl, betaVersionForDevs?.Asset.DownloadUrl) - : null; + : new IndexVersionModel("unknown", "", "https://github.com/Pathoschild/SMAPI/releases", null); // just in case something goes wrong // render view - var model = new IndexModel(stableVersionModel, betaVersionModel, this.SiteConfig.BetaBlurb, this.SiteConfig.SupporterList); + var model = new IndexModel(stableVersionModel, this.SiteConfig.OtherBlurb, this.SiteConfig.SupporterList); return this.View(model); } @@ -93,27 +88,12 @@ namespace StardewModdingAPI.Web.Controllers { entry.AbsoluteExpiration = DateTimeOffset.UtcNow.Add(this.CacheTime); - // get latest release (whether preview or stable) - GitRelease stableRelease = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: true); + // get latest stable release + GitRelease release = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: false); - // split stable/prerelease if applicable - GitRelease betaRelease = null; - if (stableRelease.IsPrerelease) + // strip 'noinclude' blocks from release description + if (release != null) { - GitRelease result = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: false); - if (result != null) - { - betaRelease = stableRelease; - stableRelease = result; - } - } - - // strip 'noinclude' blocks from release descriptions - foreach (GitRelease release in new[] { stableRelease, betaRelease }) - { - if (release == null) - continue; - HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(release.Body); foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//*[@class='noinclude']")?.ToArray() ?? new HtmlNode[0]) @@ -122,10 +102,8 @@ namespace StardewModdingAPI.Web.Controllers } // get versions - ReleaseVersion[] stableVersions = this.ParseReleaseVersions(stableRelease).ToArray(); - ReleaseVersion[] betaVersions = this.ParseReleaseVersions(betaRelease).ToArray(); - return stableVersions - .Concat(betaVersions) + return this + .ParseReleaseVersions(release) .OrderBy(p => p.Version) .ToArray(); }); @@ -146,10 +124,9 @@ namespace StardewModdingAPI.Web.Controllers Match match = Regex.Match(asset.FileName, @"SMAPI-(?[\d\.]+(?:-.+)?)-installer(?-for-developers)?.zip"); if (!match.Success || !SemanticVersion.TryParse(match.Groups["version"].Value, out ISemanticVersion version)) continue; - bool isBeta = version.IsPrerelease(); bool isForDevs = match.Groups["forDevs"].Success; - yield return new ReleaseVersion(release, asset, version, isBeta, isForDevs); + yield return new ReleaseVersion(release, asset, version, isForDevs); } } @@ -168,9 +145,6 @@ namespace StardewModdingAPI.Web.Controllers /// The SMAPI version. public ISemanticVersion Version { get; } - /// Whether this is a beta download. - public bool IsBeta { get; } - /// Whether this is a 'for developers' download. public bool IsForDevs { get; } @@ -182,14 +156,12 @@ namespace StardewModdingAPI.Web.Controllers /// The underlying GitHub release. /// The underlying download asset. /// The SMAPI version. - /// Whether this is a beta download. /// Whether this is a 'for developers' download. - public ReleaseVersion(GitRelease release, GitAsset asset, ISemanticVersion version, bool isBeta, bool isForDevs) + public ReleaseVersion(GitRelease release, GitAsset asset, ISemanticVersion version, bool isForDevs) { this.Release = release; this.Asset = asset; this.Version = version; - this.IsBeta = isBeta; this.IsForDevs = isForDevs; } } diff --git a/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs index 43969f51..664dbef3 100644 --- a/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs +++ b/src/SMAPI.Web/Framework/ConfigModels/SiteConfig.cs @@ -6,11 +6,8 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels /********* ** Accessors *********/ - /// Whether to show SMAPI beta versions on the main page, if any. - public bool BetaEnabled { get; set; } - - /// A short sentence shown under the beta download button, if any. - public string BetaBlurb { get; set; } + /// A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format. + public string OtherBlurb { get; set; } /// A list of supports to credit on the main page, in Markdown format. public string SupporterList { get; set; } diff --git a/src/SMAPI.Web/ViewModels/IndexModel.cs b/src/SMAPI.Web/ViewModels/IndexModel.cs index 450fdc0e..d8d2d27f 100644 --- a/src/SMAPI.Web/ViewModels/IndexModel.cs +++ b/src/SMAPI.Web/ViewModels/IndexModel.cs @@ -9,11 +9,8 @@ namespace StardewModdingAPI.Web.ViewModels /// The latest stable SMAPI version. public IndexVersionModel StableVersion { get; set; } - /// The latest prerelease SMAPI version (if newer than ). - public IndexVersionModel BetaVersion { get; set; } - - /// A short sentence shown under the beta download button, if any. - public string BetaBlurb { get; set; } + /// A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format. + public string OtherBlurb { get; set; } /// A list of supports to credit on the main page, in Markdown format. public string SupporterList { get; set; } @@ -27,14 +24,12 @@ namespace StardewModdingAPI.Web.ViewModels /// Construct an instance. /// The latest stable SMAPI version. - /// The latest prerelease SMAPI version (if newer than ). - /// A short sentence shown under the beta download button, if any. + /// A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format. /// A list of supports to credit on the main page, in Markdown format. - internal IndexModel(IndexVersionModel stableVersion, IndexVersionModel betaVersion, string betaBlurb, string supporterList) + internal IndexModel(IndexVersionModel stableVersion, string otherBlurb, string supporterList) { this.StableVersion = stableVersion; - this.BetaVersion = betaVersion; - this.BetaBlurb = betaBlurb; + this.OtherBlurb = otherBlurb; this.SupporterList = supporterList; } } diff --git a/src/SMAPI.Web/Views/Index/Index.cshtml b/src/SMAPI.Web/Views/Index/Index.cshtml index 9d6e4bed..669cfd99 100644 --- a/src/SMAPI.Web/Views/Index/Index.cshtml +++ b/src/SMAPI.Web/Views/Index/Index.cshtml @@ -8,9 +8,9 @@ ViewData["ViewTitle"] = string.Empty; } @section Head { - + - + }

@@ -29,25 +29,12 @@ Download from Nexus Direct download -
- - @if (Model.BetaVersion != null) + + + @if (Model.OtherBlurb != null) { -
+
@Html.Raw(Markdig.Markdown.ToHtml(Model.OtherBlurb))
} -
@@ -61,29 +48,11 @@
- @if (Model.BetaVersion == null) - { -

What's new

-
- @Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description)) -
-

See the release notes and mod compatibility list for more info.

- } - else - { -

What's new in...

-

SMAPI @Model.StableVersion.Version?

-
- @Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description)) -
-

See the release notes and mod compatibility list for more info.

- -

SMAPI @Model.BetaVersion.Version?

-
- @Html.Raw(Markdig.Markdown.ToHtml(Model.BetaVersion.Description)) -
-

See the release notes and mod compatibility list for more info.

- } +

What's new

+
+ @Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description)) +
+

See the release notes and mod compatibility list for more info.

@@ -122,10 +91,6 @@

For mod creators

diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index 22fd7396..1837170b 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -17,8 +17,7 @@ "Site": { "BetaEnabled": false, - "BetaBlurb": null, - "SupporterList": null + "OtherBlurb": null }, "ApiClients": { diff --git a/src/SMAPI.Web/wwwroot/Content/css/index.css b/src/SMAPI.Web/wwwroot/Content/css/index.css index 1cf8d261..150ccc0a 100644 --- a/src/SMAPI.Web/wwwroot/Content/css/index.css +++ b/src/SMAPI.Web/wwwroot/Content/css/index.css @@ -97,6 +97,10 @@ h1 { display: block; } +.cta-blurb { + font-size: 0.85em; +} + .sublinks { font-size: 0.9em; margin-bottom: 1em; -- cgit