summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Views/JsonValidator/Index.cshtml
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-05 20:18:16 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-05 20:18:16 -0500
commitf976b5c0f095a881fc20f6ce5dcf5a50ebb2b5da (patch)
tree260fa7579e1c361283bda09c2616783c3fdb5b9a /src/SMAPI.Web/Views/JsonValidator/Index.cshtml
parentd34f369d35290bca96cc7225d9765d1a8a66fa8b (diff)
parent48959375b9ef52abf7c7a9404d43aac6ba780047 (diff)
downloadSMAPI-f976b5c0f095a881fc20f6ce5dcf5a50ebb2b5da.tar.gz
SMAPI-f976b5c0f095a881fc20f6ce5dcf5a50ebb2b5da.tar.bz2
SMAPI-f976b5c0f095a881fc20f6ce5dcf5a50ebb2b5da.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/Views/JsonValidator/Index.cshtml')
-rw-r--r--src/SMAPI.Web/Views/JsonValidator/Index.cshtml71
1 files changed, 43 insertions, 28 deletions
diff --git a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml
index de6b06a2..a00c8387 100644
--- a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml
+++ b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml
@@ -1,13 +1,15 @@
+@using Humanizer
@using StardewModdingAPI.Web.Framework
@using StardewModdingAPI.Web.ViewModels.JsonValidator
@model JsonValidatorModel
@{
// get view data
- string curPageUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName, id = Model.PasteID });
+ string curPageUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName, id = Model.PasteID }, absoluteUrl: true);
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";
@@ -26,17 +28,17 @@
{
<meta name="robots" content="noindex" />
}
- <link rel="stylesheet" href="~/Content/css/json-validator.css" />
+ <link rel="stylesheet" href="~/Content/css/json-validator.css?r=20191204" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tmont/sunlight@1.22.0/src/themes/sunlight.default.min.css" />
<script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/tmont/sunlight@1.22.0/src/sunlight.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/tmont/sunlight@1.22.0/src/plugins/sunlight-plugin.linenumbers.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/tmont/sunlight@1.22.0/src/lang/sunlight.javascript.min.js" crossorigin="anonymous"></script>
- <script src="~/Content/js/json-validator.js"></script>
+ <script src="~/Content/js/json-validator.js?r=20191204"></script>
<script>
$(function() {
- smapi.jsonValidator(@Json.Serialize(this.Url.PlainAction("Index", "JsonValidator", values: null)), @Json.Serialize(Model.PasteID));
+ smapi.jsonValidator(@Json.Serialize(this.Url.PlainAction("Index", "JsonValidator", new { schemaName = "$schemaName", id = "$id" })), @Json.Serialize(Model.PasteID));
});
</script>
}
@@ -59,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 />
@@ -67,8 +69,20 @@ else if (Model.PasteID != null)
</div>
}
+@* save warnings *@
+@if (Model.UploadWarning != null || Model.Expiry != null)
+{
+ <div class="save-metadata" v-pre>
+ @if (Model.Expiry != null)
+ {
+ <text>This JSON file will expire in @((DateTime.UtcNow - Model.Expiry.Value).Humanize()). </text>
+ }
+ <!--@Model.UploadWarning-->
+ </div>
+}
+
@* upload new file *@
-@if (Model.Content == null)
+@if (isEditView)
{
<h2>Upload a JSON file</h2>
<form action="@this.Url.PlainAction("PostAsync", "JsonValidator")" method="post">
@@ -84,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 />
@@ -95,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())
{
@@ -135,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)