From df84df5ff195ccb7b9a47fbf644e175a26b40aa4 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 May 2020 14:06:10 -0400 Subject: add GitHub licenses to mod compatibility list, update release notes --- src/SMAPI.Web/ViewModels/ModListModel.cs | 2 +- src/SMAPI.Web/ViewModels/ModModel.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Web/ViewModels') diff --git a/src/SMAPI.Web/ViewModels/ModListModel.cs b/src/SMAPI.Web/ViewModels/ModListModel.cs index ff7513bc..6b8279c1 100644 --- a/src/SMAPI.Web/ViewModels/ModListModel.cs +++ b/src/SMAPI.Web/ViewModels/ModListModel.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Web.ViewModels public bool IsStale { get; set; } /// Whether the mod metadata is available. - public bool HasData => this.Mods != null; + public bool HasData => this.Mods?.Any() == true; /********* diff --git a/src/SMAPI.Web/ViewModels/ModModel.cs b/src/SMAPI.Web/ViewModels/ModModel.cs index 56316ab7..45b12397 100644 --- a/src/SMAPI.Web/ViewModels/ModModel.cs +++ b/src/SMAPI.Web/ViewModels/ModModel.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.Web.ViewModels /// The mod author's alternative names, if any. public string AlternateAuthors { get; set; } + /// The GitHub repo, if any. + public string GitHubRepo { get; set; } + /// The URL to the mod's source code, if any. public string SourceUrl { get; set; } @@ -62,6 +65,7 @@ namespace StardewModdingAPI.Web.ViewModels this.AlternateNames = string.Join(", ", entry.Name.Skip(1).ToArray()); this.Author = entry.Author.FirstOrDefault(); this.AlternateAuthors = string.Join(", ", entry.Author.Skip(1).ToArray()); + this.GitHubRepo = entry.GitHubRepo; this.SourceUrl = this.GetSourceUrl(entry); this.Compatibility = new ModCompatibilityModel(entry.Compatibility); this.BetaCompatibility = entry.BetaCompatibility != null ? new ModCompatibilityModel(entry.BetaCompatibility) : null; -- cgit From ea96fdf54167608502885a64e844e8b67f1c1d72 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 24 May 2020 14:35:16 -0400 Subject: update ModDrop URLs --- docs/release-notes.md | 3 ++- src/SMAPI.Web/ViewModels/ModModel.cs | 2 +- src/SMAPI.Web/appsettings.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/SMAPI.Web/ViewModels') diff --git a/docs/release-notes.md b/docs/release-notes.md index 10c31143..5813298d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,8 +7,9 @@ * MacOS files starting with `._` are now ignored and can no longer cause skipped mods. * For the web UI: - * Updated web framework to improve site performance and reliability. * Added GitHub licenses to mod compatibility list. + * Updated web framework to improve site performance and reliability. + * Updated ModDrop URLs. * Internal changes to improve performance and reliability. * For modders: diff --git a/src/SMAPI.Web/ViewModels/ModModel.cs b/src/SMAPI.Web/ViewModels/ModModel.cs index 45b12397..575d596a 100644 --- a/src/SMAPI.Web/ViewModels/ModModel.cs +++ b/src/SMAPI.Web/ViewModels/ModModel.cs @@ -106,7 +106,7 @@ namespace StardewModdingAPI.Web.ViewModels if (entry.ModDropID.HasValue) { anyFound = true; - yield return new ModLinkModel($"https://www.moddrop.com/sdv/mod/{entry.ModDropID}", "ModDrop"); + yield return new ModLinkModel($"https://www.moddrop.com/stardew-valley/mod/{entry.ModDropID}", "ModDrop"); } if (!string.IsNullOrWhiteSpace(entry.CurseForgeKey)) { diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index b1d39a6f..22fd7396 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -39,7 +39,7 @@ "GitHubPassword": null, "ModDropApiUrl": "https://www.moddrop.com/api/mods/data", - "ModDropModPageUrl": "https://www.moddrop.com/sdv/mod/{0}", + "ModDropModPageUrl": "https://www.moddrop.com/stardew-valley/mod/{0}", "NexusApiKey": null, "NexusBaseUrl": "https://www.nexusmods.com/stardewvalley/", -- cgit From ed3309e7bb8d5f3f6c3d08df3475bd811d5b16d0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 20 Jun 2020 11:36:22 -0400 Subject: remember selected schema when editing a file --- docs/release-notes.md | 1 + .../Controllers/JsonValidatorController.cs | 25 ++++++++++++++-------- .../ViewModels/JsonValidator/JsonValidatorModel.cs | 7 +++++- src/SMAPI.Web/Views/JsonValidator/Index.cshtml | 9 ++++---- 4 files changed, 27 insertions(+), 15 deletions(-) (limited to 'src/SMAPI.Web/ViewModels') diff --git a/docs/release-notes.md b/docs/release-notes.md index 2780e5ad..2bb4dc84 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -22,6 +22,7 @@ * Added GitHub licenses to mod compatibility list. * Improved JSON validator: * added SMAPI `i18n` schema; + * editing an uploaded file now remembers the selected schema; * changed default schema to plain JSON. * Updated ModDrop URLs. * Internal changes to improve performance and reliability. diff --git a/src/SMAPI.Web/Controllers/JsonValidatorController.cs b/src/SMAPI.Web/Controllers/JsonValidatorController.cs index b76d41a3..5f83eafd 100644 --- a/src/SMAPI.Web/Controllers/JsonValidatorController.cs +++ b/src/SMAPI.Web/Controllers/JsonValidatorController.cs @@ -58,16 +58,22 @@ namespace StardewModdingAPI.Web.Controllers /// Render the schema validator UI. /// The schema name with which to validate the JSON, or 'edit' to return to the edit screen. /// The stored file ID. + /// The operation to perform for the selected log ID. This can be 'edit', or any other value to view. [HttpGet] [Route("json")] [Route("json/{schemaName}")] [Route("json/{schemaName}/{id}")] - public async Task Index(string schemaName = null, string id = null) + [Route("json/{schemaName}/{id}/{operation}")] + public async Task Index(string schemaName = null, string id = null, string operation = null) { + // parse arguments schemaName = this.NormalizeSchemaName(schemaName); + bool hasId = !string.IsNullOrWhiteSpace(id); + bool isEditView = !hasId || operation?.Trim().ToLower() == "edit"; - var result = new JsonValidatorModel(id, schemaName, this.SchemaFormats); - if (string.IsNullOrWhiteSpace(id)) + // build result model + var result = this.GetModel(id, schemaName, isEditView); + if (!hasId) return this.View("Index", result); // fetch raw JSON @@ -77,7 +83,7 @@ namespace StardewModdingAPI.Web.Controllers result.SetContent(file.Content, expiry: file.Expiry, uploadWarning: file.Warning); // skip parsing if we're going to the edit screen - if (schemaName?.ToLower() == "edit") + if (isEditView) return this.View("Index", result); // parse JSON @@ -131,7 +137,7 @@ namespace StardewModdingAPI.Web.Controllers public async Task PostAsync(JsonValidatorRequestModel request) { if (request == null) - return this.View("Index", this.GetModel(null, null).SetUploadError("The request seems to be invalid.")); + return this.View("Index", this.GetModel(null, null, isEditView: true).SetUploadError("The request seems to be invalid.")); // normalize schema name string schemaName = this.NormalizeSchemaName(request.SchemaName); @@ -139,12 +145,12 @@ namespace StardewModdingAPI.Web.Controllers // get raw text string input = request.Content; if (string.IsNullOrWhiteSpace(input)) - return this.View("Index", this.GetModel(null, schemaName).SetUploadError("The JSON file seems to be empty.")); + return this.View("Index", this.GetModel(null, schemaName, isEditView: true).SetUploadError("The JSON file seems to be empty.")); // upload file UploadResult result = await this.Storage.SaveAsync(input); if (!result.Succeeded) - return this.View("Index", this.GetModel(result.ID, schemaName).SetUploadError(result.UploadError)); + return this.View("Index", this.GetModel(result.ID, schemaName, isEditView: true).SetContent(input, null).SetUploadError(result.UploadError)); // redirect to view return this.Redirect(this.Url.PlainAction("Index", "JsonValidator", new { schemaName = schemaName, id = result.ID })); @@ -157,9 +163,10 @@ namespace StardewModdingAPI.Web.Controllers /// Build a JSON validator model. /// The stored file ID. /// The schema name with which the JSON was validated. - private JsonValidatorModel GetModel(string pasteID, string schemaName) + /// Whether to show the edit view. + private JsonValidatorModel GetModel(string pasteID, string schemaName, bool isEditView) { - return new JsonValidatorModel(pasteID, schemaName, this.SchemaFormats); + return new JsonValidatorModel(pasteID, schemaName, this.SchemaFormats, isEditView); } /// Get a normalized schema name, or the if blank. diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs index c0dd7184..0ea69911 100644 --- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs +++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs @@ -10,6 +10,9 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator /********* ** Accessors *********/ + /// Whether to show the edit view. + public bool IsEditView { get; set; } + /// The paste ID. public string PasteID { get; set; } @@ -51,11 +54,13 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator /// The stored file ID. /// The schema name with which the JSON was validated. /// The supported JSON schemas (names indexed by ID). - public JsonValidatorModel(string pasteID, string schemaName, IDictionary schemaFormats) + /// Whether to show the edit view. + public JsonValidatorModel(string pasteID, string schemaName, IDictionary schemaFormats, bool isEditView) { this.PasteID = pasteID; this.SchemaName = schemaName; this.SchemaFormats = schemaFormats; + this.IsEditView = isEditView; } /// Set the validated content. diff --git a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml index f23bd150..7b89a23d 100644 --- a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml +++ b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml @@ -9,7 +9,6 @@ string newUploadUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName }); string schemaDisplayName = null; bool isValidSchema = Model.SchemaName != null && Model.SchemaFormats.TryGetValue(Model.SchemaName, out schemaDisplayName) && schemaDisplayName?.ToLower() != "none"; - bool isEditView = Model.Content == null || Model.SchemaName?.ToLower() == "edit"; // build title ViewData["Title"] = "JSON validator"; @@ -63,7 +62,7 @@ else if (Model.ParseError != null) Error details: @Model.ParseError } -else if (!isEditView && Model.PasteID != null) +else if (!Model.IsEditView && Model.PasteID != null) {