# HG changeset patch # User Goffi # Date 1506264495 -7200 # Node ID 7d5cca978eebf9b778b28d48c19a8a8819ae20f1 # Parent 0520b7c9dcc0073eee9e57c442c3b483958405b7 input/xmlui: XMLUI generation first draft diff -r 0520b7c9dcc0 -r 7d5cca978eeb default/input/xmlui.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/input/xmlui.html Sun Sep 24 16:48:15 2017 +0200 @@ -0,0 +1,108 @@ +{% import 'input/field.html' as field %} + +{# generate methods #} + +{% macro generate_container(cont) %} + {% if cont.type == 'vertical' %} + {{ vertical_container(cont) }} + {% elif cont.type == 'pairs' %} + {{ pairs_container(cont) }} + {% elif cont.type == 'label' %} + {{ label_container(cont) }} + {% endif %} +{% endmacro %} + +{% macro generate_widget(wid, id=none) %} + {% if wid.type == 'text' %} + {{ text_widget(wid, id=id) }} + {% elif wid.type == 'label' %} + {{ label_widget(wid) }} + {% elif wid.type == 'string' %} + {{ string_widget(wid, id=id) }} + {% elif wid.type == 'textbox' %} + {{ textbox_widget(wid, id=id) }} + {% elif wid.type == 'list' %} + {{ list_widget(wid, id=id) }} + {% endif %} +{% endmacro %} + +{% macro generate_children(cont) %} + {% for child in cont.children %} + {% if child.category == 'container' %} + {{ generate_container(child) }} + {% else %} + {{ generate_widget(child) }} + {% endif %} + {% endfor %} + +{% endmacro %} + +{% macro generate(xmlui) %} + {{ generate_container(xmlui.main_cont) }} +{% endmacro %} + +{# containers #} + +{% macro vertical_container(cont) %} +
+ {{ generate_children(cont) }} +
+{% endmacro %} + +{% macro pairs_container(cont) %} + {# TODO: proper impelmentation (do the same as vertical container for now #} +
+ {{ generate_children(cont) }} +
+{% endmacro %} + +{% macro label_container(cont) %} +
+ {% for child in cont.children %} + {% if loop.index is odd %} + {# label #} + {% set id = 'widget'|next_gidx %} + {% if child.type == 'label' %} + {{ label_widget(child, for=id) }} + {% endif %} + {% else %} + {# widget #} + {% set id = 'widget'|cur_gidx %} + {{ generate_widget(child, id=id) }} + {% endif %} + {% endfor %} +
+{% endmacro %} + + +{# widgets #} + +{% macro text_widget(wid, id=none) %} +

+ {{wid.value}} +

+{% endmacro%} + +{% macro label_widget(wid, for=none) %} + +{% endmacro%} + +{% macro string_widget(wid, id=none) %} + +{% endmacro%} + +{% macro textbox_widget(wid, id=none) %} + +{% endmacro%} + +{% macro list_widget(wid, id=none) %} + +{% endmacro%} diff -r 0520b7c9dcc0 -r 7d5cca978eeb default/static/styles.css --- a/default/static/styles.css Sun Sep 24 16:47:12 2017 +0200 +++ b/default/static/styles.css Sun Sep 24 16:48:15 2017 +0200 @@ -52,3 +52,25 @@ width: 60%; margin: 1.5em auto; } + +/* Forms */ + +.form_submit { + margin: 1em auto 0; + display: block; +} + +/* XMLUI */ + +.xmlui_cont_vertical>* { + display: block; + box-sizing: border-box; +} + +.xmlui_cont_vertical>.xmlui_widget { + width: 100%; +} + +label.xmlui_label { + font-weight: bold; +}