{% extends "wiki/base.html" %}
{% load i18n %}
{% load markup %}
{% load wiki %}
{% load pagelink %}

{% block pagetop %}
    {% include "wiki/page-icon-links.html" %}
    {% pagelink page "y" %}
    {% include "wiki/navigation.html" %}
{% endblock pagetop %}

{% block contents %}
    {% if content.title %}<h1 class="alt">{{ content.title }}</h1>{% endif %}
    {% if page.desc %}<h2 class="alt">{{ page.desc }}</h2>{% endif %}

    <div class="pagecontent">
    {{ content|wiki }}
    </div>
    <hr class="space">

    {% if page.attachment_set.all %}
    <h3 class="attachments">Attachments</h3>
      <table class="attachments" width="90%">
        <tr cellspacing="10">
          <th>Name</th>
          <th>Description</th>
        </tr>
      {% for att in page.attachment_set.all %}
        <tr><td><a href="{{ att.attachment.url }}">{{ att.name }}</a></td><td>{{ att.desc|default:"--" }}</td></tr>
      {% endfor %}
      </table>
    {% endif %}
{% endblock contents %}

{% block pagebottom %}
    {% include "wiki/page-icon-links.html" %}
    {% pagelink page "y" %}<br />
    <a href="{% url wiki-page-history wiki.fullname_url,page.fullname_url %}">History.</a><br />
    <span class="format-links"><a href="{{ request.path }}?format=text">text</a> |
      <a href="{{ request.path }}?format=pdf">PDF</a> |
      <a href="{{ request.path }}?format=html">HTML</a></span>
{% endblock pagebottom %}

{% block sidebarextra %}
<div id="linkedpages">
  Linked pages
  {% if content.linked.all %}
  <ul>
    {% for lp in content.linked.all %}
    <li><a href="{{ lp.get_absolute_url }}">{% ifequal lp.wiki page.wiki %}{{ lp.name }}{% else %}{{ lp.absolutename }}{% endifequal %}</a></li>
    {% endfor %}
  </ul>
  {% else %}
  <p>--</p>
  {% endif %}
</div>

<div id="linkedby">
  Linked by
  {% if page.linkedby.all %}
  <ul>
    {% for pc in page.linkedby.all %}
    <li><a href="{{ pc.page.get_absolute_url }}?rev={{ pc.rev }}">{% ifequal pc.wiki page.wiki %}{{ pc.page.name }}{% else %}{{ pc.page.absolutename }}{% endifequal %}</a></li>
    {% endfor %}
  </ul>
  {% else %}
  <p>--</p>
  {% endif %}
</div>
{% endblock sidebarextra %}
