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.
This commit is contained in:
Jesse Plamondon-Willard 2021-11-27 22:45:14 -05:00
parent 12e0c15196
commit b64cec918d
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
6 changed files with 36 additions and 104 deletions

View File

@ -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-(?<version>[\d\.]+(?:-.+)?)-installer(?<forDevs>-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
/// <summary>The SMAPI version.</summary>
public ISemanticVersion Version { get; }
/// <summary>Whether this is a beta download.</summary>
public bool IsBeta { get; }
/// <summary>Whether this is a 'for developers' download.</summary>
public bool IsForDevs { get; }
@ -182,14 +156,12 @@ namespace StardewModdingAPI.Web.Controllers
/// <param name="release">The underlying GitHub release.</param>
/// <param name="asset">The underlying download asset.</param>
/// <param name="version">The SMAPI version.</param>
/// <param name="isBeta">Whether this is a beta download.</param>
/// <param name="isForDevs">Whether this is a 'for developers' download.</param>
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;
}
}

View File

@ -6,11 +6,8 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels
/*********
** Accessors
*********/
/// <summary>Whether to show SMAPI beta versions on the main page, if any.</summary>
public bool BetaEnabled { get; set; }
/// <summary>A short sentence shown under the beta download button, if any.</summary>
public string BetaBlurb { get; set; }
/// <summary>A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format.</summary>
public string OtherBlurb { get; set; }
/// <summary>A list of supports to credit on the main page, in Markdown format.</summary>
public string SupporterList { get; set; }

View File

@ -9,11 +9,8 @@ namespace StardewModdingAPI.Web.ViewModels
/// <summary>The latest stable SMAPI version.</summary>
public IndexVersionModel StableVersion { get; set; }
/// <summary>The latest prerelease SMAPI version (if newer than <see cref="StableVersion"/>).</summary>
public IndexVersionModel BetaVersion { get; set; }
/// <summary>A short sentence shown under the beta download button, if any.</summary>
public string BetaBlurb { get; set; }
/// <summary>A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format.</summary>
public string OtherBlurb { get; set; }
/// <summary>A list of supports to credit on the main page, in Markdown format.</summary>
public string SupporterList { get; set; }
@ -27,14 +24,12 @@ namespace StardewModdingAPI.Web.ViewModels
/// <summary>Construct an instance.</summary>
/// <param name="stableVersion">The latest stable SMAPI version.</param>
/// <param name="betaVersion">The latest prerelease SMAPI version (if newer than <paramref name="stableVersion"/>).</param>
/// <param name="betaBlurb">A short sentence shown under the beta download button, if any.</param>
/// <param name="otherBlurb">A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format.</param>
/// <param name="supporterList">A list of supports to credit on the main page, in Markdown format.</param>
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;
}
}

View File

@ -8,9 +8,9 @@
ViewData["ViewTitle"] = string.Empty;
}
@section Head {
<link rel="stylesheet" href="~/Content/css/index.css?r=20200105" />
<link rel="stylesheet" href="~/Content/css/index.css" />
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1" crossorigin="anonymous"></script>
<script src="~/Content/js/index.js?r=20200105"></script>
<script src="~/Content/js/index.js"></script>
}
<h1>
@ -29,25 +29,12 @@
<a href="https://www.nexusmods.com/stardewvalley/mods/2400"><img src="Content/images/nexus-icon.png" /> Download from Nexus</a>
<a href="@Model.StableVersion.DownloadUrl"><img src="Content/images/direct-download-icon.png" /> Direct download</a>
</div>
</div><br />
@if (Model.BetaVersion != null)
{
<div class="cta-dropdown secondary-cta-dropdown">
<a href="@Model.BetaVersion.DownloadUrl" class="secondary-cta download">
Download SMAPI @Model.BetaVersion.Version
@if (!string.IsNullOrWhiteSpace(Model.BetaBlurb))
{
<br /><small>@Model.BetaBlurb</small>
}
</a><br />
<div class="dropdown-content">
<a href="https://www.nexusmods.com/stardewvalley/mods/2400"><img src="Content/images/nexus-icon.png" /> Download from Nexus</a>
<a href="@Model.BetaVersion.DownloadUrl"><img src="Content/images/direct-download-icon.png" /> Direct download</a>
</div>
</div><br />
}
<div><a href="https://stardewvalleywiki.com/Modding:Player_Guide" class="secondary-cta">Player guide</a></div>
@if (Model.OtherBlurb != null)
{
<div>@Html.Raw(Markdig.Markdown.ToHtml(Model.OtherBlurb))</div>
}
</div>
<div class="area">
@ -61,29 +48,11 @@
</div>
<div class="area">
@if (Model.BetaVersion == null)
{
<h2 id="whatsnew">What's new</h2>
<div class="github-description">
@Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description))
</div>
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.PlainAction("Index", "Mods")">mod compatibility list</a> for more info.</p>
}
else
{
<h2 id="whatsnew">What's new in...</h2>
<h3>SMAPI @Model.StableVersion.Version?</h3>
<div class="github-description">
@Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description))
</div>
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.PlainAction("Index", "Mods")">mod compatibility list</a> for more info.</p>
<h3>SMAPI @Model.BetaVersion.Version?</h3>
<div class="github-description">
@Html.Raw(Markdig.Markdown.ToHtml(Model.BetaVersion.Description))
</div>
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.PlainAction("Index", "Mods")">mod compatibility list</a> for more info.</p>
}
</div>
<div class="area">
@ -122,10 +91,6 @@
<h2 id="modcreators">For mod creators</h2>
<ul>
<li><a href="@Model.StableVersion.DevDownloadUrl">SMAPI @Model.StableVersion.Version for developers</a> (includes <a href="https://docs.microsoft.com/en-us/visualstudio/ide/using-intellisense">intellisense</a> and full console output)</li>
@if (Model.BetaVersion != null)
{
<li><a href="@Model.BetaVersion.DevDownloadUrl">SMAPI @Model.BetaVersion.Version for developers</a> (includes <a href="https://docs.microsoft.com/en-us/visualstudio/ide/using-intellisense">intellisense</a> and full console output)</li>
}
<li><a href="https://stardewvalleywiki.com/Modding:Index">Modding documentation</a></li>
<li><a href="https://github.com/Pathoschild/SMAPI">Source code</a></li>
</ul>

View File

@ -17,8 +17,7 @@
"Site": {
"BetaEnabled": false,
"BetaBlurb": null,
"SupporterList": null
"OtherBlurb": null
},
"ApiClients": {

View File

@ -97,6 +97,10 @@ h1 {
display: block;
}
.cta-blurb {
font-size: 0.85em;
}
.sublinks {
font-size: 0.9em;
margin-bottom: 1em;