{% extends 'maple/base.html' %}
{% from 'base/paginate.html' import paginate%}
{% from 'base/paginate.html' import footer as p_footer %}
{% import 'base/link.html' as link %}
{% import 'base/panel.html' as panel_base %}
{% from 'base/head.html' import breadcrumb %}
{% block script -%}
{{ super() }}
<!-- <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> -->
{%- endblock script %}

{% block style -%}
{{ super() }}
<link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
{%- endblock style %}

{% block main %}
{% include "base/header.html" %}
<div class="col-md-offset-1 col-md-10" style="padding:0;margin-top:60px">
    {% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
    {% for category,message in messages %}
    {% if category == 'message' -%}
    {% set category = 'info' %}
    {%- endif %}
    <div class="alert alert-{{ category }}" style="padding:8px">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
        <ul>
            <li>{{ message }} </li>
        </ul>
    </div>
    {% endfor %}
    {% endif %}
    {% endwith %}
    {{ dropdown() }}
    {% block content %}{% endblock %}
</div>
{% endblock %}

{% macro dropdown() -%}
{% if g.user.is_authenticated %}
<div class="btn-group pull-right">
    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        {{ g.user.username }} <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="{{ url_for('user.user',username=g.user.username) }}">{{ _('Home Page') }}</a></li>
        <li><a href="{{ url_for('setting.setting') }}">{{ _('Setting')}}</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="{{ url_for('auth.logout') }}">{{ _('Logout')}}</a></li>
    </ul>
</div>
{% else  %}
<a href="{{ url_for('auth.register') }}" class="btn btn-sm btn-primary pull-right">{{ _('Register') }}</a>
<a href="{{ url_for('auth.login') }}" class="btn btn-sm btn-primary pull-right">{{ _('Login') }}</a>
{% endif %}
<a href="{{ url_for('tag.list') }}" class="btn btn-sm btn-primary pull-right">{{ _('TagList') }}</a>
<a href="{{ url_for('user.list') }}" class="btn btn-sm btn-primary pull-right">{{ _('UserList') }}</a>
{%- endmacro %}
