diff --git a/.envrc b/.envrc index 8eec315..e0a23b6 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,4 @@ #!/usr/bin/env bash +# this file is to be loaded with 'direnv' use nix export CARDS_ACCESS_TOKEN="hunter2" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..62fc43e --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +STYLES := $(patsubst templates/%/render.sh,%,$(wildcard templates/*/render.sh)) + +help: + @printf "make %s\n" \ + render-styles \ + $(patsubst %,render-style-%-stdout,$(STYLES)) \ + $(patsubst %,render-example-card-%-stdout,$(STYLES)) \ + $(patsubst %,render-style-%-live,$(STYLES)) \ + $(patsubst %,render-example-card-%-live,$(STYLES)) \ + $(patsubst %,render-style-%,$(STYLES)) \ + $(patsubst %,render-example-card-%,$(STYLES)) + +render-styles: $(patsubst %,render-style-%,$(STYLES)) + +render-style-%-stdout: templates/%/render.sh + ./"$<" | bat --language html --plain --paging never + +render-example-card-%-stdout: templates/%/example.sh + ./"$<" | bat --language html --plain --paging never + +render-style-%-live: + fd --type f . templates/$* | entr make render-style-$*-stdout + +render-example-card-%-live: + fd --type f . templates/$* | entr make render-example-card-$*-stdout + +render-style-%: + make --quiet render-style-$*-stdout > pvv/styles/$*.html + +render-example-card-%: + ./"$<" + diff --git a/pull.sh b/pull.sh index 06a4e5e..1879491 100755 --- a/pull.sh +++ b/pull.sh @@ -10,7 +10,7 @@ mkdir -p pvv/{cards,styles} ./api.py get-styles | hjson -c | jq '.[].id' --raw-output | while read style_id; do (set -x - ./api.py get-style $style_id > pvv/styles/$style_id.xml + ./api.py get-style $style_id > pvv/styles/$style_id.html ) & done diff --git a/shell.nix b/shell.nix index 508e29a..c52cf4e 100644 --- a/shell.nix +++ b/shell.nix @@ -5,6 +5,7 @@ pkgs.mkShell { hjson # to deal with broken json j2cli sass + libxslt python3Packages.rich python3Packages.httpx python3Packages.typer diff --git a/templates/6/example.sh b/templates/6/example.sh new file mode 100755 index 0000000..b39f760 --- /dev/null +++ b/templates/6/example.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" + +xsltproc \ +<(./render.sh) \ +test_card.xml diff --git a/templates/6/render.sh b/templates/6/render.sh new file mode 100755 index 0000000..e59c9f4 --- /dev/null +++ b/templates/6/render.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" + +css_data="$(sass --style expanded style.scss)" \ +jinja_data="$(cat style.html.j2)" \ +js_data="$(cat style.js)" \ +card_header="$(j2 templates/card_header.html.j2)" \ +j2 templates/style.xsl.j2 diff --git a/templates/6/style.html.j2 b/templates/6/style.html.j2 new file mode 100644 index 0000000..661ae65 --- /dev/null +++ b/templates/6/style.html.j2 @@ -0,0 +1,203 @@ +{% set xml_image_not_done = [1] %}{# why must nunjucks suck so much? #} + +{% macro figure_layer(figure) %} + {% set figure_style %}{% filter cull_whitespace %} + {% if figure.opacity!=1 %} + opacity: {{ figure.opacity }}; + {% endif %} + {% if figure.color!=1 %} + color: {{ figure.color }}; + {% endif %} + + transform: + {% if figure.offset and figure.offset|any %} + translate({{ figure.offset[0]*100 }}%, {{ figure.offset[1]*100 }}%) + {% endif %} + {% if figure.rotation %} + rotate({{ figure.rotation }}deg) + {% endif %} + {% if figure.flip_x %} + scaleX(-1) + {% endif %} + {% if figure.flip_y %} + scaleY(-1) + {% endif %} + {% if figure.scale and figure.scale!=1 %} + scale({{figure.scale | string | replace("[", "") | replace("]", "") }}) + {% endif %} + ; + {% endfilter %}{% endset %} + + {% if figure.source == "xml" %} + {% set figure_name = xml.image if xml.image | startswith("http") else xml.image | split(":") | tail | join(":") %} + {% set figure_source = "url" if xml.image | startswith("http") else xml.image | split(":") | first %} + {% if xml_image_not_done.pop() %}{% endif %} + {% else %} + {% set figure_name = figure.name %} + {% set figure_source = figure.source %} + {% endif %} + +
" + err + ""; +} +//console.log(rendered); +document.write(rendered); diff --git a/templates/6/style.scss b/templates/6/style.scss new file mode 100644 index 0000000..d2beeb9 --- /dev/null +++ b/templates/6/style.scss @@ -0,0 +1,197 @@ +.fjomp_card { + --figure-size: 0.9in; + --figure-size: 1.35in; + --figure-size: 1.5in; + --color-border: MidnightBlue; + --color-bg-figure: white; + + --color-bg: PaleTurquoise; // PaleTurquoise; + --color-bg-body: LightCyan; // PaleTurquoise; + --color-bg-frame: PaleTurquoise; // LightSkyBlue; + --color-bg-costbar: SandyBrown; // DarkOrange; + + --color-text-title: MidnightBlue; + --color-text-body: black; + --color-text-costbar: white; + --color-shadow-costbar: 0.08em 0 0.05em Maroon, + -0.08em 0 0.05em Maroon, + 0 0.08em 0.05em Maroon, + 0 -0.08em 0.05em Maroon; + --figure-color: #555; + + width: 2.5in; + height: 3.5in; + box-sizing: border-box; + border-radius: 0mm; + border-width: 0.3mm; + border-color: var(--color-border); + + border-style: solid; + background-color: var(--color-bg); + overflow: hidden; + + font-size: 2.5mm; + font-family: sans-serif; + + display: grid; + grid-template-columns: auto 1fr; + grid-template-rows: 1.9em var(--figure-size) 2.3em auto; + grid-template-areas: + "symbol title" + "figure figure" + "costbar costbar" + "description description"; + + header { + font-family: montserrat, sans-serif; + font-style: normal; + font-weight: 200; + + grid-area: title; + font-size: 1.8em; + line-height: 1em; + margin-left: -1em; + border-radius: 1mm 1mm 0 0; + text-align: center; + background-color: var(--color-bg-frame); + border-radius: 0; + color: var(--color-text-title); + } + .symbol { + grid-area: symbol; + text-align: center; + background-color: var(--color-bg-frame); + color: var(--color-text-title); + padding-top: 0.6mm; + padding-left: 0.8mm; + white-space: nowrap; + } + figure { + grid-area: figure; + background-color: var(--color-bg-figure); + overflow: hidden; + position: relative; + border-radius: 0; + margin: 0; + + .layer { + color: var(--figure-color); + position: absolute; + top:0;right:0;left:0;bottom:0; + height: var(--figure-size); + width: var(--figure-size); + margin: auto; + text-align: center; + >* { + width: 100%; + height: 100%; + } + img { + width: calc(var(--figure-size)); + height: calc(var(--figure-size)); + object-fit: contain; + } + img.colored { + transform: translateY(-10000px); + filter: drop-shadow(0px 10000px var(--figure-color)); + } + .mdi, + .fa, + .oi, + .material-icons.figure { + font-size: calc(var(--figure-size) * 0.9); + line-height: var(--figure-size); + } + .lnr { + font-size: calc(var(--figure-size) * 0.8); + line-height: calc(var(--figure-size) * 0.95); + } + } + } + .playcosts { + grid-area: playcosts; + border-left: solid 0.3mm #ccc; + background-color: var(--color-bg-frame); + color: #444 ; + padding: 0.5mm; + ul { + margin:0; + list-style-type: none; + padding: 0; + + li { + + } + } + } + .costbar { + grid-area: costbar; + border-radius: 0; + background-color: var(--color-bg-costbar); + color: var(--color-text-costbar); + text-shadow: var(--color-shadow-costbar); + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-items: center; + justify-content: center; + text-align: center; + + font-size: 1.1em; + + section{ + font-size: 0.8em; + margin-left: 0.8mm; + margin-right: 0.8mm; + line-height: 0.9em; + } + } + .description { + grid-area: description; + margin: 1mm; + border-radius: 1mm; + background-color: var(--color-bg-body); + color: var(--color-text-body); + font-size: 0.9em; + position: relative; + + .markdown { + text-align: center; + + table { + margin-top:-0.3em; + margin-left:auto; + margin-right:auto; + th, td { + font-size: 2.5mm; /* user agent style override */ + } + } + p + table { + margin-top:-1em; + } + li { + text-align: left; + } + } + + ul, ol { + padding-left: 1.5em; + li { + + } + } + .bottom { + position: absolute; + bottom:0; + left:0; + right:0; + } + } +} + + +.fjomp_card.item, +.fjomp_card.figure, +.fjomp_card.repertoire { + --figure-size: 2.4in; +} diff --git a/templates/6/templates/all.html.j2 b/templates/6/templates/all.html.j2 new file mode 100644 index 0000000..4a2a76f --- /dev/null +++ b/templates/6/templates/all.html.j2 @@ -0,0 +1,49 @@ + + +