blob: 8143cffaf4f2a38415999c5be665392c2a1b8c13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
{%- set ROW_HEIGHT = 24 -%}
{%- set ROW_MARGIN = 2 -%}
{%- set FONT_SIZE_PERCENT = 75 -%}
{%- set FONT_SIZE = (ROW_HEIGHT - ROW_MARGIN) * FONT_SIZE_PERCENT / 100 -%}
{%- set ROWS = 1 + versions|length -%}
{%- set OUTER_MARGIN = 5 -%}
{%- set FONT_WIDENESS = 0.5 -%}
{%- set LONGEST_REPO = versions.keys()|map('length')|max -%}
{%- set LONGEST_VERSION = versions.values()|map('string')|map('length')|max -%}
{%- set VERSION_X = OUTER_MARGIN + LONGEST_REPO * FONT_WIDENESS * FONT_SIZE -%}
{%- set VERSION_WIDTH = OUTER_MARGIN + LONGEST_VERSION * FONT_WIDENESS * FONT_SIZE -%}
{%- set WIDTH = VERSION_X + VERSION_WIDTH -%}
{%- set ns = namespace(y = 0) -%}
{%- macro y(offset=0) -%}{{ ns.y + offset }}{%- endmacro -%}
{%- macro texty() -%}{{ y(FONT_SIZE) }}{%- endmacro -%}
{%- macro end_row() -%}{%- set ns.y = ns.y + ROW_HEIGHT %}{%- endmacro -%}
<?xml version="1.0" encoding="utf-8" ?>
<svg width="{{ WIDTH }}" height="{{ ROWS * ROW_HEIGHT }}" xmlns="http://www.w3.org/2000/svg" fill="white" font-size="{{ FONT_SIZE }}">
<rect x="0" y="0" width="100%" height="100%" fill="black"></rect>
<text x="5" y="{{ texty() }}" fill="white">Packaging Status</text>
<line x1="0" y1="{{ y(ROW_HEIGHT - ROW_MARGIN / 2) }}" x2="{{ WIDTH }}" y2="{{ y(ROW_HEIGHT - ROW_MARGIN / 2) }}"
stroke="white" stroke-width="{{ ROW_MARGIN }}"></line>{{ end_row() }}
{% for repo, version in versions.items() %}
<text x="{{ OUTER_MARGIN }}" y="{{ texty() }}">{{ repo }}</text>
<rect x="{{ VERSION_X }}" y="{{ y() }}" width="{{ VERSION_WIDTH }}" height="{{ ROW_HEIGHT }}"
fill="{% if version < newest_version %}red{% else %}green{% endif %}"></rect>
<text x="{{ VERSION_X + OUTER_MARGIN }}" y="{{ texty() }}">{{ version }}</text>{{ end_row() }}
{% endfor %}
</svg>
|