2020-03-07 01:27:25 +01:00
|
|
|
CARDS := $(wildcard cards/*.xml)
|
|
|
|
CARDS_DESTS := $(patsubst cards/%.xml,cards/build/%.html,$(CARDS))
|
2019-09-18 22:46:23 +02:00
|
|
|
|
2019-10-14 21:40:50 +02:00
|
|
|
.PHONY: style
|
2020-03-07 01:27:25 +01:00
|
|
|
style: build/test_card.html
|
2019-10-06 22:13:01 +02:00
|
|
|
|
|
|
|
.PHONY: cards
|
2020-03-07 01:27:25 +01:00
|
|
|
cards: cards/build/all.html
|
2019-10-06 21:43:37 +02:00
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
.PHONY: dev
|
|
|
|
dev:
|
2019-10-14 21:40:50 +02:00
|
|
|
git ls-files | entr bash -c "make style"
|
2019-10-06 21:43:37 +02:00
|
|
|
|
2019-10-15 21:20:37 +02:00
|
|
|
.PHONY: dev_cards
|
2019-10-06 22:13:01 +02:00
|
|
|
dev_cards:
|
|
|
|
git ls-files | entr bash -c "make cards"
|
2019-09-09 19:29:27 +02:00
|
|
|
|
2019-09-09 19:07:05 +02:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2019-10-06 21:43:37 +02:00
|
|
|
rm -v build/* cards/build/*
|
2019-09-09 19:07:05 +02:00
|
|
|
|
2020-03-07 01:27:25 +01:00
|
|
|
|
|
|
|
build/test_card.html: test_card.xml build/style.xsl build
|
2019-09-08 23:07:26 +02:00
|
|
|
xsltproc \
|
2019-09-18 22:46:23 +02:00
|
|
|
-o build/test_card.html \
|
2019-09-09 19:07:05 +02:00
|
|
|
build/style.xsl \
|
2020-03-07 01:27:25 +01:00
|
|
|
test_card.xml
|
2019-09-08 23:07:26 +02:00
|
|
|
|
2019-09-11 05:09:42 +02:00
|
|
|
|
2020-03-07 01:27:25 +01:00
|
|
|
cards/build/%.html: cards/%.xml build/style.xsl cards/build
|
|
|
|
xsltproc -o $@ build/style.xsl $<
|
2019-09-18 22:46:23 +02:00
|
|
|
|
2019-09-11 05:09:42 +02:00
|
|
|
|
2020-03-07 01:27:25 +01:00
|
|
|
define PYTHON_MAKE_IFRAME_HELL
|
2019-09-08 23:07:26 +02:00
|
|
|
from jinja2 import Environment, FileSystemLoader
|
2020-03-07 01:27:25 +01:00
|
|
|
import sys, os
|
|
|
|
env = Environment(
|
|
|
|
trim_blocks = True,
|
|
|
|
lstrip_blocks = True,
|
|
|
|
loader = FileSystemLoader('templates'))
|
|
|
|
with open("cards/build/all.html", "w") as f:
|
|
|
|
f.write(env.get_template('all.html.j2').render(cards=map(os.path.basename, sys.argv[1:])))
|
2019-09-09 19:07:05 +02:00
|
|
|
endef
|
2020-03-07 01:27:25 +01:00
|
|
|
export PYTHON_MAKE_IFRAME_HELL
|
|
|
|
cards/build/all.html: $(CARDS_DESTS) templates/all.html.j2
|
|
|
|
python3 -c "$$PYTHON_MAKE_IFRAME_HELL" $(CARDS_DESTS)
|
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-18 22:46:23 +02:00
|
|
|
env = Environment(
|
2020-03-07 01:27:25 +01:00
|
|
|
trim_blocks = True,
|
|
|
|
lstrip_blocks = True,
|
|
|
|
loader = FileSystemLoader('templates'))
|
2019-09-18 22:46:23 +02:00
|
|
|
card_header = env.get_template('card_header.html.j2').render()
|
2019-09-09 19:29:27 +02:00
|
|
|
with open("build/style.xsl", "w") as f:
|
2019-09-18 22:46:23 +02:00
|
|
|
f.write(
|
|
|
|
env.get_template('style.xsl.j2')
|
|
|
|
.render( css_data=css_data, jinja_data=jinja_data, js_data=js_data, card_header=card_header))
|
2019-09-08 23:07:26 +02:00
|
|
|
endef
|
2019-09-09 19:07:05 +02:00
|
|
|
export PYTHON_MAKE_STYLE_XSL
|
2020-03-07 01:27:25 +01:00
|
|
|
build/style.xsl: build/style.css templates/style.xsl.j2 templates/card_header.html.j2 style.html.j2 style.js build
|
2019-09-09 23:02:17 +02:00
|
|
|
python3 -c "$$PYTHON_MAKE_STYLE_XSL"
|
|
|
|
|
|
|
|
|
|
|
|
define PYTHON_MAKE_SASS
|
2020-03-07 01:27:25 +01:00
|
|
|
import sass # libsass
|
2019-09-09 23:02:17 +02:00
|
|
|
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
|
2020-03-07 01:27:25 +01:00
|
|
|
build/style.css: style.scss build
|
2019-09-09 23:02:17 +02:00
|
|
|
python3 -c "$$PYTHON_MAKE_SASS"
|
2020-03-07 01:27:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
mkdir -p build
|
|
|
|
|
|
|
|
|
|
|
|
cards/build:
|
|
|
|
mkdir -p cards/build
|