summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Controllers
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-10-20 15:10:44 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-10-20 15:10:44 -0400
commit28fdb9e4e7f5419947226171bf6d7efa273802c5 (patch)
tree26231b40f1e6c338e00f420b1856ae298dceea7c /src/SMAPI.Web/Controllers
parentf09befe24047de8187276c722557b6f0fddd6e35 (diff)
downloadSMAPI-28fdb9e4e7f5419947226171bf6d7efa273802c5.tar.gz
SMAPI-28fdb9e4e7f5419947226171bf6d7efa273802c5.tar.bz2
SMAPI-28fdb9e4e7f5419947226171bf6d7efa273802c5.zip
add mod compatibility page (#597)
Diffstat (limited to 'src/SMAPI.Web/Controllers')
-rw-r--r--src/SMAPI.Web/Controllers/ModsController.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsController.cs b/src/SMAPI.Web/Controllers/ModsController.cs
new file mode 100644
index 00000000..99d19f76
--- /dev/null
+++ b/src/SMAPI.Web/Controllers/ModsController.cs
@@ -0,0 +1,33 @@
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using StardewModdingAPI.Toolkit;
+using StardewModdingAPI.Toolkit.Framework.Clients.Wiki;
+using StardewModdingAPI.Web.ViewModels;
+
+namespace StardewModdingAPI.Web.Controllers
+{
+ /// <summary>Provides user-friendly info about SMAPI mods.</summary>
+ internal class ModsController : Controller
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Display information for all mods.</summary>
+ [HttpGet]
+ [Route("mods")]
+ public async Task<ViewResult> Index()
+ {
+ WikiModEntry[] mods = await new ModToolkit().GetWikiCompatibilityListAsync();
+ ModListModel viewModel = new ModListModel(
+ stableVersion: "1.3.28",
+ betaVersion: "1.3.31-beta",
+ mods: mods
+ .Select(mod => new ModModel(mod))
+ .OrderBy(p => Regex.Replace(p.Name.ToLower(), "[^a-z0-9]", "")) // ignore case, spaces, and special characters when sorting
+ );
+ return this.View("Index", viewModel);
+ }
+ }
+}