Skip to content

Commit

Permalink
Merge pull request #70 from cmason3/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
cmason3 authored Feb 11, 2025
2 parents 2c21a8a + 3f09f66 commit d5411a6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGELOG

### [25.5.1] - Feb 11, 2025
- Changed behaviour of `jinjafx_vault_undefined`, so it only returns undefined if the password is missing
- Added support for adding blank lines between output sections using `</output\n>` as closing tag

### [25.5.0] - Feb 10, 2025
- Disabled dropdowns for DataSets and Templates are now opaque and don't show text behind them
- Overhauled how Ansible Vault works and added `jinjafx_vault_undefined` from JinjaFx
Expand Down Expand Up @@ -406,6 +410,7 @@
- Initial release


[25.5.1]: https://github.com/cmason3/jinjafx_server/compare/25.5.0...25.5.1
[25.5.0]: https://github.com/cmason3/jinjafx_server/compare/25.4.0...25.5.0
[25.4.0]: https://github.com/cmason3/jinjafx_server/compare/25.3.2...25.4.0
[25.3.2]: https://github.com/cmason3/jinjafx_server/compare/25.3.1...25.3.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ You can also paste in an image and it will convert it to a Base64 encoded Data U

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.

By default JinjaFx will fail with "invalid ansible vault password" if the provided Ansible Vault password is incorrect. The `jinjafx_vault_undefined` variable allows you to change this behaviour - if set to `True` then it will proceed to process the template, but if it can't decrypt a vaulted variable due to an incorrect or missing password then the variable won't be defined.
By default JinjaFx will fail with "invalid ansible vault password" if the provided Ansible Vault password is empty or missing. The `jinjafx_vault_undefined` variable allows you to change this behaviour - if set to `True` then it will proceed to process the template, but if it can't decrypt a vaulted variable due to a missing password then the variable won't be defined.

### JinjaFx Input

Expand Down
5 changes: 4 additions & 1 deletion jinjafx_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import re, argparse, hashlib, traceback, glob, hmac, uuid, struct, binascii, gzip, requests, ctypes, subprocess
import cmarkgfm, emoji

__version__ = '25.5.0'
__version__ = '25.5.1'

llock = threading.RLock()
rlock = threading.RLock()
Expand Down Expand Up @@ -502,6 +502,9 @@ def do_POST(self):
if y := yaml.load(gyaml, Loader=yaml.SafeLoader):
vault_undef = y.get('jinjafx_vault_undefined', vault_undef)

if vpw.strip():
vault_undef = False

def yaml_vault_tag(loader, node):
x = jinjafx.AnsibleVault().decrypt(node.value.encode('utf-8'), vpw, vault_undef)
if x is not None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
packages=["jinjafx_server"],
include_package_data=True,
package_data={'': ['www/*', 'pandoc/reference.docx']},
install_requires=["jinjafx>=1.24.3", "requests", "cmarkgfm>=0.5.0", "emoji"],
install_requires=["jinjafx>=1.24.4", "requests", "cmarkgfm>=0.5.0", "emoji"],
entry_points={
"console_scripts": [
"jinjafx_server=jinjafx_server:main",
Expand Down
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js" integrity="sha512-CSBhVREyzHAjAFfBlIBakjoRUKp5h7VSweP0InR/pAJyptH7peuhCsqAI/snV+TwZmXZqoUklpXp6R6wMnYf5Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.13/dayjs.min.js" integrity="sha512-FwNWaxyfy2XlEINoSnZh1JQ5TRRtGow0D6XcmAWmYCRgvqOUTnzCxPc9uF35u5ZEpirk1uhlPVA19tflhvnW1g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.13/plugin/relativeTime.min.js" integrity="sha512-MVzDPmm7QZ8PhEiqJXKz/zw2HJuv61waxb8XXuZMMs9b+an3LoqOqhOEt5Nq3LY1e4Ipbbd/e+AWgERdHlVgaA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="/cf757af4/jinjafx_m.js"></script>
<script src="/84403509/jinjafx_m.js"></script>
</head>
<body>
<div id="overlay"></div>
Expand Down
4 changes: 2 additions & 2 deletions www/jinjafx_m.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ function getStatusText(code) {
set_wait();

var rbody = vars['jinjafx_input']['body'];
rbody = rbody.replace(/<(?:output[\t ]+.+?|\/output[\t ]*)>.*?\n/gi, '');
rbody = rbody.replace(/<(?:output[\t ]+.+?|\/output[\t ]*(?:\\n[\t ]*)?)>.*?\n/gi, '');

xHR.timeout = 10000;
xHR.setRequestHeader("Content-Type", "application/json");
Expand Down Expand Up @@ -1331,7 +1331,7 @@ function getStatusText(code) {
state.output = 1;
return "jfx-output-left";
}
else if (stream.match(/<(?=\/output *>)/i)) {
else if (stream.match(/<(?=\/output *(?:\\n *)?>)/i)) {
state.type = 2;
state.output = 1;
return "jfx-output-left";
Expand Down

0 comments on commit d5411a6

Please sign in to comment.