add basic download page (#411)
This commit is contained in:
parent
bbd021f873
commit
adee66b3b4
|
@ -0,0 +1,79 @@
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using StardewModdingAPI.Web.Framework.Clients.GitHub;
|
||||||
|
using StardewModdingAPI.Web.ViewModels;
|
||||||
|
|
||||||
|
namespace StardewModdingAPI.Web.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>Provides an info/download page about SMAPI.</summary>
|
||||||
|
[Route("")]
|
||||||
|
[Route("install")]
|
||||||
|
internal class IndexController : Controller
|
||||||
|
{
|
||||||
|
/*********
|
||||||
|
** Properties
|
||||||
|
*********/
|
||||||
|
/// <summary>The GitHub API client.</summary>
|
||||||
|
private readonly IGitHubClient GitHub;
|
||||||
|
|
||||||
|
|
||||||
|
/*********
|
||||||
|
** Public methods
|
||||||
|
*********/
|
||||||
|
/// <summary>Construct an instance.</summary>
|
||||||
|
/// <param name="github">The GitHub API client.</param>
|
||||||
|
public IndexController(IGitHubClient github)
|
||||||
|
{
|
||||||
|
this.GitHub = github;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Display the index page.</summary>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ViewResult> Index()
|
||||||
|
{
|
||||||
|
// fetch latest SMAPI release
|
||||||
|
GitRelease release = await this.GitHub.GetLatestReleaseAsync("Pathoschild/SMAPI");
|
||||||
|
string downloadUrl = this.GetMainDownloadUrl(release);
|
||||||
|
string devDownloadUrl = this.GetDevDownloadUrl(release);
|
||||||
|
|
||||||
|
// render view
|
||||||
|
var model = new IndexModel(release.Name, release.Body, downloadUrl, devDownloadUrl);
|
||||||
|
return this.View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********
|
||||||
|
** Private methods
|
||||||
|
*********/
|
||||||
|
/// <summary>Get the main download URL for a SMAPI release.</summary>
|
||||||
|
/// <param name="release">The SMAPI release.</param>
|
||||||
|
private string GetMainDownloadUrl(GitRelease release)
|
||||||
|
{
|
||||||
|
// get main download URL
|
||||||
|
foreach (GitAsset asset in release.Assets ?? new GitAsset[0])
|
||||||
|
{
|
||||||
|
if (Regex.IsMatch(asset.FileName, @"SMAPI-[\d\.]+-installer.zip"))
|
||||||
|
return asset.DownloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback just in case
|
||||||
|
return "https://github.com/pathoschild/SMAPI/releases";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Get the for-developers download URL for a SMAPI release.</summary>
|
||||||
|
/// <param name="release">The SMAPI release.</param>
|
||||||
|
private string GetDevDownloadUrl(GitRelease release)
|
||||||
|
{
|
||||||
|
// get dev download URL
|
||||||
|
foreach (GitAsset asset in release.Assets ?? new GitAsset[0])
|
||||||
|
{
|
||||||
|
if (Regex.IsMatch(asset.FileName, @"SMAPI-[\d\.]+-installer-for-developers.zip"))
|
||||||
|
return asset.DownloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback just in case
|
||||||
|
return "https://github.com/pathoschild/SMAPI/releases";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,7 +50,6 @@ namespace StardewModdingAPI.Web.Controllers
|
||||||
/// <summary>Render the log parser UI.</summary>
|
/// <summary>Render the log parser UI.</summary>
|
||||||
/// <param name="id">The paste ID.</param>
|
/// <param name="id">The paste ID.</param>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("")]
|
|
||||||
[Route("log")]
|
[Route("log")]
|
||||||
[Route("log/{id}")]
|
[Route("log/{id}")]
|
||||||
public ViewResult Index(string id = null)
|
public ViewResult Index(string id = null)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace StardewModdingAPI.Web.Framework.Clients.GitHub
|
||||||
|
{
|
||||||
|
/// <summary>A GitHub download attached to a release.</summary>
|
||||||
|
internal class GitAsset
|
||||||
|
{
|
||||||
|
/// <summary>The file name.</summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string FileName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The file content type.</summary>
|
||||||
|
[JsonProperty("content_type")]
|
||||||
|
public string ContentType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The download URL.</summary>
|
||||||
|
[JsonProperty("browser_download_url")]
|
||||||
|
public string DownloadUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,5 +15,11 @@ namespace StardewModdingAPI.Web.Framework.Clients.GitHub
|
||||||
/// <summary>The semantic version string.</summary>
|
/// <summary>The semantic version string.</summary>
|
||||||
[JsonProperty("tag_name")]
|
[JsonProperty("tag_name")]
|
||||||
public string Tag { get; set; }
|
public string Tag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The Markdown description for the release.</summary>
|
||||||
|
public string Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The attached files.</summary>
|
||||||
|
public GitAsset[] Assets { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "log",
|
"launchUrl": "",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.6.0" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.6.0" />
|
||||||
|
<PackageReference Include="Markdig" Version="0.14.8" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.0.0" />
|
||||||
|
|
|
@ -134,7 +134,6 @@ namespace StardewModdingAPI.Web
|
||||||
|
|
||||||
// shortcut redirects
|
// shortcut redirects
|
||||||
.Add(new RedirectToUrlRule("^/docs$", "https://stardewvalleywiki.com/Modding:Index"))
|
.Add(new RedirectToUrlRule("^/docs$", "https://stardewvalleywiki.com/Modding:Index"))
|
||||||
.Add(new RedirectToUrlRule("^/install$", "https://stardewvalleywiki.com/Modding:Installing_SMAPI"))
|
|
||||||
)
|
)
|
||||||
.UseStaticFiles() // wwwroot folder
|
.UseStaticFiles() // wwwroot folder
|
||||||
.UseMvc();
|
.UseMvc();
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
namespace StardewModdingAPI.Web.ViewModels
|
||||||
|
{
|
||||||
|
/// <summary>The view model for the index page.</summary>
|
||||||
|
public class IndexModel
|
||||||
|
{
|
||||||
|
/*********
|
||||||
|
** Accessors
|
||||||
|
*********/
|
||||||
|
/// <summary>The latest SMAPI version.</summary>
|
||||||
|
public string LatestVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The Markdown description for the release.</summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The main download URL.</summary>
|
||||||
|
public string DownloadUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>The for-developers download URL.</summary>
|
||||||
|
public string DevDownloadUrl { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/*********
|
||||||
|
** Public methods
|
||||||
|
*********/
|
||||||
|
/// <summary>Construct an instance.</summary>
|
||||||
|
public IndexModel() { }
|
||||||
|
|
||||||
|
/// <summary>Construct an instance.</summary>
|
||||||
|
/// <param name="latestVersion">The latest SMAPI version.</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.</param>
|
||||||
|
internal IndexModel(string latestVersion, string description, string downloadUrl, string devDownloadUrl)
|
||||||
|
{
|
||||||
|
this.LatestVersion = latestVersion;
|
||||||
|
this.Description = description;
|
||||||
|
this.DownloadUrl = downloadUrl;
|
||||||
|
this.DevDownloadUrl = devDownloadUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "SMAPI";
|
||||||
|
}
|
||||||
|
@model StardewModdingAPI.Web.ViewModels.IndexModel
|
||||||
|
|
||||||
|
<style>
|
||||||
|
li.main-download * {
|
||||||
|
font-size: 1.2em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.main-download img {
|
||||||
|
height: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-description .noinclude {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
li small {
|
||||||
|
display: block;
|
||||||
|
width: 50em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
SMAPI is the modding API for Stardew Valley. It works fine with Steam achievements and the
|
||||||
|
overlay, you can uninstall it anytime, and there's a friendly community if you need help. It's
|
||||||
|
a cool boy.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>Download and links</h2>
|
||||||
|
<ul>
|
||||||
|
<li class="main-download"><a href="@Model.DownloadUrl">Download SMAPI @Model.LatestVersion</a> <img src="favicon.ico" /></li>
|
||||||
|
<li><a href="https://stardewvalleywiki.com/Modding:Installing_SMAPI">Install guide</a></li>
|
||||||
|
<li><a href="https://stardewvalleywiki.com/Modding:Player_FAQs">FAQs</a></li>
|
||||||
|
<li><a href="https://stardewvalleywiki.com/Modding:SMAPI_compatibility">Mod compatibility list</a></li>
|
||||||
|
<li>Get help <a href="https://stardewvalleywiki.com/Modding:Community#Discord">on Discord</a> or <a href="https://community.playstarbound.com/threads/smapi-stardew-modding-api.108375/">in the forums</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>What's new in SMAPI @Model.LatestVersion?</h2>
|
||||||
|
<div class="github-description">
|
||||||
|
@Html.Raw(Markdig.Markdown.ToHtml(Model.Description))
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Support SMAPI ♥</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://www.paypal.me/pathoschild">Donate once</a></li>
|
||||||
|
<li>
|
||||||
|
<a href="https://www.patreon.com/pathoschild">Donate $1+/month</a><br />
|
||||||
|
<small>You'll have access to all private posts about behind-the-scenes info, upcoming features, and early previews of SMAPI updates. You can optionally provide early feedback on SMAPI features to influence development.</small>
|
||||||
|
</li>
|
||||||
|
<li><a href="https://github.com/Pathoschild/SMAPI">Contribute to the code</a></li>
|
||||||
|
<li><a href="https://community.playstarbound.com/threads/108375">Discuss, give feedback, or report bugs in the forums</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Special thanks to
|
||||||
|
acerbicon,
|
||||||
|
<a href="https://www.nexusmods.com/stardewvalley/users/31393530">ChefRude</a>,
|
||||||
|
jwdred,
|
||||||
|
<a href="http://community.playstarbound.com/members/karmylla.637910/">Karmylla</a>,
|
||||||
|
OfficialPiAddict,
|
||||||
|
Robby LaFarge,
|
||||||
|
and a few anonymous users for supporting SMAPI; you're awesome!
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>For mod creators</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="@Model.DevDownloadUrl">SMAPI 2.2 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>Need help? Come <a href="https://stardewvalleywiki.com/Modding:Community#Discord">chat on Discord</a>.</li>
|
||||||
|
</ul>
|
Loading…
Reference in New Issue