{% extends "badger/base.html" %}
{% import "badger/includes/macros.html" as macros %}

{% set user = award.user %}
{% set award_url = request.build_absolute_uri(url('badger.views.award_detail', award.badge.slug, award.id)) %}
{% if award.image %}
    {% set image_url = award.image.url %}
{% elif badge.image %}
    {% set image_url = badge.image.url %}
{% else %}
    {# TODO: Put the URL for default badge image in settings #}
    {% set image_url = "/media/img/default-badge.png" %}
{% endif %}

{% block pageid %}award_detail{% endblock %}

{% block extrahead %}
    <link rel="alternate" type="application/json"
        title="{{ _('{title} (JSON)') | f(title=award) }}"
        href="{{ request.build_absolute_uri(url('badger.award_detail_json', badge.slug, award.pk)) }}" />

     <meta property="og:type" content="article"> 
     <meta property="og:url" content="{{ award_url }}">
     <meta property="og:site_name" content="{{ settings.SITE_TITLE }}">
     <meta property="og:image" content="{{ request.build_absolute_uri(image_url) }}">
     <meta property="og:title" content="{{ badge.title }}">
     <meta property="og:description" content="{{ award.user }} earned the badge &quot;{{ badge.title }}&quot; on {{ settings.SITE_TITLE }}!"> 
     <meta property="og:updated_time" content="{{ award.created.isoformat() }}Z"> 
     <meta property="article:published_time" content="{{ award.created.isoformat() }}Z"> 
     {% if award.creator %}
         <meta property="article:author" content="{{ request.build_absolute_uri(award.creator.get_absolute_url()) }}">
     {% endif %}
     {% for tag in badge.tags.all() %}
     <meta property="article:tag" content="{{ tag.name }}">
     {% endfor %}
{% endblock %}

{% block intro %}
    
{% endblock %}

{% block subcontent %}

<h1>{{ _('Badge award:') }} {{ badge.title }}</h1>
<div class="column-container">
    <div class="column-strip">
        <a href="{{ badge.get_absolute_url() }}" class="image">{{ macros.badge_image(badge, MEDIA_URL, 256) }}</a>
        {% if award.user == request.user %}
            <form class="obi_issuer">
                <button class="btn issue"><img class="obi_icons" width="32" style="margin: 0 0em 0em 0; float: left" src="http://openbadges.org/wp-content/themes/openbadges2/media/images/content-background.png" />
                    <strong>{{_("Add this to your Mozilla&nbsp;Badge&nbsp;Backpack") | safe}}</strong></button>
            </form>
        {% endif %}
    </div>
    <div class="column-main">
        {% if badge.description %}
            <p>{{ badge.description }}</p>
        {% endif %}

        <section class="award span8">
            {% include "badger/includes/award_full.html" %}
        </section>
    </div>
</div>

{% endblock %}

{% block js %}
    <script type="text/javascript"
        src="{{ settings.OBI_BASE_URL }}issuer.js"></script>
{% endblock %}
