summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Web/Controllers/LogParserController.cs6
-rw-r--r--src/SMAPI.Web/ViewModels/LogParserModel.cs7
-rw-r--r--src/SMAPI.Web/Views/LogParser/Index.cshtml28
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/log-parser.js21
4 files changed, 33 insertions, 29 deletions
diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs
index ee1d51cd..f9943707 100644
--- a/src/SMAPI.Web/Controllers/LogParserController.cs
+++ b/src/SMAPI.Web/Controllers/LogParserController.cs
@@ -42,11 +42,13 @@ namespace StardewModdingAPI.Web.Controllers
** Web UI
***/
/// <summary>Render the log parser UI.</summary>
+ /// <param name="id">The paste ID.</param>
[HttpGet]
[Route("log")]
- public ViewResult Index()
+ [Route("log/{id}")]
+ public ViewResult Index(string id = null)
{
- return this.View("Index", new LogParserModel(this.Config.SectionUrl));
+ return this.View("Index", new LogParserModel(this.Config.SectionUrl, id));
}
/***
diff --git a/src/SMAPI.Web/ViewModels/LogParserModel.cs b/src/SMAPI.Web/ViewModels/LogParserModel.cs
index ba31db87..b5b3b14c 100644
--- a/src/SMAPI.Web/ViewModels/LogParserModel.cs
+++ b/src/SMAPI.Web/ViewModels/LogParserModel.cs
@@ -9,6 +9,9 @@ namespace StardewModdingAPI.Web.ViewModels
/// <summary>The root URL for the log parser controller.</summary>
public string SectionUrl { get; set; }
+ /// <summary>The paste ID.</summary>
+ public string PasteID { get; set; }
+
/*********
** Public methods
@@ -18,9 +21,11 @@ namespace StardewModdingAPI.Web.ViewModels
/// <summary>Construct an instance.</summary>
/// <param name="sectionUrl">The root URL for the log parser controller.</param>
- public LogParserModel(string sectionUrl)
+ /// <param name="pasteID">The paste ID.</param>
+ public LogParserModel(string sectionUrl, string pasteID)
{
this.SectionUrl = sectionUrl;
+ this.PasteID = pasteID;
}
}
}
diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml
index bd47f2ff..a84866c8 100644
--- a/src/SMAPI.Web/Views/LogParser/Index.cshtml
+++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml
@@ -10,7 +10,7 @@
<style type="text/css" id="modflags"></style>
<script>
$(function() {
- smapi.logParser('@Model.SectionUrl');
+ smapi.logParser('@Model.SectionUrl', '@Model.PasteID');
});
</script>
}
@@ -21,17 +21,19 @@
<p id="blurb">This page lets you upload, view, and share a SMAPI log to help troubleshoot mod issues.</p>
<input type="button" id="upload-button" value="Share a new log" />
-<h2>Parsed log</h2>
-
-<ul id="tabs">
- <li>TRACE</li>
- <li>DEBUG</li>
- <li class="active">INFO</li>
- <li class="active">ALERT</li>
- <li class="active">WARN</li>
- <li class="active">ERROR</li>
- <li class="notice">Click tabs to toggle message visibility</li>
-</ul>
+@if (Model.PasteID != null)
+{
+ <h2>Parsed log</h2>
+ <ul id="tabs">
+ <li>TRACE</li>
+ <li>DEBUG</li>
+ <li class="active">INFO</li>
+ <li class="active">ALERT</li>
+ <li class="active">WARN</li>
+ <li class="active">ERROR</li>
+ <li class="notice">Click tabs to toggle message visibility</li>
+ </ul>
+}
<div id="output" class="trace debug"></div>
<script class="template" id="template-body" type="text/html">
<div class="always">
@@ -97,7 +99,7 @@
<li><a href="https://stardewvalleywiki.com/Modding:Player_FAQs#SMAPI_log" target="_blank">Find your SMAPI log</a>.</li>
<li>Drag the file onto the textbox below (or paste the text in).</li>
<li>Click <em>Parse</em>.</li>
- <li>Share the link you get back.</li>
+ <li>Share the URL of the new page.</li>
</ol>
<textarea id="input" placeholder="Paste or drag the log here"></textarea>
<div class="buttons">
diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
index 3949fabe..904ca691 100644
--- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
+++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
@@ -1,7 +1,7 @@
/* globals $, LZString */
var smapi = smapi || {};
-smapi.logParser = function(sectionUrl) {
+smapi.logParser = function(sectionUrl, pasteID) {
/*********
** Initialisation
*********/
@@ -86,11 +86,10 @@ smapi.logParser = function(sectionUrl) {
})
.then(function(data) {
$("#uploader").fadeOut();
- console.log("Result: ", data);
if (!data.success)
$("#output").html('<div id="log" class="color-red"><h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br />&nbsp;<p>Stage: Upload</p>Error: ' + data.error + "<hr />" + $("#input").val() + "</div>");
else
- location.href = "?" + data.id;
+ location.href = (sectionUrl.replace(/\/$/, "") + "/" + data.id);
});
} else {
alert("Unable to parse log, the input is empty!");
@@ -106,8 +105,8 @@ smapi.logParser = function(sectionUrl) {
$("#closeraw").on("click", function() {
$("#popup-raw").fadeOut(400);
});
- if (location.search) {
- getData();
+ if (pasteID) {
+ getData(pasteID);
}
else
$("#popup-upload").fadeIn();
@@ -160,10 +159,6 @@ smapi.logParser = function(sectionUrl) {
dataDate = regexDate.exec(data) || regexDate.exec(data) || regexDate.exec(data),
dataPath = regexPath.exec(data) || regexPath.exec(data) || regexPath.exec(data),
match;
- console.log("dataInfo:", dataInfo);
- console.log("dataMods:", dataMods);
- console.log("dataDate:", dataDate);
- console.log("dataPath:", dataPath);
stage = "parseData.doNullCheck";
if (!dataInfo)
throw new Error("Field `dataInfo` is null");
@@ -267,19 +262,19 @@ smapi.logParser = function(sectionUrl) {
stage = "loadData.Post";
}
catch (err) {
- $("#output").html('<div id="log" class="color-red"><h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br />&nbsp;<p>Stage: ' + stage + "</p>" + err + '<hr /><div id="rawlog"></div></div>');
+ $("#output").html('<div id="log" class="color-red"><h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br />&nbsp;<p>Stage: ' + stage + "</p>" + err + '<hr /><pre id="rawlog"></pre></div>');
$("#rawlog").text($("#input").val());
}
}
- function getData() {
+ function getData(pasteID) {
$("#uploader").attr("data-text", "Loading...");
$("#uploader").fadeIn();
- $.get(sectionUrl + "/fetch/" + location.search.substring(1), function(data) {
+ $.get(sectionUrl + "/fetch/" + pasteID, function(data) {
if (data.success) {
$("#input").val(LZString.decompressFromUTF16(data.content) || data.content);
loadData();
} else {
- $("#output").html('<div id="log" class="color-red"><h1>Fetching the log failed!</h1><p>' + data.error + '</p><div id="rawlog"></div></div>');
+ $("#output").html('<div id="log" class="color-red"><h1>Fetching the log failed!</h1><p>' + data.error + '</p><pre id="rawlog"></pre></div>');
$("#rawlog").text($("#input").val());
}
$("#uploader").fadeOut();