summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/wwwroot
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/wwwroot')
-rw-r--r--src/SMAPI.Web/wwwroot/Content/css/json-validator.css98
-rw-r--r--src/SMAPI.Web/wwwroot/Content/css/main.css2
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/json-validator.js60
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/log-parser.js17
-rw-r--r--src/SMAPI.Web/wwwroot/schemas/manifest.json120
5 files changed, 287 insertions, 10 deletions
diff --git a/src/SMAPI.Web/wwwroot/Content/css/json-validator.css b/src/SMAPI.Web/wwwroot/Content/css/json-validator.css
new file mode 100644
index 00000000..f9aeb18b
--- /dev/null
+++ b/src/SMAPI.Web/wwwroot/Content/css/json-validator.css
@@ -0,0 +1,98 @@
+/*********
+** Main layout
+*********/
+#content {
+ max-width: 100%;
+}
+
+#output {
+ padding: 10px;
+ overflow: auto;
+}
+
+#output table td {
+ font-family: monospace;
+}
+
+#output table tr th,
+#output table tr td {
+ padding: 0 0.75rem;
+ white-space: pre-wrap;
+}
+
+
+/*********
+** Result banner
+*********/
+.banner {
+ border: 2px solid gray;
+ border-radius: 5px;
+ margin-top: 1em;
+ padding: 1em;
+}
+
+.banner.success {
+ border-color: green;
+ background: #CFC;
+}
+
+.banner.error {
+ border-color: red;
+ background: #FCC;
+}
+
+/*********
+** Validation results
+*********/
+.table {
+ border-bottom: 1px dashed #888888;
+ margin-bottom: 5px;
+}
+
+#metadata th, #metadata td {
+ text-align: left;
+ padding-right: 0.7em;
+}
+
+.table {
+ border: 1px solid #000000;
+ background: #ffffff;
+ border-radius: 5px;
+ border-spacing: 1px;
+ overflow: hidden;
+ cursor: default;
+ box-shadow: 1px 1px 1px 1px #dddddd;
+}
+
+.table tr {
+ background: #eee;
+}
+
+.table tr:nth-child(even) {
+ background: #fff;
+}
+
+/*********
+** Upload form
+*********/
+#input {
+ width: 100%;
+ height: 20em;
+ max-height: 70%;
+ margin: auto;
+ box-sizing: border-box;
+ border-radius: 5px;
+ border: 1px solid #000088;
+ outline: none;
+ box-shadow: inset 0px 0px 1px 1px rgba(0, 0, 192, .2);
+}
+
+#submit {
+ font-size: 1.5em;
+ border-radius: 5px;
+ outline: none;
+ box-shadow: inset 0 0 1px 1px rgba(0, 0, 0, .2);
+ cursor: pointer;
+ border: 1px solid #008800;
+ background-color: #cfc;
+}
diff --git a/src/SMAPI.Web/wwwroot/Content/css/main.css b/src/SMAPI.Web/wwwroot/Content/css/main.css
index 57eeee88..dcc7a798 100644
--- a/src/SMAPI.Web/wwwroot/Content/css/main.css
+++ b/src/SMAPI.Web/wwwroot/Content/css/main.css
@@ -73,7 +73,7 @@ a {
}
#sidebar h4 {
- margin: 0 0 0.2em 0;
+ margin: 1.5em 0 0.2em 0;
width: 10em;
border-bottom: 1px solid #CCC;
font-size: 0.8em;
diff --git a/src/SMAPI.Web/wwwroot/Content/js/json-validator.js b/src/SMAPI.Web/wwwroot/Content/js/json-validator.js
new file mode 100644
index 00000000..3f7a1775
--- /dev/null
+++ b/src/SMAPI.Web/wwwroot/Content/js/json-validator.js
@@ -0,0 +1,60 @@
+/* globals $ */
+
+var smapi = smapi || {};
+smapi.jsonValidator = function (sectionUrl, pasteID) {
+ /**
+ * Rebuild the syntax-highlighted element.
+ */
+ var formatCode = function () {
+ Sunlight.highlightAll();
+ };
+
+ /**
+ * Initialise the JSON validator page.
+ */
+ var init = function () {
+ // code formatting
+ formatCode();
+
+ // change format
+ $("#output #format").on("change", function() {
+ var schemaName = $(this).val();
+ location.href = new URL(schemaName + "/" + pasteID, sectionUrl).toString();
+ });
+
+ // upload form
+ var input = $("#input");
+ if (input.length) {
+ // disable submit if it's empty
+ var toggleSubmit = function () {
+ var hasText = !!input.val().trim();
+ submit.prop("disabled", !hasText);
+ };
+ input.on("input", toggleSubmit);
+ toggleSubmit();
+
+ // drag & drop file
+ input.on({
+ 'dragover dragenter': function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ },
+ 'drop': function (e) {
+ var dataTransfer = e.originalEvent.dataTransfer;
+ if (dataTransfer && dataTransfer.files.length) {
+ e.preventDefault();
+ e.stopPropagation();
+ var file = dataTransfer.files[0];
+ var reader = new FileReader();
+ reader.onload = $.proxy(function (file, $input, event) {
+ $input.val(event.target.result);
+ toggleSubmit();
+ }, this, file, $("#input"));
+ reader.readAsText(file);
+ }
+ }
+ });
+ }
+ };
+ init();
+};
diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
index e87a1a5c..e6c7591c 100644
--- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
+++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
@@ -23,7 +23,7 @@ smapi.logParser = function (data, sectionUrl) {
}
// set local time started
- if(data)
+ if (data)
data.localTimeStarted = ("0" + data.logStarted.getHours()).slice(-2) + ":" + ("0" + data.logStarted.getMinutes()).slice(-2);
// init app
@@ -100,7 +100,7 @@ smapi.logParser = function (data, sectionUrl) {
updateModFilters();
},
- filtersAllow: function(modId, level) {
+ filtersAllow: function (modId, level) {
return this.showMods[modId] !== false && this.showLevels[level] !== false;
},
@@ -121,16 +121,15 @@ smapi.logParser = function (data, sectionUrl) {
var submit = $("#submit");
// instruction OS chooser
- var chooseSystem = function() {
+ var chooseSystem = function () {
systemInstructions.hide();
systemInstructions.filter("[data-os='" + $("input[name='os']:checked").val() + "']").show();
- }
+ };
systemOptions.on("click", chooseSystem);
chooseSystem();
// disable submit if it's empty
- var toggleSubmit = function()
- {
+ var toggleSubmit = function () {
var hasText = !!input.val().trim();
submit.prop("disabled", !hasText);
}
@@ -139,18 +138,18 @@ smapi.logParser = function (data, sectionUrl) {
// drag & drop file
input.on({
- 'dragover dragenter': function(e) {
+ 'dragover dragenter': function (e) {
e.preventDefault();
e.stopPropagation();
},
- 'drop': function(e) {
+ 'drop': function (e) {
var dataTransfer = e.originalEvent.dataTransfer;
if (dataTransfer && dataTransfer.files.length) {
e.preventDefault();
e.stopPropagation();
var file = dataTransfer.files[0];
var reader = new FileReader();
- reader.onload = $.proxy(function(file, $input, event) {
+ reader.onload = $.proxy(function (file, $input, event) {
$input.val(event.target.result);
toggleSubmit();
}, this, file, $("#input"));
diff --git a/src/SMAPI.Web/wwwroot/schemas/manifest.json b/src/SMAPI.Web/wwwroot/schemas/manifest.json
new file mode 100644
index 00000000..06173333
--- /dev/null
+++ b/src/SMAPI.Web/wwwroot/schemas/manifest.json
@@ -0,0 +1,120 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "https://smapi.io/schemas/manifest.json",
+ "title": "SMAPI manifest",
+ "description": "Manifest file for a SMAPI mod or content pack",
+ "type": "object",
+ "properties": {
+ "Name": {
+ "title": "Mod name",
+ "description": "The mod's display name. SMAPI uses this in player messages, logs, and errors.",
+ "type": "string",
+ "examples": [ "Lookup Anything" ]
+ },
+ "Author": {
+ "title": "Mod author",
+ "description": "The name of the person who created the mod. Ideally this should include the username used to publish mods.",
+ "type": "string",
+ "examples": [ "Pathoschild" ]
+ },
+ "Version": {
+ "title": "Mod version",
+ "description": "The mod's semantic version. Make sure you update this for each release! SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game).",
+ "$ref": "#/definitions/SemanticVersion"
+ },
+ "Description": {
+ "title": "Mod description",
+ "description": "A short explanation of what your mod does (one or two sentences), shown in the SMAPI log.",
+ "type": "string",
+ "examples": [ "View metadata about anything by pressing a button." ]
+ },
+ "UniqueID": {
+ "title": "Mod unique ID",
+ "description": "A unique identifier for your mod. The recommended format is \"Username.ModName\", with no spaces or special characters. SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). When another mod needs to reference this mod, it uses the unique ID.",
+ "$ref": "#/definitions/ModID"
+ },
+ "EntryDll": {
+ "title": "Mod entry DLL",
+ "description": "The DLL filename SMAPI should load for this mod. Mutually exclusive with ContentPackFor.",
+ "type": "string",
+ "pattern": "^[a-zA-Z0-9_.-]+\\.dll$",
+ "examples": "LookupAnything.dll"
+ },
+ "ContentPackFor": {
+ "title": "Content pack for",
+ "description": "Specifies the mod which can read this content pack.",
+ "type": "object",
+ "properties": {
+ "UniqueID": {
+ "title": "Required unique ID",
+ "description": "The unique ID of the mod which can read this content pack.",
+ "$ref": "#/definitions/ModID"
+ },
+ "MinimumVersion": {
+ "title": "Required minimum version",
+ "description": "The minimum semantic version of the mod which can read this content pack, if applicable.",
+ "$ref": "#/definitions/SemanticVersion"
+ }
+ },
+
+ "required": [ "UniqueID" ]
+ },
+ "Dependencies": {
+ "title": "Mod dependencies",
+ "description": "Specifies other mods to load before this mod. If a dependency is required and a player tries to use the mod without the dependency installed, the mod won't be loaded and they'll see a friendly message saying they need to install those.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "UniqueID": {
+ "title": "Dependency unique ID",
+ "description": "The unique ID of the mod to load first.",
+ "$ref": "#/definitions/ModID"
+ },
+ "MinimumVersion": {
+ "title": "Dependency minimum version",
+ "description": "The minimum semantic version of the mod to load first, if applicable.",
+ "$ref": "#/definitions/SemanticVersion"
+ },
+ "IsRequired": {
+ "title": "Dependency is required",
+ "description": "Whether the dependency is required. Default true if not specified."
+ }
+ },
+ "required": [ "UniqueID" ]
+ }
+ },
+ "UpdateKeys": {
+ "title": "Mod update keys",
+ "description": "Specifies where SMAPI should check for mod updates, so it can alert the user with a link to your mod page. See https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Manifest#Update_checks for more info.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^(Chucklefish:\\d+|Nexus:\\d+|GitHub:[A-Za-z0-9_]+/[A-Za-z0-9_]+|ModDrop:\\d+)$"
+ }
+ }
+ },
+
+ "required": [ "Name", "Author", "Version", "Description", "UniqueID" ],
+ "oneOf": [
+ {
+ "required": [ "EntryDll" ]
+ },
+ {
+ "required": [ "ContentPackFor" ]
+ }
+ ],
+
+ "definitions": {
+ "SemanticVersion": {
+ "type": "string",
+ "pattern": "(?>(?<major>0|[1-9]\\d*))\\.(?>(?<minor>0|[1-9]\\d*))(?>(?:\\.(?<patch>0|[1-9]\\d*))?)(?:-(?<prerelease>(?>[a-zA-Z0-9]+[\\-\\.]?)+))?", // derived from SMAPI.Toolkit.SemanticVersion
+ "examples": [ "1.0.0", "1.0.1-beta.2" ]
+ },
+ "ModID": {
+ "type": "string",
+ "pattern": "^[a-zA-Z0-9_.-]+$", // derived from SMAPI.Toolkit.Utilities.PathUtilities.IsSlug
+ "examples": [ "Pathoschild.LookupAnything" ]
+ }
+ }
+}