{% extends "mapit/base.html" %}
{% load i18n %}

{% block fulltitle %}
    {% trans "MapIt : map postcodes and geographical points to administrative areas" %}
{% endblock %}

{% block content_outer %}

    <header class="homepage-section homepage-intro">
        <div class="container">
            {% include "mapit/intro.html" %}
            {% block extra_intro %}{% endblock %}
        </div>
    </header>

    <div class="homepage-section homepage-try homepage-section--contrasting">
        <form method="post" action="{% url "mapit_index" %}{% if postcodes_available %}postcode{% else %}point{% endif %}/" class="homepage-try__form">
            <div class="container">
                <label for="try-mapit-pc">
                    {% if postcodes_available %}{% trans "Try it out, enter a postcode" %}:
                    {% else %}{% trans "Try it out, enter a lat,lon" %}:{% endif %}
                </label>
                <input type="text" name="pc" id="pc"{% if not postcodes_available %} placeholder="{% trans "latitude" %},{% trans "longitude" %}"{% endif %}>
                <input class="btn" type="submit" value="{% trans "Look up" %}">
            </div>
        </form>
    </div>

    <article class="content content--with-sidebar content--api-docs">

        <h2>{% trans "MapIt API Documentation" %}</h2>

        {% include "mapit/api/intro.html" %}

        <header>

            <nav class="toc">

                <p>{% trans "Lookups" %}</p>
                <ol>
                    {% if postcodes_available %}
                    <li><a href="#api-by_postcode">{% trans "Postcode" %}</a></li>
                    {% if partial_postcodes_available %}
                    <li><a href="#api-by_partial_postcode">{% trans "Partial postcode" %}</a></li>
                    {% endif %}
                    {% endif %}
                    <li><a href="#api-by_point">{% trans "Point" %}</a></li>
                    {% if postcodes_available %}
                    <li><a href="#api-nearest">{% trans "Nearest postcode" %}</a></li>
                    {% endif %}
                    <li><a href="#api-by_area_id">{% trans "Area" %}</a></li>
                    <li><a href="#api-related_areas">{% trans "Related areas" %}</a></li>
                    <li><a href="#api-multiple_areas">{% trans "Multiple areas" %}</a></li>
                    <li><a href="#api-code">{% trans "Code" %}</a></li>
                    <li><a href="#api-generations">{% trans "Generations" %}</a></li>
                </ol>

                <p>{% trans "Information" %}</p>
                <ul>
                    <li><a href="#general">{% trans "General information" %}</a></li>
                    <li><a href="#about-mapit">{% trans "About MapIt" %}</a></li>
                    <li><a href="#usage-licence">{% trans "Usage &amp; licence" %}</a></li>
                    <li><a href="https://github.com/mysociety/mapit">{% trans "Source code" %}</a></li>
                    {% if country == 'IT' %}
                    <li><a href="{% url 'mapit_changelog' %}">{% trans "Changelog" %}</a></li>
                    {% endif %}
                </ul>

                {% block extra_nav %}{% endblock %}

            </nav>

        </header>

        {% if postcodes_available %}
        {% include "mapit/api/postcode.html" %}
        {% endif %}
        {% include "mapit/api/point.html" %}
        {% include "mapit/api/area.html" %}
        {% include "mapit/api/areas.html" %}
        {% include "mapit/api/code.html" %}
        {% include "mapit/api/generations.html" %}

        <section id="general">
            <h3>{% trans "General information" %}</h3>
            <dl>
                <dt>{% trans "Format" %}</dt>
                <dd>

                {% blocktrans trimmed %}
                <p>All calls return JSON, you can generally get an HTML representation
                by sticking .html on the end.</p>
                {% endblocktrans %}

                {% blocktrans trimmed %}
                <p>Whenever an area is returned from MapIt, it is as a
                dictionary with the following keys: id, name, country, type,
                parent_area, generation_low, generation_high, codes.</p>
                {% endblocktrans %}
                </dd>
                <dt>{% trans "Historical areas" %}</dt>
                <dd>
                    {% blocktrans trimmed %}
                By default, calls will return active areas; for some calls
                you may specify a previous generation to look up instead.
                {% endblocktrans %}
                {% include "mapit/index-general-extra.html" %}
                </dd>
            </dl>
        </section>

        <section id="about-mapit">
            <h3>{% trans "About MapIt" %}</h3>

            {% blocktrans trimmed %}
            <p>MapIt was written back in 2003 as a postcode lookup to power the
            original <a href="http://www.mysociety.org/">mySociety</a> sites
            such as <a href="http://www.writetothem.com/">WriteToThem</a>. Over
            time it gained features such as point lookup (for
            <a href="http://www.fixmystreet.com/">FixMyStreet</a>), and when
            Ordnance Survey data became freely available in 2010, it was
            rewritten and made public for the whole UK.
            {% endblocktrans %}

            {% include "mapit/index-others.html" %}
            </p>

        </section>

        {% include "mapit/index-usage.html" %}

    </article>

{% endblock %}
