{% extends theme("layout.html") %}
{% import "utils.html" as utils with context %}
{% import "forms.html" as forms with context %}
{% block content %}
    {% if results is not defined %}
        <h1>{{ _("Lookup") }}</h1>
        {{ gen.form.open(lookup_form, id='moin-lookup-form', method='get', action=url_for('frontend.lookup')) }}
            {{ forms.render_errors(lookup_form) }}
            <dl>
                {% for e in [
                    'name',
                    'name_exact',
                    'itemid',
                    'revid',
                    'userid',
                    'language',
                    'itemlinks',
                    'itemtransclusions',
                    'refs',
                    'tags',
                    'history',
                    ] %}
                    {{ forms.render(lookup_form[e]) }}
                {% endfor %}
            </dl>
            {{ forms.render_submit(lookup_form) }}
        {{ gen.form.close() }}
    {% else %}
        {% if not results %}
            <h1>{{ _("No results") }}</h1>
        {% else %}
            <h1>{{ _("More than one result") }}</h1>
            <div class="lookupresults">
                <table>
                    {% for result in results %}
                        <tr>
                            <td class="moin-wordbreak">{{ loop.index }}
                                <a href="{{ url_for_item(item_name=result.name, wiki_name='Self', rev=result.revid) }}"><b>{{ result.name }}</b></a>
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            </div>
        {% endif %}
    {% endif %}
{% endblock %}
