diff --git a/Makefile b/Makefile
index 70f5bbc..bfb8a0a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,9 @@
-all: build/card.html build/card_rendered.html
+CARDS := $(wildcard cards/*.yaml)
+CARDS_DESTS := $(patsubst cards/%.yaml,cards/build/%.html,$(CARDS))
+
+.PHONY: all
+all: build/test_card.html build/test_card_rendered.html $(CARDS_DESTS)
.PHONY: dev
dev:
@@ -7,37 +11,45 @@ dev:
.PHONY: clean
clean:
- rm build/*
+ rm build/* cards/build/*
-build/card.html: build/card.xml build/style.xsl
+build/test_card.html: build/card.xml build/style.xsl
xsltproc \
- -o build/card.html \
+ -o build/test_card.html \
build/style.xsl \
build/card.xml
-define PYTHON_MAKE_RENDERED_CARD
+define PYTHON_MAKE_JINJA2_RENDERED_CARD
from jinja2 import Environment, FileSystemLoader
from markdown import markdown
-import yaml
-with open("card.yaml") as f: data = f.read()
-with open("build/card_rendered.html", "w") as f:
+import yaml, sys
+with open("build/style.css") as f: css_data = f.read()
+with open(sys.argv[1]) as f: data = f.read()
+with open(sys.argv[2], "w") as f:
e = Environment(trim_blocks=True, lstrip_blocks=True, loader=FileSystemLoader(''))
+ css_data
+ header = e.get_template("templates/card_header.html.j2").render(css_data=css_data)
e.filters.update({
"markdown":markdown,
"any":any,
"all":all,
"cull_whitespace":(lambda x: " ".join(x.split())) })
- f.write(e.get_template('style.html.j2').render(card=yaml.load(data)))
+ f.write(header + "\n" + e.get_template('style.html.j2').render(card=yaml.load(data)))
endef
-export PYTHON_MAKE_RENDERED_CARD
-build/card_rendered.html: card.yaml style.html.j2
- python3 -c "$$PYTHON_MAKE_RENDERED_CARD"
+
+export PYTHON_MAKE_JINJA2_RENDERED_CARD
+build/test_card_rendered.html: test_card.yaml style.html.j2
+ python3 -c "$$PYTHON_MAKE_JINJA2_RENDERED_CARD" "test_card.yaml" "build/test_card_rendered.html"
+
+export PYTHON_MAKE_JINJA2_RENDERED_CARD
+cards/build/%.html: cards/%.yaml style.html.j2
+ python3 -c "$$PYTHON_MAKE_JINJA2_RENDERED_CARD" $< $@
define PYTHON_MAKE_CARD_XML
from jinja2 import Environment, FileSystemLoader
-with open("card.yaml") as f: data = f.read()
+with open("test_card.yaml") as f: data = f.read()
with open("build/card.xml", "w") as f:
f.write(Environment(
loader=FileSystemLoader('templates'))
@@ -45,7 +57,7 @@ with open("build/card.xml", "w") as f:
.render(data=data))
endef
export PYTHON_MAKE_CARD_XML
-build/card.xml: card.yaml templates/card.xml.j2
+build/card.xml: test_card.yaml templates/card.xml.j2
python3 -c "$$PYTHON_MAKE_CARD_XML"
@@ -54,16 +66,18 @@ from jinja2 import Environment, FileSystemLoader
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()
+env = Environment(
+ trim_blocks=True,
+ lstrip_blocks=True,
+ loader=FileSystemLoader('templates'))
+card_header = env.get_template('card_header.html.j2').render()
with open("build/style.xsl", "w") as f:
- f.write(Environment(
- trim_blocks=True,
- lstrip_blocks=True,
- loader=FileSystemLoader('templates'))
- .get_template('style.xsl.j2')
- .render( css_data=css_data, jinja_data=jinja_data, js_data=js_data))
+ 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))
endef
export PYTHON_MAKE_STYLE_XSL
-build/style.xsl: build/style.css templates/style.xsl.j2 style.html.j2 style.js
+build/style.xsl: build/style.css templates/style.xsl.j2 templates/card_header.html.j2 style.html.j2 style.js
python3 -c "$$PYTHON_MAKE_STYLE_XSL"
diff --git a/cards/build/.gitkeep b/cards/build/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/old/card_header.html.j2 b/old/card_header.html.j2
deleted file mode 100644
index 7e5f9b6..0000000
--- a/old/card_header.html.j2
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-{% macro async() -%}
-media="none" onload="if(media!='all')media='all'"
-{%- endmacro -%}
-
-
-
-
-
diff --git a/style.html.j2 b/style.html.j2
index d10c54f..7af6d1e 100644
--- a/style.html.j2
+++ b/style.html.j2
@@ -29,14 +29,14 @@
{% elif figure.type == "svg" %}
{# /cards/svg #}
- {% if figure.color != false %}
- {% if figure.color %}
-
+ {% if figure.color %}
+ {% if figure.color == true %}
+
{% else %}
-
+
{% endif %}
{% else %}
-
+
{% endif %}
{% elif figure.type == "img" %}
{# /cards/img #}
diff --git a/templates/card_header.html.j2 b/templates/card_header.html.j2
new file mode 100644
index 0000000..e3e524a
--- /dev/null
+++ b/templates/card_header.html.j2
@@ -0,0 +1,19 @@
+{% set async = "media=\"none\" onload=\"if(media!='all')media='all'\"" -%}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% if css_data %}
+
+{% endif %}
diff --git a/templates/style.xsl.j2 b/templates/style.xsl.j2
index d88dfb2..ae4c90a 100644
--- a/templates/style.xsl.j2
+++ b/templates/style.xsl.j2
@@ -2,27 +2,18 @@
{% set newline = "\n" %}
-{% set async = "media=\"none\" onload=\"if(media!='all')media='all'\"" %}
{% filter replace(">", ">foobarhuehuehue")
| replace("<", "<")
| replace(">foobarhuehuehue", ">")
- | replace("\n", newline) %}
+ | replace("\n", newline)
+ | replace("", "") %}
-
-
-
-
-
-
-
-
-
-
+{{ card_header }}
Status Card
diff --git a/card.yaml b/test_card.yaml
similarity index 96%
rename from card.yaml
rename to test_card.yaml
index e12a4d7..37038eb 100644
--- a/card.yaml
+++ b/test_card.yaml
@@ -18,7 +18,7 @@ notes: ''
figures:
- name: batman
type: svg
- color: false
+ color: true
scale: 0.8
flip_x: false
flip_y: false