Skip to content

Commit

Permalink
Merge pull request #66 from cmason3/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
cmason3 authored Feb 10, 2025
2 parents 4c6000b + a046c2f commit 52a91b6
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 84 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## CHANGELOG

### [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
- Updated Pandoc to 3.6.3 in Dockerfile

### [25.4.0] - Feb 3, 2025
- Add the ability to hide the `Global.yml` pane via a toggle switch
- If you delete a DataSet or Template with the dropdown open it will now close automatically.
Expand Down Expand Up @@ -400,6 +405,7 @@
- Initial release


[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
[25.3.1]: https://github.com/cmason3/jinjafx_server/compare/25.3.0...25.3.1
Expand Down
39 changes: 29 additions & 10 deletions 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.4.0'
__version__ = '25.5.0'

llock = threading.RLock()
rlock = threading.RLock()
Expand Down Expand Up @@ -494,23 +494,42 @@ def do_POST(self):

if 'vars' in dt and len(dt['vars'].strip()) > 0:
gyaml = self.d(dt['vars']).decode('utf-8')
vpw = self.d(dt['vpw']).decode('utf-8') if 'vpw' in dt else ''
vault_undef = False

if 'vpw' in dt:
vpw = self.d(dt['vpw']).decode('utf-8')
if 'jinjafx_vault_undefined' in gyaml:
yaml.add_constructor('!vault', lambda x, y: None, yaml.SafeLoader)
if y := yaml.load(gyaml, Loader=yaml.SafeLoader):
vault_undef = y.get('jinjafx_vault_undefined', vault_undef)

if gyaml.lstrip().startswith('$ANSIBLE_VAULT;'):
gyaml = jinjafx.AnsibleVault().decrypt(gyaml.encode('utf-8'), vpw).decode('utf-8')
def yaml_vault_tag(loader, node):
x = jinjafx.AnsibleVault().decrypt(node.value.encode('utf-8'), vpw, vault_undef)
if x is not None:
return x.decode('utf-8')

def yaml_vault_tag(loader, node):
return jinjafx.AnsibleVault().decrypt(node.value.encode('utf-8'), vpw).decode('utf-8')
else:
return '_undef'

yaml.add_constructor('!vault', yaml_vault_tag, yaml.SafeLoader)
yaml.add_constructor('!vault', yaml_vault_tag, yaml.SafeLoader)

y = yaml.load(gyaml, Loader=yaml.SafeLoader)
if y != None:
if y := yaml.load(gyaml, Loader=yaml.SafeLoader):
if isinstance(y, list):
y = {'_': y}

s = [y]

while s:
c = s.pop()
for key in list(c.keys()):
if c[key] == '_undef':
del c[key]
elif isinstance(c[key], dict):
s.append(c[key])
elif isinstance(c[key], list):
for item in c[key]:
if isinstance(item, dict):
s.append(item)

gvars.update(y)

st = round(time.time() * 1000)
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.2/pandoc-3.6.2-1-amd64.deb; \
dpkg -i /tmp/pandoc-3.6.2-1-amd64.deb; \
wget -P /tmp https://github.com/jgm/pandoc/releases/download/3.6.3/pandoc-3.6.3-1-amd64.deb; \
dpkg -i /tmp/pandoc-3.6.3-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; \
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.0", "requests", "cmarkgfm>=0.5.0", "emoji"],
install_requires=["jinjafx>=1.24.3", "requests", "cmarkgfm>=0.5.0", "emoji"],
entry_points={
"console_scripts": [
"jinjafx_server=jinjafx_server:main",
Expand Down
50 changes: 21 additions & 29 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/addon/display/fullscreen.min.css" integrity="sha512-T8xB3MmwpA77VK9lUH3UkdUTnkmpqOxHF8OceOKaHrvpcXMSNX0xtpa9FoLTDAVO1JnB2UiMdVeI2V0HTHjTWA==" crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/addon/fold/foldgutter.min.css" integrity="sha512-YwkMTlTHn8dBnwa47IF+cKsS00HPiiVhQ4DpwT1KF2gUftfFR7aefepabSPLAs6zrMyD89M3w0Ow6mQ5XJEUCw==" crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="/bb176715/jinjafx.css">
<link rel="stylesheet" href="/7a0bef24/jinjafx_m.css">
<link rel="stylesheet" href="/5ae811ff/jinjafx_m.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js" integrity="sha512-7Pi/otdlbbCR+LnW+F7PwFcSDJOuUJB3OxtEHbg4vSMvzvJjde4Po1v4BR9Gdc9aXNUNFVUY+SK51wWT8WF0Gg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/codemirror.min.js" integrity="sha512-6cPYokihlrofMNApz7OXVQNObWjLiKGIBBb7+UB+AuMiRCLKmFKgrwms21sHq3bdFFZWpfHYRJBJvMFMPj1S9g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.18/addon/selection/mark-selection.min.js" integrity="sha512-XaS0JPIY5yDTDaYIMjkoXz+LF/DEVhRn1eq9QOhJPhMuJGGPOKZTulF+LY8/uwd18k00CIaSe4f8fCyp/5U7IQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Expand All @@ -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="/1e6090c7/jinjafx_m.js"></script>
<script src="/b000c1ba/jinjafx_m.js"></script>
</head>
<body>
<div id="overlay"></div>
Expand All @@ -57,7 +57,7 @@ <h5 id="title">
<div id="buttons" class="btn-toolbar ms-auto d-flex d-none" role="group">
<div class="btn-group me-2">
<div class="btn-group">
<button id="select_ds" type="button" class="btn btn-warning text-black text-start mw-150" data-bs-toggle="dropdown" title="Select DataSet" disabled>
<button id="select_ds" type="button" class="btn btn-warning text-black text-start mw-150 btn-warn-opaque" data-bs-toggle="dropdown" title="Select DataSet" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="12 2 2 7 12 12 22 7 12 2" />
<polyline points="2 17 12 22 22 17" />
Expand All @@ -66,8 +66,8 @@ <h5 id="title">
</button>
<div id="datasets" class="dropdown-menu"></div>
</div>
<button id="delete_ds" type="button" class="btn btn-warning text-black" title="Delete DataSet" disabled>-</button>
<button id="add_ds" type="button" class="btn btn-warning text-black" title="Add DataSet">+</button>
<button id="delete_ds" type="button" class="btn btn-warning text-black btn-warn-opaque" title="Delete DataSet" disabled>-</button>
<button id="add_ds" type="button" class="btn btn-warning text-black btn-warn-opaque" title="Add DataSet">+</button>
</div>

<button id="encrypt" type="button" class="btn btn-secondary text-white me-2 d-none" title="Encrypt String with Ansible Vault">
Expand Down Expand Up @@ -169,17 +169,28 @@ <h5 id="title">
<div id="xlvars" class="position-relative h-100">
<div class="badge lb-vars float-start labels">V<br />A<br />R<br />S<br />.<br />Y<br />M<br />L<br /></div>
<textarea id="vars"></textarea>
<span id="ansible-vault" class="topright d-none">
<div class="input-group mw-250">
<span class="input-group-text" title="Ansible Vault Password">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
</span>
<input id="vault-password" type="password" class="form-control" placeholder="Vault Password">
</div>
</span>
</div>
</div>
</div>
<div id="ctemplate" class="position-relative">
<div class="badge lb-template float-start labels">T<br />E<br />M<br />P<br />L<br />A<br />T<br />E<br />.<br />J<br />2<br /></div>
<textarea id="template"></textarea>
<span id="stemplates" class="templates">
<span id="stemplates" class="topright">
<div class="btn-group">
<div class="btn-group">
<button id="select_t" type="button" class="btn btn-warning btn-sm text-start mw-150" data-bs-toggle="dropdown" title="Select Template" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<button id="select_t" type="button" class="btn btn-warning btn-sm text-start mw-150 btn-warn-opaque" data-bs-toggle="dropdown" title="Select Template" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
Expand All @@ -188,8 +199,8 @@ <h5 id="title">
</button>
<div id="templates" class="dropdown-menu"></div>
</div>
<button id="delete_t" type="button" class="btn btn-warning btn-sm" title="Delete Template" disabled>-</button>
<button id="add_t" type="button" class="btn btn-warning btn-sm" title="Add Template">+</button>
<button id="delete_t" type="button" class="btn btn-warning btn-sm btn-warn-opaque" title="Delete Template" disabled>-</button>
<button id="add_t" type="button" class="btn btn-warning btn-sm btn-warn-opaque" title="Add Template">+</button>
</div>
</span>
<span id="template_info" class="info">
Expand Down Expand Up @@ -274,25 +285,6 @@ <h6 class="text-end">JinjaFx v{{ jinjafx.version }}<br /><a class="small" href="
</div>
</div>
</div>
<div id="vault_input" class="modal fade" role="dialog">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 id="ml-title" class="mt-0">Ansible Vault</h4>
</div>
<div class="form-group row modal-body">
<label for="vault" class="col-sm-12 col-form-label">Vault Password</label>
<div class="col-sm-12">
<input type="password" class="form-control" id="vault">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button id="ml-vault-ok" type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<div id="vault_encrypt" class="modal fade" role="dialog">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
Expand Down
11 changes: 10 additions & 1 deletion www/jinjafx_m.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ body {
textarea {
resize: none;
}
.btn-warn-opaque:disabled {
color: #535353 !important;
border-color: #ffd75e !important;
background-color: #ffd75e !important;
opacity: 1 !important;
}
.mw-150 {
min-width: 150px;
}
.mw-250 {
min-width: 250px;
}
.me-10 {
margin-right: 10px;
}
Expand Down Expand Up @@ -85,7 +94,7 @@ textarea {
border-radius: 0.5rem;
padding: 10px;
}
.templates {
.topright {
position: absolute;
z-index: 2;
right: 8px;
Expand Down
Loading

0 comments on commit 52a91b6

Please sign in to comment.