view MoinMoin/templates/utils.html @ 2703:23f66a758366

Improved Item Size view and Interwiki Names view Added bootstrap tables to both views and made item sizes in the Item Size view human readable
author Ajitesh Gupta <ajgupta93@gmail.com>
date Sat, 09 Aug 2014 23:22:15 +0530
parents 7798855349f6
children 8c29936b3d29
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=[], filesize_cols=[]) %}
<table class="zebra table table-hover">
<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 loop.index in filesize_cols %}
                <td>{{ col|filesizeformat }}</td>
            {% elif 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.fullname, e.relname, e.meta['contenttype'], e.hassubitems) }}
                {% endif %}
                <a href="{{ url_for('frontend.show_item', item_name=e.fullname) }}"
                    title="{{ e.relname }}" class="subitem-link"
                    {% if newtab %}target="_blank"{% endif %}>{{ e.relname }}</a>
                {% if e.hassubitems %}
                    <button class="expander" title="{{ _('Expand Subitem') }}"></button>
                    {{ _render_subitem_navigation_tree(theme_supp.subitem_index(e.fullname), newtab, parentcaller) }}
                {% endif %}
            </li>
        {% endfor %}
    </ul>
{% endmacro %}

{% macro render_subitem_navigation(fqname, newtab, subitems=None) %}
    {% if not subitems %}
        {% set subitems = theme_supp.subitem_index(fqname) %}
    {% 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')) }}
            {{ forms.render(form['q']) }}
            {{ forms.render_submit(form, id='moin-search-submit') }}
            {{ forms.render_errors(form) }}
    {{ gen.form.close() }}
{% endmacro %}

{% macro meta_info(meta) %}
<!-- Bootstrap classes list-group and list-group-item used to display the metadata info in an unordered list -->
    <ul class="list-group">
        <li class="list-group-item">Action: {{ meta['action'] }}</li>
        <li class="list-group-item">Address: {{ meta['address'] }}</li>
        <li class="list-group-item">Comment: '{{ meta['comment'] }}'</li>
        <li class="list-group-item">Content Type: {{ meta['contenttype']|shorten_ctype }} [{{ meta['contenttype'] }}]</li>
        <li class="list-group-item">Data ID: {{ meta['dataid'] }}</li>
        <li class="list-group-item">External Links:
        {% if meta['externallinks'] %}
            {% for item in meta['externallinks'] %}
                <a href="{{ item|safe }}">
                    {{ item }}
                </a>,
            {% endfor %}
        {% else %}
            (None)
        {% endif %}
        </li>
        <li class="list-group-item">Item ID: {{ meta['itemid'] }}</li>
        <li class="list-group-item">Item Links:
        {% if meta['itemlinks'] %}
            {% for item in meta['itemlinks'] %}
                <a href="{{ url_for('frontend.show_item', item_name=item) }}" {% if not theme_supp.item_exists(item) %}class="moin-nonexistent"{% endif %}>
                    {{ item }}
                </a>,
            {% endfor %}
        {% else %}
            (None)
        {% endif %}
        </li>
        <li class="list-group-item">Item Transclusions:
        {% if meta['itemtransclusions'] %}
            {% for item in meta['itemtransclusions'] %}
                <a href="{{ url_for('frontend.show_item', item_name=item) }}" {% if not theme_supp.item_exists(item) %}class="moin-nonexistent"{% endif %}>
                {{ item }}
                </a>,
            {% endfor %}
        {% else %}
            (None)
        {% endif %}
        </li>
        <li class="list-group-item">Item Type: {{ meta['itemtype'] }}</li>
        <li class="list-group-item">Modified Time: {{ meta['mtime']|datetimeformat }}</li>
        <li class="list-group-item">Name:
        {% if meta['name'] %}
            {% for name in meta['name'] %}
                {{ name }}
            {% endfor %}
        {% else %}
            (None)
        {% endif %}
        </li>
        <li class="list-group-item">Old Name:
        {% if meta['name_old'] %}
            {% for name in meta['name_old'] %}
                {{ name }}
            {% endfor %}
        {% else %}
            (None)
        {% endif %}
        </li>
        <li class="list-group-item">Namespace: '{{ meta['namespace'] }}'</li>
        <li class="list-group-item">Revision ID: {{ meta['revid'] }}</li>
        <li class="list-group-item">SHA1: {{ meta['sha1'] }}</li>
        <li class="list-group-item">Size: {{ meta['size']|filesizeformat }}</li>
        <li class="list-group-item">Summary: '{{ meta['summary'] }}'</li>
        <li class="list-group-item">Tags:
        {% if meta['tags'] %}
            {% for tag in meta['tags'] %}
                {{ tag }}
            {% endfor %}
        {% else %}
            (None)
        {% endif %}
        </li>
        <li class="list-group-item">Wiki Name: {{ meta['wikiname'] }}</li>
    </ul>
{% endmacro %}