fuck my ass i hate nunjucks

This commit is contained in:
Peder Bergebakken Sundt 2019-10-20 03:25:33 +02:00
parent 8de13889d3
commit 9161623fe9
3 changed files with 80 additions and 48 deletions

View File

@ -1,3 +1,5 @@
{% set xml_image_note_done = [1] %}{# why must nunjucks suck so much? #}
{% macro figure_layer(figure) %} {% macro figure_layer(figure) %}
{% set figure_style %}{% filter cull_whitespace %} {% set figure_style %}{% filter cull_whitespace %}
{% if figure.opacity!=1 %} {% if figure.opacity!=1 %}
@ -26,42 +28,51 @@
; ;
{% endfilter %}{% endset %} {% 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_note_done.clear() %}{% endif %}
{% else %}
{% set figure_name = figure.name %}
{% set figure_source = figure.source %}
{% endif %}
<div class="layer" style="{{ figure_style }}"> <div class="layer" style="{{ figure_style }}">
{% if figure.source == "material-icons" %} {% if figure_source == "material-icons" %}
{# https://material.io/icons/ #} {# https://material.io/icons/ #}
<i class="material-icons figure">{{ figure.name }}</i> <i class="material-icons figure">{{ figure_name }}</i>
{% elif figure.source == "mdi" %} {% elif figure_source == "mdi" %}
{# https://materialdesignicons.com/ #} {# https://materialdesignicons.com/ #}
<i class="mdi mdi-{{ figure.name }}"></i> <i class="mdi mdi-{{ figure_name }}"></i>
{% elif figure.source == "fa" %} {% elif figure_source == "fa" %}
{# http://fontawesome.io/icons/ #} {# http://fontawesome.io/icons/ #}
<i class="fa fa-{{ figure.name }}"></i> <i class="fa fa-{{ figure_name }}"></i>
{% elif figure.source == "lnr" %} {% elif figure_source == "lnr" %}
{# https://linearicons.com/free #} {# https://linearicons.com/free #}
<span class="lnr lnr-{{ figure.name }}"></span> <span class="lnr lnr-{{ figure_name }}"></span>
{% elif figure.source == "oi" %} {% elif figure_source == "oi" %}
{# https://useiconic.com/open #} {# https://useiconic.com/open #}
<span class="oi" data-glyph="{{ figure.name }}"></span> <span class="oi" data-glyph="{{ figure_name }}"></span>
{% elif figure.source == "svg" %} {% elif figure_source == "svg" %}
{# pvv.ntnu.no/~pederbs/cards/svg #} {# pvv.ntnu.no/~pederbs/cards/svg #}
{% if figure.color == true %} {% if figure.color == true %}
<img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure.name }}"> <img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure_name }}">
{% elif figure.color %} {% elif figure.color %}
<img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure.name }}" class="colored" style="--figure-color: {{ figure.color }}"> <img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure_name }}" class="colored" style="--figure-color: {{ figure.color }}">
{% else %} {% else %}
<img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure.name }}" class="colored"> <img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure_name }}" class="colored">
{% endif %} {% endif %}
{% elif figure.source in ["img", "emoji"] %} {% elif figure_source in ["img", "emoji"] %}
{# pvv.ntnu.no/~pederbs/cards/img #} {# pvv.ntnu.no/~pederbs/cards/img #}
{# /cards/emoji #} {# /cards/emoji #}
{% if figure.color == true %} {% if figure.color == true %}
<img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure.source }}/data/{{ figure.name }}" class="colored"> <img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure_source }}/data/{{ figure_name }}" class="colored">
{% elif figure.color %} {% elif figure.color %}
<img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure.source }}/data/{{ figure.name }}" class="colored" style="--figure-color: {{ figure.color }}"> <img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure_source }}/data/{{ figure_name }}" class="colored" style="--figure-color: {{ figure.color }}">
{% else %} {% else %}
<img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure.source }}/data/{{ figure.name }}"> <img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure_source }}/data/{{ figure_name }}">
{% endif %} {% endif %}
{% elif figure.source == "url" %} {% elif figure_source == "url" %}
{% if figure.color == true %} {% if figure.color == true %}
<img src="{{ figure.name }}" class="colored"> <img src="{{ figure.name }}" class="colored">
{% elif figure.color %} {% elif figure.color %}
@ -87,7 +98,7 @@
{% for figure in yaml.figures or [] %} {% for figure in yaml.figures or [] %}
{{ figure_layer(figure) }} {{ figure_layer(figure) }}
{% endfor %} {% endfor %}
{% if xml.image %} {% if xml.image and xml_image_note_done %}
{{ figure_layer({ {{ figure_layer({
'name': xml.image if xml.image | startswith("http") else xml.image | split(":") | tail | join(":"), 'name': xml.image if xml.image | startswith("http") else xml.image | split(":") | tail | join(":"),
'source': "url" if xml.image | startswith("http") else xml.image | split(":") | first 'source': "url" if xml.image | startswith("http") else xml.image | split(":") | first
@ -95,20 +106,6 @@
{% endif %} {% endif %}
</figure> </figure>
<div class="costbar"> <div class="costbar">
{% for label, data in [
["Difficulty", xml.difficulty or yaml.difficulty],
["Power", xml.power or yaml.power],
["Range", xml.range or yaml.range],
["Duration", xml.duration or yaml.duration],
["CP", xml.cp or yaml.cp]
] %}
{% if data %}
<section>
<big>{{ data }}</big><br>
<small>{{ label }}</small>
</section>
{% endif %}
{% endfor %}
{% for playcosts in [xml.playcost, yaml.playcost] %} {% for playcosts in [xml.playcost, yaml.playcost] %}
{% if playcosts %} {% if playcosts %}
{% for playcost in (playcosts.split(",") if playcosts | is_string else playcosts ) %} {% for playcost in (playcosts.split(",") if playcosts | is_string else playcosts ) %}
@ -117,18 +114,48 @@
<big>{{ playcost | trim | split(" ") | first }}</big><br> <big>{{ playcost | trim | split(" ") | first }}</big><br>
<small>{{ playcost | trim | split(" ") | tail | join(" ") }}</small> <small>{{ playcost | trim | split(" ") | tail | join(" ") }}</small>
</section> </section>
{% elif playcost | trim | split(" ") | length == 1 %}
<section>
<big>{{ 1 }}</big><br>
<small>{{ playcost }}</small>
</section>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for label, data in [
["Artistic Value", xml.artistic_value],
["Difficulty", xml.difficulty or yaml.difficulty],
["Power", xml.power or yaml.power],
["Range", xml.range or yaml.range],
["Duration", xml.duration or yaml.duration],
["CP", xml.cp or yaml.cp]
] %}
{% if data %}
<section>
<big>
{% for part in data | split("+") %}
{% if "death" not in part %}
{{"+" if not loop.first }}
{{ part }}
{% endif %}
{% endfor %}
</big><br>
{# <big>{{ data }}</big><br> #}
<small>{{ label }}</small>
</section>
{% endif %}
{% endfor %}
</div> </div>
<div class="description"> <div class="description">
<ul> <ul>
{% for playcosts in [xml.playcost, yaml.playcost] %} {% for playcosts in [xml.playcost, yaml.playcost] %}
{% if playcosts %} {% if playcosts %}
{% for playcost in (playcosts.split(",") if playcosts | is_string else playcosts ) %} {% for playcost in (playcosts.split(",") if playcosts | is_string else playcosts ) %}
{% if not playcost | trim | split(" ") | first | is_number %} {% if playcost | trim | split(" ") | first | is_number %}
<li>{{ playcost | trim }}</li> {% elif playcost | trim | split(" ") | length == 1 %}
{% else %}
<li>{{ playcost }}</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@ -157,6 +184,7 @@
</div> </div>
{# {#
{% for item in xml.components %} {% for item in xml.components %}
{{item["@x"]}}, {{item["@x"]}},
{{item["@y"]}}, {{item["@y"]}},

View File

@ -17,7 +17,7 @@
display: grid; display: grid;
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;
grid-template-rows: 1.9em var(--figure-size) 2.1em auto; grid-template-rows: 1.9em var(--figure-size) 2.3em auto;
grid-template-areas: grid-template-areas:
"symbol title" "symbol title"
"figure figure" "figure figure"
@ -98,7 +98,9 @@
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
li {} li {
}
} }
} }
.costbar { .costbar {
@ -113,6 +115,8 @@
justify-content: center; justify-content: center;
text-align: center; text-align: center;
font-size: 1.1em;
section{ section{
font-size: 0.8em; font-size: 0.8em;
margin-left: 0.5mm; margin-left: 0.5mm;
@ -125,6 +129,7 @@
margin: 1mm; margin: 1mm;
border-radius: 1mm; border-radius: 1mm;
background-color: #ddd; background-color: #ddd;
font-size: 0.9em;
ul, ol { ul, ol {
padding-left: 1.5em; padding-left: 1.5em;
@ -136,8 +141,7 @@
} }
.fjomp_card.item { .fjomp_card.figure,
.playcosts { .fjomp_card.repertoire {
display: none; --figure-size: 2.4in;
}
} }

View File

@ -5,13 +5,13 @@ tags:
playcost: playcost:
- 'Element: fire' - 'Element: fire'
- BODY+5 POWER - BODY+5 POWER
flavor: Enemies sure are squishy #flavor: Enemies sure are squishy
description: Perform an attack description: Perform an attack
steps: #steps:
- Do A #- Do A
- Do A #- Do A
- Do A #- Do A
- Then B #- Then B
figures: figures:
- name: piuy/chicken - name: piuy/chicken
source: img source: img