view MoinMoin/templates/utils.html @ 1988:490c13d072f2

remove Submit widget The Submit widget was a mistake. The buttons carry no user input, and making it part of the form screws up POST form handling. Instead of being a widget, the submit button has its label kept in the class member submit_label of the Form, and is rendered by a new macro forms.render_submit.
author Cheer Xiao <xiaqqaix@gmail.com>
date Tue, 12 Feb 2013 10:28:18 +0800
parents 7f04d451cd7b
children e1cf79737e15
line wrap: on
line source
{% import 'forms.html' as forms %}

{% macro show_editor_info(info) %}
  {%- if info.uri -%}
      <a href="{{ info.uri }}" class="{{ info.css }}" title="{{ info.title }}">
  {%- elif info.email -%}
      <a href="mailto:{{ info.email }}" class="{{ info.css }}" title="{{ info.title }}">
  {%- else -%}
      <span class="{{ info.css }}" title="{{ info.title }}">
  {%- endif -%}
  {{ info.text }}
  {%- if info.uri or info.email -%}
    </a>
  {%- else -%}
    </span>
  {%- endif -%}
{% endmacro %}


{% macro editor_info(meta) %}
  {%- set info = get_editor_info(meta) -%}
  {{ show_editor_info(info) }}
{% endmacro %}


{% macro table(headings, rows, itemname_cols=[], url_cols=[]) %}
<table class="zebra">
<thead>
    <tr>
        {% for heading in headings %}
            {% if rows and rows[0][loop.index0] is number %}
                <th class="moin-integer">{{ heading }}</th>
            {% else %}
                <th>{{ heading }}</th>
            {% endif %}
        {% endfor %}
    </tr>
</thead>
<tbody>
{% for row in rows %}
    <tr>
        {% for col in row %}
            {% if col is number %}
                <td class="moin-integer">{{ col }}</td>
            {% elif loop.index in itemname_cols %}
                <td><a href="{{ url_for('frontend.show_item', item_name=col) }}">{{ col }}</a></td>
            {% elif loop.index in url_cols %}
                <td><a href="{{ col }}">{{ col }}</a></td>
            {%- else -%}
                <td>{{ col }}</td>
            {% endif %}
        {% endfor %}
    </tr>
{% endfor %}
</tbody>
</table>
{% endmacro %}

{% macro _render_subitem_navigation_tree(index, newtab, parentcaller) %}
    <ul>
        {% for e in index %}
            <li>
                {# call our parent's caller with all the data we have if they exist, used to implement
                    transclude/link actions in the modify view #}
                {% if parentcaller %}
                    {{ parentcaller(e.meta['name'], e.relname, e.meta['contenttype'], e.hassubitems) }}
                {% endif %}
                <a href="{{ url_for('frontend.show_item', item_name=e.meta['name']) }}"
                    title="{{ e.relname }}" class="subitem-link"
                    {% if newtab %}target="_blank"{% endif %}>{{ e.relname }}</a>
                {% if e.hassubitems %}
                    <button class="expander" title="{{ _('Expand Subitem') }}"
                        onclick="toggleSubtree(this)"></button>
                    {{ _render_subitem_navigation_tree(theme_supp.subitem_index(e.meta['name']), newtab, parentcaller) }}
                {% endif %}
            </li>
        {% endfor %}
    </ul>
{% endmacro %}

{% macro render_subitem_navigation(itemname, newtab, subitems=None) %}
    {% if not subitems %}
        {% set subitems = theme_supp.subitem_index(itemname) %}
    {% endif %}
    {% if caller %}
        {% set mycaller = caller %}
    {% endif %}
    {% if subitems %}
        <div class="moin-subitem-navigation">
            <div class="list-header">
                {{ _('Subitems') }}
            </div>
            {{ _render_subitem_navigation_tree(subitems, newtab, mycaller) }}
        </div>
    {% endif %}
{% endmacro %}

{% macro header_search(form) %}
    {{ gen.form.open(form, id='moin-searchform', method='get', action=url_for('frontend.search')) }}
        <div>
            {{ forms.render(form['q']) }}
            {{ forms.render_submit(form, id='moin-search-submit') }}
            {{ forms.render_errors(form) }}
        </div>
    {{ gen.form.close() }}
{% endmacro %}