2019-09-08 23:07:26 +02:00
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
all: build/card.html
|
2019-09-08 23:07:26 +02:00
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
.PHONY: dev
|
|
|
|
dev:
|
2019-09-09 19:29:27 +02:00
|
|
|
git ls-files | entr bash -c "make all"
|
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm build/*
|
|
|
|
|
|
|
|
build/card.html: build/card.xml build/style.xsl
|
2019-09-08 23:07:26 +02:00
|
|
|
xsltproc \
|
2019-09-09 19:07:05 +02:00
|
|
|
-o build/card.html \
|
|
|
|
build/style.xsl \
|
2019-09-09 18:48:15 +02:00
|
|
|
build/card.xml
|
2019-09-08 23:07:26 +02:00
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
define PYTHON_MAKE_CARD_XML
|
2019-09-08 23:07:26 +02:00
|
|
|
from jinja2 import Environment, FileSystemLoader
|
2019-09-09 19:07:05 +02:00
|
|
|
with open("card.yaml") as f: data = f.read()
|
|
|
|
with open("build/card.xml", "w") as f:
|
2019-09-09 23:02:17 +02:00
|
|
|
f.write(Environment(
|
|
|
|
loader=FileSystemLoader('templates'))
|
|
|
|
.get_template('card.xml.j2')
|
|
|
|
.render(data=data))
|
2019-09-09 19:07:05 +02:00
|
|
|
endef
|
2019-09-08 23:07:26 +02:00
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
export PYTHON_MAKE_CARD_XML
|
2019-09-10 17:54:18 +02:00
|
|
|
build/card.xml: card.yaml templates/card.xml.j2
|
2019-09-09 23:02:17 +02:00
|
|
|
python3 -c "$$PYTHON_MAKE_CARD_XML"
|
2019-09-08 23:07:26 +02:00
|
|
|
|
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
define PYTHON_MAKE_STYLE_XSL
|
|
|
|
from jinja2 import Environment, FileSystemLoader
|
2019-09-09 23:02:17 +02:00
|
|
|
with open("build/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()
|
2019-09-09 19:29:27 +02:00
|
|
|
with open("build/style.xsl", "w") as f:
|
2019-09-09 23:02:17 +02:00
|
|
|
f.write(Environment(
|
2019-09-10 17:54:18 +02:00
|
|
|
trim_blocks=True,
|
|
|
|
lstrip_blocks=True,
|
2019-09-09 23:02:17 +02:00
|
|
|
loader=FileSystemLoader('templates'))
|
|
|
|
.get_template('style.xsl.j2')
|
|
|
|
.render( css_data=css_data, jinja_data=jinja_data, js_data=js_data))
|
2019-09-08 23:07:26 +02:00
|
|
|
endef
|
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
export PYTHON_MAKE_STYLE_XSL
|
2019-09-09 23:02:17 +02:00
|
|
|
build/style.xsl: build/style.css templates/style.xsl.j2 style.html.j2 style.js
|
|
|
|
python3 -c "$$PYTHON_MAKE_STYLE_XSL"
|
|
|
|
|
|
|
|
|
|
|
|
define PYTHON_MAKE_SASS
|
|
|
|
import sass
|
|
|
|
with open("style.scss") as f:
|
|
|
|
with open("build/style.css", "w") as of:
|
|
|
|
of.write(sass.compile(string=f.read(), output_style="expanded"))
|
|
|
|
endef
|
|
|
|
|
|
|
|
export PYTHON_MAKE_SASS
|
|
|
|
build/style.css: style.scss
|
|
|
|
python3 -c "$$PYTHON_MAKE_SASS"
|