{% extends 'ccpages/base.html' %}

{% load ccpages_tags %}

{% load markup %}

{% block title %}{{page.title}} &ndash; {% endblock %}

{% block breadcrumbs %}
	{% ccpages_nav_breadcrumbs page as nav_breadcrumb_pages %}

	{% for page in nav_breadcrumb_pages %}
		<li><a href="{{page.get_absolute_url}}">{{page.title}}</a></li>
	{% endfor %}

	<li><a href="{{page.get_absolute_url}}">{{page.title}}</a></li>

{% endblock %}

{% block nav_local %}
	{% ccpages_nav_local page as nav_local_pages %}
	{% for page in nav_local_pages %}
		{% if forloop.first %}
		<ul>
		{% endif %}

		<li><a href="{{page.get_absolute_url}}">{{page.title}}</a></li>

		{% if forloop.last %}
		</ul>
		{% endif %}
	{% endfor %}
{% endblock %}

{% block content %}
	<article>
		<header>
			<h1>{{page.title}}</h1>
		</header>

		{{page.content|markdown}}

		{% for image in page.pageimage_set.all %}
			{% if forloop.first %}
				<div class="images">
			{% endif %}

				<img src="{{image.src.url_140x140}}" alt="{{image.title}}">

			{% if forloop.last %}
				</div>
			{% endif %}
		{% endfor %}

		{% for attachment in page.pageattachment_set.all %}
			{% if forloop.first %}
				<div class="attachments">
			{% endif %}

				<a href="{{attachment.src.url}}" title="{{attachment.title}}">
					{{attachment.name}} ({{attachment.src.size|filesizeformat}})
					<img src="{{attachment|icon_for_attachment:"medium"}}"
					alt="icon for {{attachment.name}}">
				</a>

			{% if forloop.last %}
				</div>
			{% endif %}
		{% endfor %}
	</article>
{% endblock %}
