Skip to content

Commit

Permalink
Merge pull request #2 from cmason3/21.12.3-beta
Browse files Browse the repository at this point in the history
21.12.3 beta
  • Loading branch information
cmason3 authored Dec 12, 2021
2 parents ce81b7f + 5f21c72 commit 3da559a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 19 deletions.
2 changes: 1 addition & 1 deletion jinjafx_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import jinjafx, os, io, sys, socket, signal, threading, yaml, json, base64, time, datetime
import re, argparse, zipfile, hashlib, traceback, glob, hmac, uuid, struct, binascii, gzip

__version__ = '21.12.2'
__version__ = '21.12.3'

try:
import requests
Expand Down
3 changes: 0 additions & 3 deletions www/jinjafx_m.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,3 @@ body {
.cm-jfx-header {
font-weight: bold;
}
.cm-jfx-invalid {
background: red;
}
61 changes: 47 additions & 14 deletions www/jinjafx_m.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function getStatusText(code) {
var protect_ok = false;
var csv_on = false;
var dicon = "ldata";
var cDataPos = null;

var jsyaml_schema = {
schema: jsyaml.DEFAULT_SCHEMA.extend(['scalar', 'sequence', 'mapping'].map(function(kind) {
Expand Down Expand Up @@ -130,17 +131,22 @@ function getStatusText(code) {
dt.id = dt_id;
dt.dataset = current_ds;

if (vaulted_vars) {
new bootstrap.Modal(document.getElementById('vault_input'), {
keyboard: false
}).show();
if (JSON.stringify(dt).length > 2048 * 1024) {
set_status("darkred", "ERROR", 'Content Too Large');
}
else {
if (dt_id != '') {
window.open("output.html?dt=" + dt_id, "_blank");
if (vaulted_vars) {
new bootstrap.Modal(document.getElementById('vault_input'), {
keyboard: false
}).show();
}
else {
window.open("output.html", "_blank");
if (dt_id != '') {
window.open("output.html?dt=" + dt_id, "_blank");
}
else {
window.open("output.html", "_blank");
}
}
}
}
Expand Down Expand Up @@ -186,11 +192,32 @@ function getStatusText(code) {
return false;
}

var cTemplate = window.cmTemplate.getSearchCursor(/[^\u0000-\u007f]/);
var nonAsciiRegex = /[^\u0000-\u007f]+/;
var cTemplate = window.cmTemplate.getSearchCursor(nonAsciiRegex);
if (cTemplate.findNext()) {
window.cmTemplate.focus();
window.cmTemplate.setSelection(cTemplate.from(), cTemplate.to());
set_status("darkred", "ERROR", "Non ASCII Character in Template");
set_status("darkred", "ERROR", "Non ASCII Character(s) in 'template.j2'");
return false;
}
var cData = window.cmData.getSearchCursor(nonAsciiRegex);
if (cData.findNext()) {
if (csv_on) {
cDataPos = [cData.from(), cData.to()];
document.getElementById("csv").dispatchEvent(new CustomEvent('click'));
}
else {
window.cmData.focus();
window.cmData.setSelection(cData.from(), cData.to());
}
set_status("darkred", "ERROR", "Non ASCII Character(s) in 'data.csv'");
return false;
}
var cVars = window.cmVars.getSearchCursor(nonAsciiRegex);
if (cVars.findNext()) {
window.cmVars.focus();
window.cmVars.setSelection(cVars.from(), cVars.to());
set_status("darkred", "ERROR", "Non ASCII Character(s) in 'vars.yml'");
return false;
}

Expand Down Expand Up @@ -393,7 +420,7 @@ function getStatusText(code) {
}
catch (ex) {
console.log(ex);
set_status("darkred", "ERROR", "Invalid Character Encoding in DataTemplate");
set_status("darkred", "ERROR", ex);
clear_wait();
}
}
Expand Down Expand Up @@ -470,7 +497,10 @@ function getStatusText(code) {
xHR.setRequestHeader("Content-Type", "application/json");

var rd = JSON.stringify(dt);
if (rd.length > 1024) {
if (rd.length > 2048 * 1024) {
set_status("darkred", "ERROR", 'Content Too Large');
}
else if (rd.length > 1024) {
xHR.setRequestHeader("Content-Encoding", "gzip");
xHR.send(pako.gzip(rd));
}
Expand Down Expand Up @@ -745,6 +775,12 @@ function getStatusText(code) {
document.getElementById(dicon).classList.remove('d-none');
window.cmData.refresh();
window.cmData.focus();

if (cDataPos != null) {
window.cmData.setSelection(cDataPos[0], cDataPos[1]);
window.cmData.scrollIntoView({from: cDataPos[0], to: cDataPos[1]}, 20);
cDataPos = null;
}
csv_on = false;
};

Expand Down Expand Up @@ -1455,9 +1491,6 @@ function getStatusText(code) {
stream.skipToEnd();
return "comment";
}
if (stream.match(/[^\t -~]/)) {
return "jfx-invalid";
}
if ((state.n == 1) && stream.sol()) {
state.n = 2;
}
Expand Down
5 changes: 4 additions & 1 deletion www/jinjafx_o.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
xHR.setRequestHeader("Content-Type", "application/json");

var rd = JSON.stringify(obj.outputs);
if (rd.length > 1024) {
if (rd.length > 2048 * 1024) {
set_status("darkred", "ERROR", 'Content Too Large');
}
else if (rd.length > 1024) {
xHR.setRequestHeader("Content-Encoding", "gzip");
xHR.send(pako.gzip(rd));
}
Expand Down

0 comments on commit 3da559a

Please sign in to comment.