<!DOCTYPE html>
{% macro with_errors(field) %}
    {% if field.errors %}
        {% set css_class = 'has_error ' + kwargs.pop('class', '') %}
        {{ field(class=css_class, **kwargs) }}
        <ul class="errors">{% for error in field.errors %}<li>{{ error|e }}</li>{% endfor %}</ul>
    {% else %}
        {{ field(**kwargs) }}
    {% endif %}
{% endmacro %}
<html>
<head>
    <title>{% block title %}{% endblock %} - Galah</title>
    <link rel="stylesheet" href="/static/galah.css"></link>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(function() {
        $(".attention").each(function(index) {
            $(this).hide()
            $(this).delay(200*index).fadeIn(300)
        })
    })
    </script>
    {%- block includes %}{% endblock -%}
</head>
<body>
<div id="container">
    <div id="header" class="heading">
        <span class="logo"><a href="/home">Galah</a></span>
        <span class="path">
            {% block path %}{% endblock %}
        </span>
    </div>
    <div id="topbar">
    {%- if current_user.is_authenticated() %}
        <div id="login_status">
            You are logged in as <strong>{{ current_user.id }}</strong> (<a href="/logout">logout</a>)
        </div>
    {% else %}
        <div id="login_status">
            You are not logged in (<a href="/login">login</a>)
        </div>
    {% endif -%}
        {% with messages = get_flashed_messages(with_categories = True) %}
        {% if messages %}
        <div id="flashes">
            {% for category, message in messages %}
            {% if category in ("error", "message") %}
            <div class="attention {{ category }}">
                {{ message }}
            </div>
            {% endif %}
            {% endfor %}
        </div>
        {% endif %}
        {% endwith %}
    </div>
            
    {%- block content %}{% endblock -%}

    <div id="source_download">
        <b>Galah</b> Copyright John Sullivan and other contributers,
        <a href="http://www.gnu.org/licenses/agpl-3.0.html">some rights reserved</a>.
        Running {{ config['CURRENT_VERSION'] }}.
        (<a href="{{ config['SOURCE_HOST'] }}">Get the code!</a>)
    </div>
</div>
</body>
</html>
