{% extends 'forgewiki:templates/wiki/master.html' %}
{% do g.register_forge_css('css/forge/hilite.css', compress=False) %}

{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / {{page.title}}{% endblock %}

{% block header %}{{page.title}}{% if page['deleted'] %}<span> (deleted)</span>{% endif %}{% endblock %}

{% block extra_css %}
<style>
  .hidden { display: none }
  a.notfound { color: #f00; }
</style>
{% endblock %}

{% block head %}
<link rel="alternate" type="application/rss+xml" title="Page RSS" href="feed.rss"/>
<link rel="alternate" type="application/atom+xml" title="Page Atom" href="feed.atom"/>
<link rel="alternate" type="application/rss+xml" title="Wiki RSS" href="../feed.rss"/>
<link rel="alternate" type="application/atom+xml" title="Wiki Atom" href="../feed.atom"/>
{% endblock %}
{% block body_attrs %} class="wiki-{{(page.title).replace(' ','_')}}"{% endblock %}

{% block actions %}
  {% if not page['deleted'] %}
    {% if c.user and c.user != c.user.anonymous() %}
      <a href="edit" title="Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}" title="Edit"></b></a>
    {% endif %}
    <a href="history" title="History"><b data-icon="{{g.icons['history'].char}}" class="ico {{g.icons['history'].css}}" title="History"></b></a>
  {% elif h.has_access(page, 'delete')() %}
    <a class="post-link" href="undelete" title="Undelete"><b data-icon="{{g.icons['undelete'].char}}" class="ico {{g.icons['undelete'].css}}" title="Undelete"></b></a>
  {% endif %}
  {% if c.user and c.user != c.user.anonymous() %}
    {{c.subscribe_form.display(value=subscribed, action='subscribe', style='icon')}}
  {% endif %}
	<a href="feed" title="RSS"><b data-icon="{{g.icons['feed'].char}}" class="ico {{g.icons['feed'].css}}" title="Feed"></b></a>
{% endblock %}

{% block wiki_content %}
{{page.html_text}}
{% endblock %}

{% block wiki_meta %}
<div class="editbox">
  {% if page.labels %}
  <div class="grid-9">
    <label class="simple">Labels: </label>
    {% for label in page.labels %}
      {% if label != '' %}
        <span><a href="{{c.app.url}}search/?q=labels_t:{{label}}">{{label}} ({{page.artifacts_labeled_with(label).count()}})</a></span>
      {% endif %}
    {% endfor %}
  </div>
  {% endif %}
  <div class="grid-9 gravatar sm">
    <label class="simple">Authors: </label>
    {% for author in page.authors() %}
      <a href="{{author.url()}}">
        {{lib.gravatar(author, size=16)}}
      </a>  
    {% endfor %}
  </div>
  {% if page.attachments %}
  <div class="grid-18">
    <strong>Attachments</strong>
  </div>
  {% endif %}
  {% for att in page.attachments %}
    {% if att.is_image() and not att.is_embedded() %}
    <div class="attachment_thumb">
      <a href="{{att.url()}}">
        <img src="{{att.url()}}/thumb" alt="Thumbnail"/>
      </a><br/>
      <a href="{{att.url()}}">{{att.filename}}</a>
      ({{att.length}} bytes)
    </div>
    {% else %}
    <div>
      <a href="{{att.url()}}">{{att.filename}}</a>
      ({{att.length}} bytes)
    </div>
    {% endif %}
  {% endfor %}
</div>
{% endblock %}

{% block after_content %}
  <hr class="grid-19" style="margin-top: 1em; margin-bottom: 2em; clear:both;">
  {{lib.related_artifacts(page)}}
  {% if page.discussion_thread and c.app.show_discussion %}
    {% set thread = page.discussion_thread %}
    <div>{{c.thread.display(value=thread)}}</div>
  {% endif %}
{% endblock %}
