Skip to content

Commit

Permalink
tweak GitHub download link to match other sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Mar 25, 2024
1 parent 588ed41 commit e92feaa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/SMAPI.Web/Controllers/IndexController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public async Task<ViewResult> Index()

// 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
? new IndexVersionModel(stableVersion.Version.ToString(), stableVersion.Release.Body, stableVersion.Release.WebUrl, stableVersion.Asset.DownloadUrl, stableVersionForDevs?.Asset.DownloadUrl)
: new IndexVersionModel("unknown", "", "https://github.com/Pathoschild/SMAPI/releases", "https://github.com/Pathoschild/SMAPI/releases", null); // just in case something goes wrong

// render view
var model = new IndexModel(stableVersionModel, this.SiteConfig.OtherBlurb, this.SiteConfig.SupporterList);
Expand Down
8 changes: 7 additions & 1 deletion src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ internal class GitRelease
[JsonProperty("tag_name")]
public string Tag { get; }

/// <summary>The URL to the release web page.</summary>
[JsonProperty("html_url")]
public string WebUrl { get; }

/// <summary>The Markdown description for the release.</summary>
public string Body { get; internal set; }

Expand All @@ -38,14 +42,16 @@ internal class GitRelease
/// <summary>Construct an instance.</summary>
/// <param name="name">The display name.</param>
/// <param name="tag">The semantic version string.</param>
/// <param name="webUrl">The URL to the release web page.</param>
/// <param name="body">The Markdown description for the release.</param>
/// <param name="isDraft">Whether this is a draft version.</param>
/// <param name="isPrerelease">Whether this is a prerelease version.</param>
/// <param name="assets">The attached files.</param>
public GitRelease(string name, string tag, string? body, bool isDraft, bool isPrerelease, GitAsset[]? assets)
public GitRelease(string name, string tag, string webUrl, string? body, bool isDraft, bool isPrerelease, GitAsset[]? assets)
{
this.Name = name;
this.Tag = tag;
this.WebUrl = webUrl;
this.Body = body ?? string.Empty;
this.IsDraft = isDraft;
this.IsPrerelease = isPrerelease;
Expand Down
15 changes: 10 additions & 5 deletions src/SMAPI.Web/ViewModels/IndexVersionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public class IndexVersionModel
/// <summary>The Markdown description for the release.</summary>
public string Description { get; }

/// <summary>The main download URL.</summary>
/// <summary>The URL to the download page.</summary>
public string WebUrl { get; }

/// <summary>The direct download URL for the main version.</summary>
public string DownloadUrl { get; }

/// <summary>The for-developers download URL (not applicable for prerelease versions).</summary>
/// <summary>The direct download URL for the for-developers version. Not applicable for prerelease versions.</summary>
public string? DevDownloadUrl { get; }


Expand All @@ -25,12 +28,14 @@ public class IndexVersionModel
/// <summary>Construct an instance.</summary>
/// <param name="version">The release number.</param>
/// <param name="description">The Markdown description for the release.</param>
/// <param name="downloadUrl">The main download URL.</param>
/// <param name="devDownloadUrl">The for-developers download URL (not applicable for prerelease versions).</param>
internal IndexVersionModel(string version, string description, string downloadUrl, string? devDownloadUrl)
/// <param name="webUrl">The URL to the download page.</param>
/// <param name="downloadUrl">The direct download URL for the main version.</param>
/// <param name="devDownloadUrl">The direct download URL for the for-developers version. Not applicable for prerelease versions.</param>
internal IndexVersionModel(string version, string description, string webUrl, string downloadUrl, string? devDownloadUrl)
{
this.Version = version;
this.Description = description;
this.WebUrl = webUrl;
this.DownloadUrl = downloadUrl;
this.DevDownloadUrl = devDownloadUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SMAPI.Web/Views/Index/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<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="https://www.curseforge.com/stardewvalley/utility/smapi"><img src="Content/images/curseforge-icon.png" /> Download from CurseForge</a>
<a href="@Model.StableVersion.DownloadUrl"><img src="Content/images/github-logo.png" /> Download from GitHub</a>
<a href="@Model.StableVersion.WebUrl"><img src="Content/images/github-logo.png" /> Download from GitHub</a>
</div>
</div>
<div><a href="https://stardewvalleywiki.com/Modding:Player_Guide" class="secondary-cta">Player guide</a></div>
Expand Down

0 comments on commit e92feaa

Please sign in to comment.