asdasasd
This commit is contained in:
parent
0c2346bf59
commit
c16742291c
25
Makefile
25
Makefile
@ -3,7 +3,7 @@ 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)
|
||||
all: build/test_card.html build/test_card_rendered.html $(CARDS_DESTS) cards/build/all.html
|
||||
|
||||
.PHONY: dev
|
||||
dev:
|
||||
@ -23,29 +23,38 @@ build/test_card.html: build/card.xml build/style.xsl
|
||||
define PYTHON_MAKE_JINJA2_RENDERED_CARD
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from markdown import markdown
|
||||
import yaml, sys
|
||||
import yaml, sys, glob
|
||||
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)
|
||||
f.write(e.get_template("templates/card_header.html.j2").render(is_local=True, css_data=css_data))
|
||||
e.filters.update({
|
||||
"markdown":markdown,
|
||||
"any":any,
|
||||
"all":all,
|
||||
"cull_whitespace":(lambda x: " ".join(x.split())) })
|
||||
f.write(header + "\n" + e.get_template('style.html.j2').render(card=yaml.load(data)))
|
||||
for filename in ([sys.argv[1]] if sys.argv[1] != "ALL" else glob.glob("cards/*.yaml")):
|
||||
if sys.argv[1] == "ALL": f.write(f"\n\n<h1>{filename}</h1>\n")
|
||||
with open(filename) as f2: data = f2.read()
|
||||
try:
|
||||
data = e.get_template('style.html.j2').render(card=yaml.load(data))
|
||||
except Exception as ex:
|
||||
data = f"<pre style=\"color:red;\">{ex}</pre>"
|
||||
f.write("\n" + data)
|
||||
endef
|
||||
|
||||
export PYTHON_MAKE_JINJA2_RENDERED_CARD
|
||||
build/test_card_rendered.html: test_card.yaml style.html.j2
|
||||
build/test_card_rendered.html: test_card.yaml style.html.j2 templates/card_header.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
|
||||
cards/build/%.html: cards/%.yaml style.html.j2 templates/card_header.html.j2
|
||||
python3 -c "$$PYTHON_MAKE_JINJA2_RENDERED_CARD" $< $@
|
||||
|
||||
export PYTHON_MAKE_JINJA2_RENDERED_CARD
|
||||
cards/build/all.html: $(CARDS) style.html.j2 templates/card_header.html.j2
|
||||
python3 -c "$$PYTHON_MAKE_JINJA2_RENDERED_CARD" ALL $@
|
||||
|
||||
|
||||
define PYTHON_MAKE_CARD_XML
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
6
sync.py
6
sync.py
@ -74,10 +74,10 @@ def pull_all():
|
||||
f.write(yaml_data + "\n")
|
||||
print(f"./cards/{card_id}.yaml written!")
|
||||
continue
|
||||
|
||||
with open(f"cards/{card_id}.xml", "w") as f:
|
||||
ftype = "xml" if data.strip() else "yaml"
|
||||
with open(f"cards/{card_id}.{ftype}", "w") as f:
|
||||
f.write(data + "\n")
|
||||
print(f"./cards/{card_id}.xml written!")
|
||||
print(f"./cards/{card_id}.{ftype} written!")
|
||||
|
||||
def push_all():
|
||||
existing_card_ids = get_card_ids()
|
||||
|
@ -1,5 +1,10 @@
|
||||
{% set async = "media=\"none\" onload=\"if(media!='all')media='all'\"" -%}
|
||||
|
||||
{% if is_local %}
|
||||
<script type="text/javascript" src="http://livejs.com/live.js"></script>
|
||||
{#<meta http-equiv="refresh" content="3">#}
|
||||
{% endif %}
|
||||
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js"></script>
|
||||
<script type="text/javascript" src="https://mozilla.github.io/nunjucks/files/nunjucks.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/9.1.0/markdown-it.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user