{% extends 'base.html' %}

{% block title %}
  {{ path }} - {{ super() }}
{% endblock %}

{% block content %}

{% include 'tree.inc.html' %}

{% set raw_url = url_for('raw', repo=repo.name, namespace=namespace, rev=rev, path=path) %}
{% macro not_shown(reason) %}
  <div>
    ({{ reason }} not shown &mdash; <a href="{{ raw_url }}">Download file</a>)
  </div>
{% endmacro %}

<div class=blobview>
  <h2>
    {{ filename|force_unicode }}
    <span>
      @<a href="{{ url_for('commit', repo=repo.name, namespace=namespace, rev=rev) }}">{{ rev|shorten_sha1 }}</a>
      &mdash;
      {% if is_markup %}
        {% if render_markup %}
          <a href="?markup">view markup</a>
        {% else %}
          <a href="?">view rendered</a>
        {% endif %}
        &middot;
      {% endif %}
      <a href="{{ raw_url }}">raw</a>
      &middot; <a href="{{ url_for('history', repo=repo.name, namespace=namespace, rev=rev, path=path) }}">history</a>
      {% if not is_binary and not too_large %}
      &middot; <a href="{{ url_for('blame', repo=repo.name, namespace=namespace, rev=rev, path=path) }}">blame</a>
      {% endif %}
    </span>
  </h2>
  {% if is_binary %}
    {% if is_image %}
      <a href="{{ raw_url }}"><img src="{{ raw_url }}"></a>
    {% else %}
      {{ not_shown("Binary data") }}
    {% endif %}
  {% elif too_large %}
    {{ not_shown("Large file") }}
  {% else %}
    {% autoescape false %}
      {% if is_markup and render_markup %}
        <div class=markup>{{ rendered_code }}</div>
      {% else %}
        {{ rendered_code }}
      {% endif %}
    {% endautoescape %}
  {% endif %}
</div>

<script>
  highlight_linenos({linksSelector: '.highlighttable .linenos a'});
</script>

{% endblock %}
