Skip to content

Commit 43c4ee8

Browse files
committed
Add infrastructureascode.ch branding, update dependencies
1 parent f670943 commit 43c4ee8

File tree

9 files changed

+1508
-854
lines changed

9 files changed

+1508
-854
lines changed

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,29 @@ FROM python:3.8
44
WORKDIR /jinja101
55
RUN useradd -m jinja101
66

7-
ENV PATH="/root/.poetry/bin:$PATH" \
7+
ENV PATH="/root/.local/bin:$PATH" \
88
PYTHONDONTWRITEBYTECODE=1 \
99
PYTHONUNBUFFERED=1
1010

1111

1212
RUN apt-get update && apt-get install curl -y \
1313
&& rm -rf /var/lib/apt/lists/* \
14-
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python \
14+
&& curl -sSL https://install.python-poetry.org | python3 \
1515
&& poetry config virtualenvs.create false
1616

1717
COPY --chown=jinja101:jinja101 pyproject.toml .
18-
COPY --chown=jinja101:jinja101 poetry.lock .
18+
# COPY --chown=jinja101:jinja101 poetry.lock .
1919

2020
# poetry does not support subdirectory yet
2121
RUN pip install "git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backend" \
2222
&& pip install "git+https://github.com/StackStorm/[email protected]#subdirectory=st2common" \
2323
&& poetry install --no-dev --no-interaction --no-ansi
2424

25+
2526
COPY --chown=jinja101:jinja101 . .
2627

2728
USER jinja101
29+
RUN ansible-galaxy collection install ansible.netcommon
2830

2931
EXPOSE 5000/tcp
3032

examples.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Ansible Filter:
227227
228228
{{ '52:54:00' | community.general.random_mac }}
229229
{% for i in range(10, 20) %}
230-
{{ ip_net | ansible.netcommon.ipaddr(i) }}{% endfor %}
230+
{{ ip_net | ansible.utils.ipaddr(i) }}{% endfor %}
231231
232232
{{ text | hash('sha1') }}
233233
{{ text | hash('md5') }}

flask_app.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import json
21
import jinja2
32
import yaml
43
from jinja2.sandbox import SandboxedEnvironment
5-
from flask import Flask, render_template, request, Response, url_for, jsonify
4+
from flask import Flask, render_template, request, jsonify
65
from load_filter import load_filter_ansible, load_filter_salt, load_filter_st2
76

87
app = Flask(__name__, static_url_path="/static")
9-
app.config['JSON_SORT_KEYS'] = False
8+
app.json.sort_keys = False
9+
app.config.update(
10+
TITLE="Jinaj101",
11+
SUBTITLE="Playground for jinja2 templates",
12+
GITHUB="https://github.com/infrastructureAsCode-ch/jinja101/"
13+
)
1014

1115
MAP_UNDEFINED = {
1216
"jinja2.Undefined": jinja2.Undefined,
@@ -23,12 +27,6 @@ def index():
2327
return render_template("index.html")
2428

2529

26-
@app.route("/demo")
27-
@app.route("/demo/<name>")
28-
def demo(name=False):
29-
return render_template("demo.html", name=name)
30-
31-
3230
@app.route("/examples")
3331
def examples():
3432
try:
@@ -96,4 +94,4 @@ def rend():
9694

9795

9896
if __name__ == "__main__":
99-
app.run(debug=True)
97+
app.run(debug=True, host="0.0.0.0")

poetry.lock

Lines changed: 1090 additions & 677 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
[tool.poetry]
22
name = "jinja101"
3-
version = "0.1.4"
4-
description = ""
3+
version = "0.2.0"
4+
description = "Playground for jinja2 templates"
55
authors = ["ubaumann <[email protected]>"]
66

77
[tool.poetry.dependencies]
88
python = "^3.8"
9-
flask = "^2.0.1"
10-
pyaml = "^21.10.1"
11-
gunicorn = "^20.1.0"
12-
ansible = "^5"
13-
salt = "^3004"
14-
netaddr = "^0.8.0"
15-
timelib = "^0.2.5"
16-
jmespath = "^0.10.0"
9+
flask = "*"
10+
pyaml = "*"
11+
gunicorn = "*"
12+
ansible = "*"
13+
salt = "*"
14+
netaddr = "*"
15+
timelib = "*"
16+
jmespath = "*"
1717

1818
[tool.poetry.dev-dependencies]
19-
black = "^21.12b0"
20-
pylama = "^8.3.7"
21-
rich = "^11.0.0"
19+
black = "^23"
20+
pylama = "^8"
21+
rich = "^13"
22+
pytest = "^7.4.4"
23+
24+
[tool.poetry.group.dev.dependencies]
25+
black = "^23.12.1"
2226

2327
[build-system]
2428
requires = ["poetry>=0.12"]

static/background.jpg

596 KB
Loading

templates/demo.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

templates/form.html

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<div class="container-fluid">
2+
<form id="templateForm" method="POST" action="rend">
3+
<div class="row">
4+
<div class="col">
5+
<p>
6+
<button class="btn btn-primary mt20" type="button" data-toggle="collapse"
7+
data-target="#environmentSettings" aria-expanded="false"
8+
aria-controls="environmentSettings">
9+
Environment Settings
10+
</button>
11+
</p>
12+
<div class="collapse" id="environmentSettings">
13+
<p>
14+
<div class="card card-body">
15+
<div class="form-check">
16+
<input type="checkbox" class="form-check-input" id="trim_blocks" name="trim_blocks">
17+
<label class="form-check-label" for="trim_blocks">trim_blocks</label>
18+
<small id="trimHelp" class="form-text text-muted">If this is set to True the first
19+
newline after a block is removed (block, not variable tag!). Defaults to
20+
False.</small>
21+
</div>
22+
23+
<div class="form-check">
24+
<input type="checkbox" class="form-check-input" id="lstrip_blocks" name="lstrip_blocks">
25+
<label class="form-check-label" for="lstrip_blocks">lstrip_blocks</label>
26+
<small id="lstripHelp" class="form-text text-muted">If this is set to True leading
27+
spaces and tabs are stripped from the start of a line to a block. Defaults to
28+
False.</small>
29+
</div>
30+
31+
<div class="form-check">
32+
<input type="checkbox" class="form-check-input" id="keep_trailing_newline"
33+
name="keep_trailing_newline">
34+
<label class="form-check-label"
35+
for="keep_trailing_newline">keep_trailing_newline</label>
36+
<small id="trailingHelp" class="form-text text-muted">Preserve the trailing newline
37+
when
38+
rendering templates. The default is False, which causes a single newline, if
39+
present, to be stripped from the end of the template.</small>
40+
</div>
41+
42+
<div class="form-group">
43+
<label for="newline_sequence">newline_sequence</label>
44+
<input type="text" class="form-control" id="newline_sequence"
45+
aria-describedby="newlineHelp" placeholder="\n" value="\n" name="newline_sequence">
46+
<small id="newlineHelp" class="form-text text-muted">The sequence that starts a
47+
newline.
48+
Must be one of '\r', '\n' or '\r\n'. The default is '\n' which is a useful
49+
default
50+
for Linux and OS X systems as well as web applications.</small>
51+
</div>
52+
53+
<div class="form-group">
54+
<label class="mr-sm-2" for="undefined">Extensions</label>
55+
<select class="custom-select" id="extensions" name="extensions" multiple>
56+
<option value="jinja2.ext.i18n">i18n</option>
57+
<option value="jinja2.ext.do">do</option>
58+
<option value="jinja2.ext.loopcontrols">loopcontrols</option>
59+
<option value="jinja2.ext.debug">debug</option>
60+
</select>
61+
<small id="extensionsHelp" class="form-text text-muted">List of Jinja extensions to
62+
use.
63+
This can either be import paths as strings or extension classes. For more
64+
information have a look at the extensions documentation.</small>
65+
</div>
66+
67+
<div class="form-group">
68+
<label class="mr-sm-2" for="undefined">Undefined</label>
69+
<select class="custom-select" id="undefined" name="undefined">
70+
<option value="jinja2.Undefined">Undefined</option>
71+
<option value="jinja2.ChainableUndefined">ChainableUndefined</option>
72+
<option value="jinja2.DebugUndefined">DebugUndefined</option>
73+
<option value="jinja2.StrictUndefined">StrictUndefined</option>
74+
</select>
75+
<small id="undefinedHelp" class="form-text text-muted">Undefined or a subclass of it
76+
that is used to represent undefined values in the template</small>
77+
</div>
78+
79+
<div class="form-group">
80+
<label class="mr-sm-2" for="filter">Filter</label>
81+
<select class="custom-select" id="filter" name="filter">
82+
<option value="default">Default (Built-in)</option>
83+
<option value="ansible">Ansible</option>
84+
<option value="salt">SaltStack</option>
85+
<option value="st2">StackStorm</option>
86+
</select>
87+
<small id="filterHelp" class="form-text text-muted">Filter imported from tools</small>
88+
</div>
89+
90+
</div>
91+
</p>
92+
</div>
93+
</div>
94+
</div>
95+
<div class="row">
96+
<div class="col-lg-4">
97+
<div class="form-group">
98+
<label for="textData">Data <small>YAML</small></label>
99+
<textarea class="form-control show-spaces" id="textData" name="data" rows="20"></textarea>
100+
</div>
101+
</div>
102+
<div class="col-lg-4">
103+
<div class="form-group">
104+
<label for="textTemplate">Template <small>jinja2</small></label>
105+
<textarea class="form-control show-spaces" id="textTemplate" name="template"
106+
rows="20"></textarea>
107+
</div>
108+
</div>
109+
<div class="col-lg-4">
110+
<div class="form-group">
111+
<label for="textRendered" disabled>Rendered <small>Text</small></label>
112+
<textarea class="form-control show-spaces" id="textRendered" rows="20" disabled></textarea>
113+
</div>
114+
</div>
115+
</div>
116+
<div class="row">
117+
<div class="col-auto">
118+
<div>
119+
<button class="btn btn-primary" type="submit">
120+
Render Template
121+
</button>
122+
</div>
123+
</div>
124+
<div class="col-auto mr-auto ">
125+
<div class="dropdown">
126+
<button id="examples" class="btn btn-primary dropdown-toggle" type="button"
127+
data-toggle="dropdown">Examples
128+
<span class="caret"></span></button>
129+
<ul class="dropdown-menu">
130+
</ul>
131+
</div>
132+
</div>
133+
</div>
134+
</div>
135+
</form>
136+
</div>

0 commit comments

Comments
 (0)