{% extends "home/base.html" %}
{% load i18n %}
{% load molly_utils %}
{% load molly_search %}

{% comment %}
        index.html
        The root home page
        
        block list - indentation defines hierarchy 
        ==========================================
        - site_title (the title for the front page of the site)
        - title 
        
        - header
        - content
          - date
          - weather_location
          - below_weather
          - below_about
{% endcomment %}

{% block site_title %}{% endblock site_title %}

{% block title %}{{ site_name }}{% endblock title %}

{% block header %}

{# Displayed on the home page - contains brand mark and universal search form #}
<div id="index-header">
    {# Brandmark for site #}
    <div id="index-title">
        
    {# Display a logo (should be on white background) for featurephones: should be .jpg for compatibility #}
    {% ifequal style_group "dumb" %}
        <img width="90" height="55" src="{{ STATIC_URL }}site/images/logos/logo-90x55.jpg" alt="{{ site_name }}">
    {% else %}
        {# Standard logo for non-featurephones #}
        <img width="128" height="51" src="{{ STATIC_URL }}site/images/logos/logo-128x51-TRMargin-5px.png" alt="{{ site_name }}"/>
        {% endifequal %}
    </div>

        {# universal search form #}
    <div id="index-search">
        {% search_form %}
    <form method="get" action="{% url search:index %}">
        <p>
        {{ search_form.query }}
        {# Give featurephones a simple search button #}
        {% ifequal style_group "dumb" %}
            <input type="submit" value="{% trans 'Search' %}" />
        {% else %}
            {# Give non-featurephones an image search button #}
            <input type="image" src="{{ STATIC_URL }}site/images/buttons/search-button.png" title="{% trans 'Search' %}" alt="{% trans 'Search' %}"/>
        {% endifequal %}
        </p>
    </form>
    </div>
</div>
{% endblock header %}

{% block content %}
    {# Display messages to the user such as warnings for Opera Mini #}
    {% for message in messages %}
      <div class="bubble pad-10">
	{% if message.url %}<a href="{{ message.url }}">{% endif %}{{ message.body|sanitize_html }}{% if message.url %}</a>{% endif %}
      </div>
    {% endfor %}

    {# The main icon bubble for non-featurephones, access keys are defined in the view #}
    <div class="bubble">
        <div class="center">
        <ol class="icon-menu">
        {% for application in applications %}{% if application.display_to_user %}
            <li id="menu-{{ application.local_name }}">
            <a {% if application.accesskey %} accesskey="{{ application.accesskey }}"{% endif %} href="{{ application.url }}">{% trans application.title %}</a>
            </li>
        {% endif %}{% endfor %}
        </ol>
    </div>
    </div>
    </div>
    
    {# The a div to display various 'quick' bits of information #}
    {% block weather %}{% if weather %}
    <div id="quick-info" class="bubble pad-5">
        <table>
            <tbody>
                <tr>
                    <td class="half-width">
                    {% block date %}
                        {% now "l, jS F, Y" %}
                    {% endblock date %}
                    </td>
                    <td class="half-width weather">
                {% block weather_location %}{{ weather.name }}{% endblock weather_location %}: {{ weather.temperature }}&deg;C<img src="{{ STATIC_URL }}weather/images/{{ weather.icon }}_small.png" alt="{{ weather.get_outlook_display|capfirst }}" height="30" width="30"/>
                    </td>
                </tr>
                {% block below_weather %}{% endblock below_weather %}
            </tbody>
        </table>
    </div>
    {% endif %}{% endblock weather %}
    
    {# Display a list of favourite pages if a user has made any #}
    {% if favourites %}
    <div class="section">
      <div class="header">
        <h2>{% trans "Favourites" %}</h2>
      </div>
      <ul class="link-list">
    {% for favourite in favourites %}
      <li class="favourite-link">
        <a href="{{ favourite.url }}">{{ favourite.metadata.title|safe }}
        {% if favourite.metadata.additional %}
        <br /><span class="additional">{{ favourite.metadata.additional|safe }}</span>
        {% endif %}
        </a>
      </li>
    {% endfor %}
        <li><a href="{% url favourites:index %}"><strong>{% trans "Manage Favourites" %}</strong></a></li>
      </ul>
    </div>
    {% endif %}

    <ul class="stand-alone link-list">
        {% if "feature_vote"|app_is_loaded or "feature-suggestions"|app_is_loaded %}
            <li><a href="{% url feature_vote:index %}">{% trans "Suggest a feature" %}</a></li>
        {% endif %}
        <li><a href="{% url home:static_about %}">{% trans "About this site" %}</a></li>
        {% if has_user_messages %}
            <li><a href="{% url home:messages %}">{% trans "Read messages from the developers" %}</a></li>
        {% endif %}
        <li><a href="{% url feedback:index %}?referer={% url home:index %}">{% trans "Provide feedback" %}</a></li>
    </ul>

    {% block below_about %}
    {% endblock below_about %}
    {% if LANGUAGES|length > 1 %}
        {% include "i18n/language_selector.html" %}
    {% endif %}

{% endblock content %}
