diff options
-rw-r--r-- | docs/release-notes.md | 11 | ||||
-rw-r--r-- | src/SMAPI.Web/Controllers/JsonValidatorController.cs | 6 | ||||
-rw-r--r-- | src/SMAPI.Web/Views/JsonValidator/Index.cshtml | 50 |
3 files changed, 37 insertions, 30 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index bd377d0b..75438aaa 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -11,6 +11,12 @@ * Internal optimizations. * Updated translations. Thanks to PlussRolf (added Spanish)! +* For the web UI: + * Added option to edit & reupload in the JSON validator. + * If a JSON validator upload can't be saved to Pastebin (e.g. due to rate limits), it's now uploaded to Amazon S3 instead. Files uploaded to S3 expire after one month. + * Updated the JSON validator for Content Patcher 1.10.0. + * Fixed JSON validator no longer letting you change format when viewing results. + * For modders: * Added asset propagation for grass textures. * Added asset propagation for `Data\Bundles` changes (for added bundles only). @@ -18,11 +24,6 @@ * `helper.Read/WriteSaveData` can now be used while a save is being loaded (e.g. within a `Specialized.LoadStageChanged` event). * Fixed private textures loaded from content packs not having their `Name` field set. -* For the web UI: - * If a JSON validator upload can't be saved to Pastebin (e.g. due to rate limits), it's now uploaded to Amazon S3 instead. Files uploaded to S3 expire after one month. - * Updated the JSON validator for Content Patcher 1.10.0. - * Fixed JSON validator no longer letting you change format when viewing results. - ## 3.0.1 Released 02 December 2019 for Stardew Valley 1.4.0.1. diff --git a/src/SMAPI.Web/Controllers/JsonValidatorController.cs b/src/SMAPI.Web/Controllers/JsonValidatorController.cs index 830fe839..e4eff0f4 100644 --- a/src/SMAPI.Web/Controllers/JsonValidatorController.cs +++ b/src/SMAPI.Web/Controllers/JsonValidatorController.cs @@ -55,7 +55,7 @@ namespace StardewModdingAPI.Web.Controllers ** Web UI ***/ /// <summary>Render the schema validator UI.</summary> - /// <param name="schemaName">The schema name with which to validate the JSON.</param> + /// <param name="schemaName">The schema name with which to validate the JSON, or 'edit' to return to the edit screen.</param> /// <param name="id">The stored file ID.</param> [HttpGet] [Route("json")] @@ -75,6 +75,10 @@ namespace StardewModdingAPI.Web.Controllers return this.View("Index", result.SetUploadError("The JSON file seems to be empty.")); result.SetContent(file.Content, expiry: file.Expiry, uploadWarning: file.Warning); + // skip parsing if we're going to the edit screen + if (schemaName?.ToLower() == "edit") + return this.View("Index", result); + // parse JSON JToken parsed; try diff --git a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml index a042f024..fb43823a 100644 --- a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml +++ b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml @@ -8,7 +8,8 @@ string curPageUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName, id = Model.PasteID }); 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 != "None"; + 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"; @@ -60,7 +61,7 @@ else if (Model.ParseError != null) <small v-pre>Error details: @Model.ParseError</small> </div> } -else if (Model.PasteID != null) +else if (!isEditView && Model.PasteID != null) { <div class="banner success"> <strong>Share this link to let someone else see this page:</strong> <code>@curPageUrl</code><br /> @@ -81,7 +82,7 @@ else if (Model.PasteID != null) } @* upload new file *@ -@if (Model.Content == null) +@if (isEditView) { <h2>Upload a JSON file</h2> <form action="@this.Url.PlainAction("PostAsync", "JsonValidator")" method="post"> @@ -97,7 +98,7 @@ else if (Model.PasteID != null) </li> <li> Drag the file onto this textbox (or paste the text in):<br /> - <textarea id="input" name="Content" placeholder="paste file here"></textarea> + <textarea id="input" name="Content" placeholder="paste file here">@Model.Content</textarea> </li> <li> Click this button:<br /> @@ -108,26 +109,23 @@ else if (Model.PasteID != null) } @* validation results *@ -@if (Model.Content != null) +@if (!isEditView) { <div id="output"> @if (Model.UploadError == null) { - <div> - Change JSON format: - <select id="format" name="format"> - @foreach (var pair in Model.SchemaFormats) - { - <option value="@pair.Key" selected="@(Model.SchemaName == pair.Key)">@pair.Value</option> - } - </select> - </div> - - <h2>Validation errors</h2> - @if (Model.FormatUrl != null) - { - <p>See <a href="@Model.FormatUrl">format documentation</a>.</p> - } + <h2>Validation</h2> + <p> + @(Model.Errors.Any() ? "Oops, found some issues with your JSON." : "No errors found!") + @if (!isValidSchema) + { + <text>(You have no schema selected, so only the basic JSON syntax was checked.)</text> + } + else if (Model.FormatUrl != null) + { + <text>See <a href="@Model.FormatUrl">format documentation</a> for more info.</text> + } + </p> @if (Model.Errors.Any()) { @@ -148,13 +146,17 @@ else if (Model.PasteID != null) } </table> } - else - { - <p>No errors found.</p> - } } <h2>Content</h2> + <div> + You can change JSON format (<select id="format" name="format"> + @foreach (var pair in Model.SchemaFormats) + { + <option value="@pair.Key" selected="@(Model.SchemaName == pair.Key)">@pair.Value</option> + } + </select>) or <a href="@(this.Url.PlainAction("Index", "JsonValidator", new { id = this.Model.PasteID, schemaName = "edit" }))">edit this file</a>. + </div> <pre id="raw-content" class="sunlight-highlight-javascript">@Model.Content</pre> @if (isValidSchema) |