From 65f0fa625575592639a24a9b39330e4a6b500f22 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 27 Oct 2017 19:36:31 -0400 Subject: add scaffolding for web UI (#358) --- src/SMAPI.Web/wwwroot/Content/main.css | 107 +++++++++++++++++++++++++++ src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif | Bin 0 -> 1104 bytes src/SMAPI.Web/wwwroot/favicon.ico | Bin 0 -> 15086 bytes 3 files changed, 107 insertions(+) create mode 100644 src/SMAPI.Web/wwwroot/Content/main.css create mode 100644 src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif create mode 100644 src/SMAPI.Web/wwwroot/favicon.ico (limited to 'src/SMAPI.Web/wwwroot') diff --git a/src/SMAPI.Web/wwwroot/Content/main.css b/src/SMAPI.Web/wwwroot/Content/main.css new file mode 100644 index 00000000..c8ce8d33 --- /dev/null +++ b/src/SMAPI.Web/wwwroot/Content/main.css @@ -0,0 +1,107 @@ +/* tags */ +html { + height: 100%; +} + +body { + height: 100%; + font-family: sans-serif; +} + +h1, h2, h3 { + font-weight: bold; + margin: 0.2em 0 0.1em 0; + padding-top: .5em; +} + +h1 { + font-size: 1.5em; + color: #888; + margin-bottom: 0; +} + +h2 { + font-size: 1.5em; + border-bottom: 1px solid #AAA; +} + +h3 { + font-size: 1.2em; + border-bottom: 1px solid #AAA; + width: 50%; +} + +a { + color: #006; +} + +/* content */ +#content-column { + position: absolute; + top: 1em; + left: 10em; +} + +#content { + min-height: 140px; + padding: 0 1em 1em 1em; + border-left: 1px solid #CCC; + background: #FFF; + font-size: 0.9em; +} + +#content p { + max-width: 55em; +} + +.section { + border: 1px solid #CCC; + padding: 0.5em; + margin-bottom: 1em; +} + +/* sidebar */ +#sidebar { + margin-top: 3em; + min-height: 75%; + width: 12em; + background: url("sidebar-bg.gif") no-repeat top right; + color: #666; +} + +#sidebar h4 { + margin: 0 0 0.2em 0; + width: 10em; + border-bottom: 1px solid #CCC; + font-size: 0.8em; + font-weight: normal; +} + +#sidebar a { + color: #77B; + border: 0; +} + +#sidebar ul, #sidebar li { + margin: 0; + padding: 0; + list-style: none none; + font-size: 0.9em; + color: #888; +} + +#sidebar li { + margin-left: 1em; +} + +/* footer */ +#footer { + margin: 1em; + padding: 1em; + font-size: 0.6em; + color: gray; +} + +#footer a { + color: #669; +} diff --git a/src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif b/src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif new file mode 100644 index 00000000..48e9af5a Binary files /dev/null and b/src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif differ diff --git a/src/SMAPI.Web/wwwroot/favicon.ico b/src/SMAPI.Web/wwwroot/favicon.ico new file mode 100644 index 00000000..587a6e74 Binary files /dev/null and b/src/SMAPI.Web/wwwroot/favicon.ico differ -- cgit From 9f5af37391ac196fe183122f57496846843335cd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 27 Oct 2017 19:38:13 -0400 Subject: move log parser CSS/JS out of HTML (#358) --- src/SMAPI.Web/Views/LogParser/Index.cshtml | 674 +-------------------- src/SMAPI.Web/Views/Shared/_Layout.cshtml | 3 +- src/SMAPI.Web/wwwroot/Content/css/log-parser.css | 374 ++++++++++++ src/SMAPI.Web/wwwroot/Content/css/main.css | 107 ++++ .../wwwroot/Content/images/sidebar-bg.gif | Bin 0 -> 1104 bytes src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 287 +++++++++ src/SMAPI.Web/wwwroot/Content/main.css | 107 ---- src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif | Bin 1104 -> 0 bytes 8 files changed, 776 insertions(+), 776 deletions(-) create mode 100644 src/SMAPI.Web/wwwroot/Content/css/log-parser.css create mode 100644 src/SMAPI.Web/wwwroot/Content/css/main.css create mode 100644 src/SMAPI.Web/wwwroot/Content/images/sidebar-bg.gif create mode 100644 src/SMAPI.Web/wwwroot/Content/js/log-parser.js delete mode 100644 src/SMAPI.Web/wwwroot/Content/main.css delete mode 100644 src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif (limited to 'src/SMAPI.Web/wwwroot') diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 417fe428..021293b6 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -1,6 +1,12 @@ @{ ViewData["Title"] = "SMAPI log parser"; } +@section Head { + + + + +}

How to share a SMAPI log

    @@ -14,387 +20,10 @@ TODO - SMAPI log parser - @@ -486,296 +115,5 @@
    - - - diff --git a/src/SMAPI.Web/Views/Shared/_Layout.cshtml b/src/SMAPI.Web/Views/Shared/_Layout.cshtml index 89b1866c..547a8178 100644 --- a/src/SMAPI.Web/Views/Shared/_Layout.cshtml +++ b/src/SMAPI.Web/Views/Shared/_Layout.cshtml @@ -3,7 +3,8 @@ @ViewData["Title"] - SMAPI.io - + + @RenderSection("Head", required: false) '); + } + else { + $("#input").val(LZString.decompressFromUTF16(data) || data); + loadData(); + } + $("#uploader").fadeOut(); + }); + } + var Stage, + flags = $("#modflags"), + output = $("#output"), + filters = 0, + memory = "", + versionInfo, + modInfo, + modMap, + modErrors, + logInfo, + templateBody = $("#template-body").text(), + templateModentry = $("#template-modentry").text(), + templateCss = $("#template-css").text(), + templateLogentry = $("#template-logentry").text(), + templateLognotice = $("#template-lognotice").text(), + regexInfo = /\[[\d\:]+ INFO SMAPI] SMAPI (.*?) with Stardew Valley (.*?) on (.*?)\n/g, + regexMods = /\[[^\]]+\] Loaded \d+ mods:(?:\n\[[^\]]+\] .+)+/g, + regexLog = /\[([\d\:]+) (TRACE|DEBUG|INFO|WARN|ALERT|ERROR) ? ([^\]]+)\] ?((?:\n|.)*?)(?=(?:\[\d\d:|$))/g, + regexMod = /\[(?:.*?)\] *(.*?) (\d+\.?(?:.*?))(?: by (.*?))? \|(?:.*?)$/gm, + regexDate = /\[\d{2}:\d{2}:\d{2} TRACE SMAPI\] Log started at (.*?) UTC/g, + regexPath = /\[\d{2}:\d{2}:\d{2} DEBUG SMAPI\] Mods go here: (.*?)(?:\n|$)/g + ; + $("#tabs li:not(.notice)").on("click", function(evt) { + var t = $(evt.currentTarget) + t.toggleClass("active"); + $("#output").toggleClass(t.text().toLowerCase()); + }) + $("#upload").on("click", function() { + memory = $("#input").val() || ""; + $("#input").val(""); + $("#popup-upload").fadeIn(); + }) + var proxies = [ + "https://cors-anywhere.herokuapp.com/", + "https://galvanize-cors-proxy.herokuapp.com/" + ]; + $('#popup-upload').on({ + 'dragover dragenter': function(e) { + e.preventDefault(); + e.stopPropagation(); + }, + 'drop': function(e) { + $("#uploader").attr("data-text", "Reading...") + $("#uploader").show(); + 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); + $("#uploader").fadeOut(); + $("#submit").click(); + }, this, file, $("#input")); + reader.readAsText(file); + } + } + }); + function logSize(id, str) { + console.log(id + ":", str.length * 2, "bytes", Math.round(str.length / 5.12) / 100, "kb"); + } + $("#submit").on("click", function() { + $("#popup-upload").fadeOut(); + if ($("#input").val()) { + memory = ""; + var raw = $("#input").val(); + var paste = LZString.compressToUTF16(raw); + logSize("Raw", raw); + logSize("Compressed", paste); + if (paste.length * 2 > 524288) { + $("#output").html('

    Unable to save!

    This log cannot be saved due to its size.
    ' + $("#input").val() + '
    '); + return; + } + console.log("paste:", paste); + var packet = { + api_dev_key: "b8219d942109d1e60ebb14fbb45f06f9", + api_option: "paste", + api_paste_private: 1, + api_paste_code: paste, + api_paste_expire_date: "1W" + }; + $("#uploader").attr("data-text", "Saving..."); + $("#uploader").fadeIn(); + var uri = proxies[Math.floor(Math.random() * proxies.length)] + "pastebin.com/api/api_post.php"; + console.log(packet, uri); + $.post(uri, packet, function(data, state, xhr) { + $("#uploader").fadeOut(); + console.log("Result: ", data); + if (data.substring(0, 15) == "Bad API request") + $("#output").html('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: Upload

    Error: ' + data + '
    ' + $("#input").val() + '
    '); + else if (data) + location.href = "?" + data.split('/').pop(); + else + $("#output").html('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: Upload

    Error: Received null response
    ' + $("#input").val() + '
    '); + }) + } else { + alert("Unable to parse log, the input is empty!"); + $("#uploader").fadeOut(); + } + }) + $("#cancel").on("click", function() { + $("#popup-upload").fadeOut(400, function() { + $("#input").val(memory); + memory = ""; + }); + }); + $("#closeraw").on("click", function() { + $("#popup-raw").fadeOut(400); + }) + if (location.search) { + getData(); + } + else + $("#popup-upload").fadeIn(); +}) diff --git a/src/SMAPI.Web/wwwroot/Content/main.css b/src/SMAPI.Web/wwwroot/Content/main.css deleted file mode 100644 index c8ce8d33..00000000 --- a/src/SMAPI.Web/wwwroot/Content/main.css +++ /dev/null @@ -1,107 +0,0 @@ -/* tags */ -html { - height: 100%; -} - -body { - height: 100%; - font-family: sans-serif; -} - -h1, h2, h3 { - font-weight: bold; - margin: 0.2em 0 0.1em 0; - padding-top: .5em; -} - -h1 { - font-size: 1.5em; - color: #888; - margin-bottom: 0; -} - -h2 { - font-size: 1.5em; - border-bottom: 1px solid #AAA; -} - -h3 { - font-size: 1.2em; - border-bottom: 1px solid #AAA; - width: 50%; -} - -a { - color: #006; -} - -/* content */ -#content-column { - position: absolute; - top: 1em; - left: 10em; -} - -#content { - min-height: 140px; - padding: 0 1em 1em 1em; - border-left: 1px solid #CCC; - background: #FFF; - font-size: 0.9em; -} - -#content p { - max-width: 55em; -} - -.section { - border: 1px solid #CCC; - padding: 0.5em; - margin-bottom: 1em; -} - -/* sidebar */ -#sidebar { - margin-top: 3em; - min-height: 75%; - width: 12em; - background: url("sidebar-bg.gif") no-repeat top right; - color: #666; -} - -#sidebar h4 { - margin: 0 0 0.2em 0; - width: 10em; - border-bottom: 1px solid #CCC; - font-size: 0.8em; - font-weight: normal; -} - -#sidebar a { - color: #77B; - border: 0; -} - -#sidebar ul, #sidebar li { - margin: 0; - padding: 0; - list-style: none none; - font-size: 0.9em; - color: #888; -} - -#sidebar li { - margin-left: 1em; -} - -/* footer */ -#footer { - margin: 1em; - padding: 1em; - font-size: 0.6em; - color: gray; -} - -#footer a { - color: #669; -} diff --git a/src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif b/src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif deleted file mode 100644 index 48e9af5a..00000000 Binary files a/src/SMAPI.Web/wwwroot/Content/sidebar-bg.gif and /dev/null differ -- cgit From 467b9aa2df8532aa3cb94c84307c7012573d61d4 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 27 Oct 2017 19:38:37 -0400 Subject: integrate prototype into page layout (#358) --- src/SMAPI.Web/Views/LogParser/Index.cshtml | 197 +++++++++++------------ src/SMAPI.Web/wwwroot/Content/css/log-parser.css | 77 +++------ src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 2 +- 3 files changed, 122 insertions(+), 154 deletions(-) (limited to 'src/SMAPI.Web/wwwroot') diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 021293b6..87a3962b 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -6,114 +6,107 @@ + } -

    How to share a SMAPI log

    -
      -
    1. Find your SMAPI log.
    2. -
    3. Click the file and drag it onto the upload form below (or paste the text in).
    4. -
    5. Click Parse.
    6. -
    7. Share the link you get back.
    8. -
    +@********* +** Intro +*********@ +

    This page lets you upload, view, and share a SMAPI log to help troubleshoot mod issues.

    +

    Parsed log

    -TODO - - - - - SMAPI log parser - - - -
      -
    • TRACE
    • -
    • DEBUG
    • -
    • INFO
    • -
    • ALERT
    • -
    • WARN
    • -
    • ERROR
    • -
    • Click tabs to toggle message visibility
    • -
    • UPLOAD
    • -
    -
    - - - - - -