From 15935a3de7c71d9c623dd8bde8374cef5fcf0316 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Thu, 12 Sep 2024 15:49:45 +0100 Subject: [PATCH 01/21] update --- CHANGELOG.md | 6 ++++++ jinjafx_server.py | 4 ++-- kubernetes/Dockerfile | 4 ++-- www/logs.css | 11 ++++++++--- www/logs.html | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 923bc66..54dbe51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## CHANGELOG +### [24.9.1] - In Development +- Updated `/logs` so it can scroll back through the history +- Increased the size of `logring` from 128 to 1024 +- Updated Pandoc to 3.4 in Dockerfile + ### [24.9.0] - Sep 2, 2024 - Removed 'Fira Code' font from `/logs` as it adds no value over 'Consolas' - Updated `codemirror` JavaScript library to 5.65.17 @@ -329,6 +334,7 @@ ### 21.11.0 - Nov 29, 2021 - Initial release +[24.9.1]: https://github.com/cmason3/jinjafx_server/compare/24.9.0...24.9.1 [24.9.0]: https://github.com/cmason3/jinjafx_server/compare/24.6.4...24.9.0 [24.6.4]: https://github.com/cmason3/jinjafx_server/compare/24.6.3...24.6.4 [24.6.3]: https://github.com/cmason3/jinjafx_server/compare/24.6.2...24.6.3 diff --git a/jinjafx_server.py b/jinjafx_server.py index fe300e4..0c75b8c 100755 --- a/jinjafx_server.py +++ b/jinjafx_server.py @@ -28,7 +28,7 @@ import re, argparse, hashlib, traceback, glob, hmac, uuid, struct, binascii, gzip, requests, ctypes, subprocess import cmarkgfm, emoji -__version__ = '24.9.0' +__version__ = '24.9.1' llock = threading.RLock() rlock = threading.RLock() @@ -1047,7 +1047,7 @@ def log(t, ae=''): print('[' + timestamp + '] ' + t + ae) logring.append('[' + timestamp + '] ' + t + ae) - logring = logring[-128:] + logring = logring[-1024:] if logfile is not None: try: diff --git a/kubernetes/Dockerfile b/kubernetes/Dockerfile index 4b2292d..30859ef 100644 --- a/kubernetes/Dockerfile +++ b/kubernetes/Dockerfile @@ -7,8 +7,8 @@ RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends wget git build-essential; \ -wget -P /tmp https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-1-amd64.deb; \ -dpkg -i /tmp/pandoc-3.3-1-amd64.deb; \ +wget -P /tmp https://github.com/jgm/pandoc/releases/download/3.4/pandoc-3.4-1-amd64.deb; \ +dpkg -i /tmp/pandoc-3.4-1-amd64.deb; \ python3 -m venv /opt/jinjafx; \ /opt/jinjafx/bin/python3 -m pip install --upgrade git+https://github.com/cmason3/jinjafx_server.git@${BRANCH} lxml; \ diff --git a/www/logs.css b/www/logs.css index bce6538..533be12 100644 --- a/www/logs.css +++ b/www/logs.css @@ -4,10 +4,15 @@ body { } pre { height: 100%; - font-family: Consolas, monaco, monospace; - font-size: 14px; + font-size: 12pt; font-variant-ligatures: none; white-space: pre-wrap; word-break: break-all; - overflow-y: hidden; + overflow-y: scroll; + scrollbar-width: none; + -ms-overflow-style: none; +} +pre::-webkit-scrollbar { + width: 0; + height: 0; } diff --git a/www/logs.html b/www/logs.html index 375c023..0b496e5 100644 --- a/www/logs.html +++ b/www/logs.html @@ -7,7 +7,7 @@ - + From 5967ba008d82e5a1bcdf8e06d45df1e2259d8f35 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Sat, 14 Sep 2024 10:06:19 +0100 Subject: [PATCH 02/21] update font size of logs --- www/logs.css | 2 +- www/logs.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/logs.css b/www/logs.css index 533be12..90dc4df 100644 --- a/www/logs.css +++ b/www/logs.css @@ -4,7 +4,7 @@ body { } pre { height: 100%; - font-size: 12pt; + font-size: unset; font-variant-ligatures: none; white-space: pre-wrap; word-break: break-all; diff --git a/www/logs.html b/www/logs.html index 0b496e5..6641de2 100644 --- a/www/logs.html +++ b/www/logs.html @@ -7,7 +7,7 @@ - + From 4d94ef302e3f8a648e136ce84eef6305a1c85f45 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Mon, 23 Sep 2024 17:10:52 +0100 Subject: [PATCH 03/21] add ability to paste an image into the template --- www/index.html | 2 +- www/jinjafx_m.js | 59 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/www/index.html b/www/index.html index 5e71fe2..9e3b0b4 100644 --- a/www/index.html +++ b/www/index.html @@ -32,7 +32,7 @@ - +
diff --git a/www/jinjafx_m.js b/www/jinjafx_m.js index 9cba6fc..9fd154e 100644 --- a/www/jinjafx_m.js +++ b/www/jinjafx_m.js @@ -806,7 +806,7 @@ function getStatusText(code) { document.getElementById('get2').onclick = function() { jinjafx('get_link'); }; document.getElementById('update').onclick = function() { jinjafx('update_link'); }; document.getElementById('protect').onclick = function() { jinjafx('protect'); }; - + if (window.crypto.subtle) { document.getElementById('encrypt').classList.remove('d-none'); } @@ -1108,11 +1108,16 @@ function getStatusText(code) { csv_on = false; }; - window.cmData.on("beforeChange", onPaste); - window.cmTemplate.on("beforeChange", onPaste); - window.cmVars.on("beforeChange", onPaste); - window.cmgVars.on("beforeChange", onPaste); - + //window.cmData.on("beforeChange", beforeChange); + //window.cmVars.on("beforeChange", beforeChange); + //window.cmgVars.on("beforeChange", beforeChange); + //window.cmTemplate.on("beforeChange", beforeChange); + + window.cmData.on("paste", (cm, e) => onPaste(cm, e, window.cmData)); + window.cmVars.on("paste", (cm, e) => onPaste(cm, e, window.cmVars)); + window.cmgVars.on("paste", (cm, e) => onPaste(cm, e, window.cmgVars)); + window.cmTemplate.on("paste", (cm, e) => onPaste(cm, e, window.cmTemplate)); + window.cmData.on("change", onChange); window.cmVars.on("change", onChange); window.cmgVars.on("change", onChange); @@ -1703,7 +1708,46 @@ function getStatusText(code) { document.getElementById('protect').innerHTML = 'Protect Link'; } - function onPaste(cm, change) { + function onPaste(cm, e, target) { + var clipboardData = (e.originalEvent || e).clipboardData; + + if (clipboardData.items[0].type.indexOf("image") === 0) { + e.preventDefault(); + + var r = new FileReader(); + r.onload = function(e) { + var d = target.getDoc(); + var c = d.getCursor(); + + var x = '![](' + e.target.result + ')'; + d.replaceRange(x, { line: c.line, ch: c.ch }); + }; + r.readAsDataURL(clipboardData.items[0].getAsFile()); + } + else { + var t = clipboardData.getData('text/plain'); + + if (t.replace(/\r/g, '').indexOf('---\ndt:\n') > -1) { + var obj = jsyaml.load(t, jsyaml_schema); + if (obj != null) { + e.preventDefault(); + pending_dt = obj['dt']; + + if (dirty) { + if (confirm("Are You Sure?") === true) { + apply_dt(); + } + } + else { + apply_dt(); + } + } + } + } + } + + /* + function beforeChange(cm, change) { if (change.origin === "paste") { var t = change.text.join('\n'); @@ -1725,6 +1769,7 @@ function getStatusText(code) { } } } + */ function onBeforeUnload(e) { e.returnValue = 'Are you sure?'; From 9ee721feba174fcf29b3a7f205f7fcc542203074 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Mon, 23 Sep 2024 17:16:45 +0100 Subject: [PATCH 04/21] add ability to paste an image into the template --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 49aabfd..8cdab9e 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ JinjaFx Server supports the ability to use "output" tags to create different out ``` +You can also paste in an image and it will convert it to a Base64 encoded Data URI that is formatted as Markdown. + ### Ansible Vault JinjaFx Server supports the ability to perform Ansible Vault encryption of strings from within the browser using client side JavaScript. By clicking on the padlock it will prompt you for your string and the password to use which you can then use within `vars.yml`. JinjaFx doesn't support the ability to use different passwords for different strings within the same DataTemplate so it is important that all vaulted strings are using the same password within the same DataTemplate. From d383bac8d4bc7a7d0a18ee9d94e92133e6f84743 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Thu, 26 Sep 2024 14:42:46 +0100 Subject: [PATCH 05/21] update dockerfile --- kubernetes/Dockerfile | 5 ++++- www/index.html | 2 +- www/jinjafx_m.js | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kubernetes/Dockerfile b/kubernetes/Dockerfile index 30859ef..d2d0180 100644 --- a/kubernetes/Dockerfile +++ b/kubernetes/Dockerfile @@ -20,4 +20,7 @@ FROM docker.io/library/python:3.12-slim COPY --from=BUILD /opt/jinjafx /opt/jinjafx COPY --from=BUILD /usr/bin/pandoc /usr/bin/pandoc -ENTRYPOINT [ "/opt/jinjafx/bin/python3", "-u", "-m", "jinjafx_server", "-s", "-l", "0.0.0.0", "-p", "8080" ] +ENV VIRTUAL_ENV /opt/jinjafx +ENV PATH /opt/jinjafx/bin:${PATH} + +ENTRYPOINT [ "python3", "-u", "-m", "jinjafx_server", "-s", "-l", "0.0.0.0", "-p", "8080" ] diff --git a/www/index.html b/www/index.html index 9e3b0b4..11e189f 100644 --- a/www/index.html +++ b/www/index.html @@ -32,7 +32,7 @@ - +
diff --git a/www/jinjafx_m.js b/www/jinjafx_m.js index 9fd154e..462dd8a 100644 --- a/www/jinjafx_m.js +++ b/www/jinjafx_m.js @@ -1708,6 +1708,11 @@ function getStatusText(code) { document.getElementById('protect').innerHTML = 'Protect Link'; } + function onDrop(cm, e, target) { + + + } + function onPaste(cm, e, target) { var clipboardData = (e.originalEvent || e).clipboardData; From 60d0ffc8aaa90b8b0f4b8db3ece3032a8a3aa534 Mon Sep 17 00:00:00 2001 From: Chris Mason <57402469+cmason3@users.noreply.github.com> Date: Fri, 27 Sep 2024 07:31:18 +0100 Subject: [PATCH 06/21] Update Dockerfile --- kubernetes/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/Dockerfile b/kubernetes/Dockerfile index d2d0180..44cdc8a 100644 --- a/kubernetes/Dockerfile +++ b/kubernetes/Dockerfile @@ -1,6 +1,6 @@ FROM docker.io/library/python:3.12-slim AS BUILD -ARG BRANCH="main" +ARG BRANCH main RUN set -eux; \ From d679cdf4f1a9d8536f283e5d103feaafd83f4199 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 27 Sep 2024 12:27:44 +0100 Subject: [PATCH 07/21] update paste and drop --- www/index.html | 2 +- www/jinjafx_m.js | 99 +++++++++++++++++++++++------------------------- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/www/index.html b/www/index.html index 11e189f..9424007 100644 --- a/www/index.html +++ b/www/index.html @@ -32,7 +32,7 @@ - +
diff --git a/www/jinjafx_m.js b/www/jinjafx_m.js index 462dd8a..1f89c34 100644 --- a/www/jinjafx_m.js +++ b/www/jinjafx_m.js @@ -1108,15 +1108,15 @@ function getStatusText(code) { csv_on = false; }; - //window.cmData.on("beforeChange", beforeChange); - //window.cmVars.on("beforeChange", beforeChange); - //window.cmgVars.on("beforeChange", beforeChange); - //window.cmTemplate.on("beforeChange", beforeChange); + window.cmData.on("paste", onPaste); + window.cmVars.on("paste", onPaste); + window.cmgVars.on("paste", onPaste); + window.cmTemplate.on("paste", onPaste); - window.cmData.on("paste", (cm, e) => onPaste(cm, e, window.cmData)); - window.cmVars.on("paste", (cm, e) => onPaste(cm, e, window.cmVars)); - window.cmgVars.on("paste", (cm, e) => onPaste(cm, e, window.cmgVars)); - window.cmTemplate.on("paste", (cm, e) => onPaste(cm, e, window.cmTemplate)); + window.cmData.on("drop", onDrop); + window.cmVars.on("drop", onDrop); + window.cmgVars.on("drop", onDrop); + window.cmTemplate.on("drop", onDrop); window.cmData.on("change", onChange); window.cmVars.on("change", onChange); @@ -1708,15 +1708,8 @@ function getStatusText(code) { document.getElementById('protect').innerHTML = 'Protect Link'; } - function onDrop(cm, e, target) { - - - } - - function onPaste(cm, e, target) { - var clipboardData = (e.originalEvent || e).clipboardData; - - if (clipboardData.items[0].type.indexOf("image") === 0) { + function onPasteOrDrop(e, obj, target) { + if (obj.items[0].type.indexOf("image") === 0) { e.preventDefault(); var r = new FileReader(); @@ -1727,54 +1720,56 @@ function getStatusText(code) { var x = '![](' + e.target.result + ')'; d.replaceRange(x, { line: c.line, ch: c.ch }); }; - r.readAsDataURL(clipboardData.items[0].getAsFile()); + r.readAsDataURL(obj.files[0]); } - else { - var t = clipboardData.getData('text/plain'); + else if (obj.items[0].type.indexOf("text") === 0) { + e.preventDefault(); - if (t.replace(/\r/g, '').indexOf('---\ndt:\n') > -1) { - var obj = jsyaml.load(t, jsyaml_schema); - if (obj != null) { - e.preventDefault(); - pending_dt = obj['dt']; + var process_text = function(t) { + if (t.replace(/\r/g, '').indexOf('---\ndt:\n') > -1) { + var obj = jsyaml.load(t, jsyaml_schema); + if (obj != null) { + pending_dt = obj['dt']; - if (dirty) { - if (confirm("Are You Sure?") === true) { + if (dirty) { + if (confirm("Are You Sure?") === true) { + apply_dt(); + } + } + else { apply_dt(); } } - else { - apply_dt(); - } } + else { + var d = target.getDoc(); + var c = d.getCursor(); + d.replaceRange(t, { line: c.line, ch: c.ch }); + } + }; + + if (typeof obj.files[0] !== "undefined") { + var r = new FileReader(); + r.onload = function(re) { + process_text(re.target.result); + }; + r.readAsText(obj.files[0]); + } + else { + process_text(obj.getData("text")); } } } - /* - function beforeChange(cm, change) { - if (change.origin === "paste") { - var t = change.text.join('\n'); - - if (t.replace(/\r/g, '').indexOf('---\ndt:\n') > -1) { - var obj = jsyaml.load(t, jsyaml_schema); - if (obj != null) { - change.cancel(); - pending_dt = obj['dt']; + function onDrop(cm, e) { + var dataTransfer = (e.originalEvent || e).dataTransfer; + onPasteOrDrop(e, dataTransfer, cm); + } - if (dirty) { - if (confirm("Are You Sure?") === true) { - apply_dt(); - } - } - else { - apply_dt(); - } - } - } - } + function onPaste(cm, e) { + var clipboardData = (e.originalEvent || e).clipboardData; + onPasteOrDrop(e, clipboardData, cm); } - */ function onBeforeUnload(e) { e.returnValue = 'Are you sure?'; From 4f2f647f3d8b69da6d1794e0d1753080450320d5 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 27 Sep 2024 14:22:41 +0100 Subject: [PATCH 08/21] update paste and drop --- www/index.html | 2 +- www/jinjafx_m.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/www/index.html b/www/index.html index 9424007..d501695 100644 --- a/www/index.html +++ b/www/index.html @@ -32,7 +32,7 @@ - +
diff --git a/www/jinjafx_m.js b/www/jinjafx_m.js index 1f89c34..c936e5d 100644 --- a/www/jinjafx_m.js +++ b/www/jinjafx_m.js @@ -932,7 +932,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, - mode: "data", +// mode: "data", viewportMargin: 80, smartIndent: false }); @@ -942,7 +942,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, - mode: "yaml", +// mode: "yaml", viewportMargin: 80, smartIndent: false, showTrailingSpace: true @@ -953,7 +953,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, - mode: "yaml", +// mode: "yaml", viewportMargin: 80, smartIndent: false, showTrailingSpace: true @@ -1072,7 +1072,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, - mode: "template", +// mode: "template", viewportMargin: 80, smartIndent: false, showTrailingSpace: true, @@ -1722,7 +1722,7 @@ function getStatusText(code) { }; r.readAsDataURL(obj.files[0]); } - else if (obj.items[0].type.indexOf("text") === 0) { + else { e.preventDefault(); var process_text = function(t) { From 2a0ad87cd55f719c14c03295bcfceaadd3adaf57 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 27 Sep 2024 14:23:48 +0100 Subject: [PATCH 09/21] update paste and drop --- www/jinjafx_m.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/jinjafx_m.js b/www/jinjafx_m.js index c936e5d..4cddf7f 100644 --- a/www/jinjafx_m.js +++ b/www/jinjafx_m.js @@ -932,7 +932,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, -// mode: "data", + mode: "data", viewportMargin: 80, smartIndent: false }); @@ -942,7 +942,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, -// mode: "yaml", + mode: "yaml", viewportMargin: 80, smartIndent: false, showTrailingSpace: true @@ -953,7 +953,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, -// mode: "yaml", + mode: "yaml", viewportMargin: 80, smartIndent: false, showTrailingSpace: true @@ -1072,7 +1072,7 @@ function getStatusText(code) { scrollbarStyle: "null", styleSelectedText: false, extraKeys: gExtraKeys, -// mode: "template", + mode: "template", viewportMargin: 80, smartIndent: false, showTrailingSpace: true, From ca3bceb14e2af9be08185cb209e8b2b5ecb684a7 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Mon, 30 Sep 2024 09:04:40 +0100 Subject: [PATCH 10/21] update paste and drop --- CHANGELOG.md | 2 +- jinjafx_server.py | 2 +- www/dt.html | 3 +- www/index.html | 2 +- www/jinjafx_dt.css | 6 +++ www/{logs.css => jinjafx_logs.css} | 0 www/{logs.js => jinjafx_logs.js} | 0 www/jinjafx_m.js | 69 ++++++++++++++---------------- www/logs.html | 4 +- 9 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 www/jinjafx_dt.css rename www/{logs.css => jinjafx_logs.css} (100%) rename www/{logs.js => jinjafx_logs.js} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54dbe51..3782578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## CHANGELOG -### [24.9.1] - In Development +### [24.10.0] - In Development - Updated `/logs` so it can scroll back through the history - Increased the size of `logring` from 128 to 1024 - Updated Pandoc to 3.4 in Dockerfile diff --git a/jinjafx_server.py b/jinjafx_server.py index 0c75b8c..e6f1a14 100755 --- a/jinjafx_server.py +++ b/jinjafx_server.py @@ -28,7 +28,7 @@ import re, argparse, hashlib, traceback, glob, hmac, uuid, struct, binascii, gzip, requests, ctypes, subprocess import cmarkgfm, emoji -__version__ = '24.9.1' +__version__ = '24.10.0' llock = threading.RLock() rlock = threading.RLock() diff --git a/www/dt.html b/www/dt.html index bc77324..dfdf901 100644 --- a/www/dt.html +++ b/www/dt.html @@ -7,10 +7,11 @@ + -
+