This commit is contained in:
Peder Bergebakken Sundt 2019-09-09 19:29:27 +02:00
parent 295c59689e
commit 9545b2a205
4 changed files with 25 additions and 9 deletions

View File

@ -3,7 +3,8 @@ all: build/card.html
.PHONY: dev
dev:
git ls-files | entr make all
git ls-files | entr bash -c "make all"
.PHONY: clean
clean:
rm build/*
@ -32,17 +33,18 @@ build/card.xml: card.yaml
define PYTHON_MAKE_STYLE_XSL
from jinja2 import Environment, FileSystemLoader
with open("style.css") as f: css_data = f.read()
with open("style.css") as f: css_data = f.read()
with open("style.html.j2") as f: jinja_data = f.read()
with open("style.js") as f: js_data = f.read()
out = (Environment(
loader=FileSystemLoader('templates'))
.get_template('style.xsl.j2')
.render( css_data=css_data, jinja_data=jinja_data))
.render( css_data=css_data, jinja_data=jinja_data, js_data=js_data))
#print(out)
with open("build/card.xml", "w") as f:
with open("build/style.xsl", "w") as f:
f.write(out)
endef
export PYTHON_MAKE_STYLE_XSL
build/style.xsl: style.css style.html.j2
build/style.xsl: style.css templates/style.xsl.j2 style.html.j2 style.js
python -c "$$PYTHON_MAKE_STYLE_XSL"

View File

@ -1,5 +1,9 @@
spis meg
<div class="">
</div>

6
style.js Normal file
View File

@ -0,0 +1,6 @@
template = new plate.Template(jinja_template)
template.render({world: 'everyone'}, function(err, data) {
document.write(data);
})

View File

@ -1,16 +1,17 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:output method="html" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/*">
<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;
</xsl:text>
<script src="https://raw.githubusercontent.com/nodeca/js-yaml/master/dist/js-yaml.min.js"></script>
<script src="http://mozilla.github.io/nunjucks/files/nunjucks.min.js"></script>
<script src="https://raw.githubusercontent.com/chrisdickinson/plate/master/dist/plate.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"/>
<title>Status Card</title>
<style type="text/css">
{{ css }}
{{ css_data }}
</style>
<script type="text/html" id="yaml_data">
@ -19,7 +20,10 @@ xsl
<script type="text/javascript">
var jinja_template = {{ jinja_data | tojson }};
// render this shit
</script>
<script type="text/javascript">
{{ js_data }}
</script>
</xsl:template>