{% extends 'html/main.html' %}


{% block header_scripts %}
	{% if pwic.env.mathjax %}
		<script>
			window.MathJax = {
				tex: { inlineMath: [['$', '$'], ['\\(', '\\)']] },
				svg: { fontCache: 'global' }
			};
		</script>
		<script src="/static/mathjax.min.js" async></script>
	{% endif %}
{% endblock %}


{% block content %}
	<header>
		<div class="pwic_ph1"><a href="/{% if pwic.page != pwic.constants['default_home'] %}{{pwic.project|urlencode}}{% endif %}">{{pwic.project_description|escape}}</a></div>
		{% if (not pwic.env.no_search) or (pwic.links|count > 0) %}
			<div class="pwic_tagbox">
				{% for link in pwic.links %}
					<a href="/{{pwic.project|urlencode}}/{{link.page|urlencode}}">{{link.title|escape}}</a>
				{% endfor %}
				{% if not pwic.env.no_search %}
					<div class="pwic_searchbox pwic_js">
						{{pwic.emojis.search}}
						<input type="text" id="page_search" onkeypress="page_search()">
					</div>
				{% endif %}
			</div>
		{% endif %}
	</header>

	<article>
		<div id="pwic_progress"></div>

		{% if pwic.env.maintenance %}
			<div class="pwic_error">{{pwic.emojis.calendar}} {{pwic.env.maintenance.value|escape|replace('\\n','<br>')}}</div>
		{% endif %}
		{% if pwic.env.message %}
			<div class="pwic_information">{{pwic.emojis.pin}} {{pwic.env.message.value|escape|replace('\\n','<br>')}}</div>
		{% endif %}

		<div class="pwic_action_bar">
			{% if pwic.protection %}
				<span title="{% trans %}The page is protected{% endtrans %}">{{pwic.emojis.padlock}}</span>
			{% endif %}
			<a href="/{{pwic.project|urlencode}}/special">{{pwic.emojis.star}} {% trans %}Special{% endtrans %}</a>
			{% if pwic.manager %}
				<a class="pwic_js" href="/{{pwic.project|urlencode}}/special/page">{{pwic.emojis.sparkles}} {% trans %}New page{% endtrans %}</a>
			{% endif %}
			{% if pwic.latest and (pwic.manager or (pwic.editor and not pwic.protection)) %}
				<a class="pwic_js" href="/{{pwic.project|urlencode}}/{{pwic.page|urlencode}}/edit">{{pwic.emojis.set_square}} {% trans %}Edit{% endtrans %}</a>
			{% endif %}
			{% if not pwic.pure_reader or not pwic.env.no_history %}
				<a href="/{{pwic.project|urlencode}}/{{pwic.page|urlencode}}/history">{{pwic.emojis.clock}} {% trans %}History{% endtrans %}</a>
			{% endif %}
			{% if pwic.manager %}
				<a class="pwic_js" href="/{{pwic.project|urlencode}}/{{pwic.page|urlencode}}/move">{{pwic.emojis.truck}} {% trans %}Move{% endtrans %}</a>
			{% endif %}

			<a class="pwic_js" href="#" onclick="return page_email()">{{pwic.emojis.outbox}} {% trans %}Email{% endtrans %}</a>
			{% if not pwic.env.no_printing %}
				<a class="pwic_desktop pwic_js" href="#" onclick="return page_print()">{{pwic.emojis.printer}} {% trans %}Print{% endtrans %}</a>
			{% endif %}

			{% set no_formats = pwic.env.get('file_formats_disabled', {'value': ''}).value.split(' ') %}
			{% if '*' not in no_formats %}
				{% for f in pwic.file_formats %}
					{% if f not in no_formats %}
						<a class="pwic_js" href="#" title="{% trans %}Export to{% endtrans %} {{f|escape|upper}}" onclick="return page_export('{{f|escape}}')">{{pwic.emojis.save}} {{f|escape|upper}}</a>
					{% endif %}
				{% endfor %}
			{% endif %}

			{% if pwic.validator and (pwic.valuser == '') and pwic.final %}
				<a class="pwic_js" href="#" onclick="return page_post_action('validate', {% trans %}'The validation cannot be undone.\n\nDo you want to continue?'{% endtrans %})">{{pwic.emojis.validate}} {% trans %}Validate{% endtrans %}</a>
			{% endif %}
			{% if pwic.removable %}
				<a class="pwic_js" href="#" onclick="return page_post_action('delete', {% trans %}'Warning: deleting the revision cannot be undone.\n\nDo you want to continue?'{% endtrans %})">{{pwic.emojis.trashcan}} {% trans %}Delete{% endtrans %}</a>
			{% endif %}
		</div>

		{% if not pwic.latest %}
			<p class="pwic_warning">{{pwic.emojis.eye}}
				{% if pwic.env.validated_only %}
					{{ gettext('You are viewing the <span class="pwic_bold">revision %(revision)d</span> and <a href="/%(project)s/%(page)s/history">other revisions</a> are pending.')|format(revision=pwic.revision, project=pwic.project|urlencode, page=pwic.page|urlencode) }}
				{% else %}
					{{ gettext('You are viewing the <span class="pwic_bold">revision %(revision)d</span>, but the <a href="/%(project)s/%(page)s">latest version</a> is available.')|format(revision=pwic.revision, project=pwic.project|urlencode, page=pwic.page|urlencode) }}
				{% endif %}
			</p>
		{% endif %}

		{% if pwic.valuser != '' %}
			<p class="pwic_information">{{pwic.emojis.flag}} {{ gettext('This page has been validated by <a href="/special/user/%(user1)s" rel="nofollow">%(user2)s</a> on %(sdate)s at %(stime)s.')|format(user1=pwic.valuser|urlencode, user2=pwic.valuser|escape, sdate=pwic.valdate|escape, stime=pwic.valtime|escape) }}</p>
		{% endif %}

		{% if pwic.tmap|count + pwic.documents|count > 1 %}
			<div id="pwic_browser_access" class="pwic_js" title="{% trans %}Show/Hide the map of the page{% endtrans %}" onclick="page_tmap()">
				{{pwic.emojis.pin}}
			</div>
			<div id="pwic_browser" class="pwic_hidden">
				{% for tmap in pwic.tmap %}
					<a class="pwic_browser_item pwic_browser_item_h{{tmap.level}}" href="#{{tmap.tag|urlencode}}" onclick="page_tmap()">{% if not pwic.env.no_heading %}<span class="pwic_bold">{{tmap.header|escape}}</span> {% endif %}{{tmap.title|no_html|escape}}</a>
				{% endfor %}

				{% if not pwic.env.no_document_list and (pwic.documents|count + pwic.images|count > 0) %}
					<a class="pwic_browser_item pwic_browser_item_h1" href="#page_documents" onclick="page_tmap()">{{pwic.emojis.scroll}} {% trans %}Attached documents{% endtrans %}</a>
				{% endif %}
			</div>
		{% endif %}

		{% if pwic.relations|count > 0 %}
			<p id="pwic_relations">
				<span class="pwic_bold">{% trans %}Related pages:{% endtrans %}</span>
				{% for p in pwic.relations %}
					{% if loop.index > 1 %} &ndash; {% endif %}
					<a href="{{p[0]|escape}}">{{p[1]|escape}}</a>
				{% endfor %}
			</p>
		{% endif %}

		{% if pwic.tags|count > 0 %}
			<div class="pwic_tagbox">
				{% for tag in pwic.tags %}
					{% if pwic.env.no_search %}
						<a href="#" onclick="return false">#{{tag|escape}}</a>
					{% else %}
						<a href="/{{pwic.project|urlencode}}/special/search?q=%23{{tag|urlencode}}" title="{% trans %}Search for related classified pages{% endtrans %}">#{{tag|escape}}</a>
					{% endif %}
				{% endfor %}
			</div>
		{% endif %}

		{{pwic.html}}

		{% if not pwic.env.no_document_list and (pwic.documents|count + pwic.images|count > 0) %}
			<h1 id="page_documents" class="pwic_cursor" title="{% trans %}Expand/Collapse{% endtrans %}" onclick="$('#page_section_files').toggleClass('pwic_hidden')">{% trans %}Attached documents{% endtrans %}</h1>

			<div id="page_section_files">
				{% if pwic.documents|count > 0 %}
					<div class="pwic_file_gallery">
						{% if pwic.documents|count + pwic.images|count > 1 %}
							<a href="/{{pwic.project|urlencode}}/special/documents/{{pwic.page|urlencode}}" rel="nofollow">
								<span>{% trans %}Download all{% endtrans %}</span>
								<br>{{pwic.emojis.inbox}}
							</a>
						{% endif %}
						{% for doc in pwic.documents %}
							<a href="/special/document/{{doc.id|urlencode}}/{{doc.filename|urlencode}}" title="{{ gettext('Uploaded by %(author)s on %(date)s at %(time)s.')|format(author=doc.author|escape, date=doc.date|escape, time=doc.time|escape) }}">
								<span>{{doc.filename|escape}}</span>
								<br><small>{{doc.mime|escape}}</small> ({{doc.size|size2str|escape}})
							</a>
						{% endfor %}
					</div>
				{% endif %}

				{% if pwic.images|count > 0 %}
					<div class="pwic_file_gallery">
						{% if (pwic.documents|count == 0) and (pwic.images|count > 1) %}
							<a href="/{{pwic.project|urlencode}}/special/documents/{{pwic.page|urlencode}}" rel="nofollow">
								<span>{% trans %}Download all{% endtrans %}</span>
								<br>{{pwic.emojis.inbox}}
							</a>
						{% endif %}
						{% for doc in pwic.images %}
							<a href="/special/document/{{doc.id|urlencode}}/{{doc.filename|urlencode}}" title="{{ gettext('Uploaded by %(author)s on %(date)s at %(time)s.')|format(author=doc.author|escape, date=doc.date|escape, time=doc.time|escape) }}">
								<span>{{doc.filename|escape}}</span>
								<br><small>{{doc.mime|escape}}</small> ({{doc.size|size2str|escape}})
							</a>
						{% endfor %}
					</div>
				{% endif %}
			</div>
		{% endif %}

		<p id="page_lastmod">
			{{ gettext('Revision <span class="pwic_bold">#%(revision)d</span> was last modified by <a href="/special/user/%(author1)s" rel="nofollow">%(author2)s</a><br>on %(date)s at %(time)s &mdash; <span title="Hash: %(hash)s">%(shash)s</span>')|format(revision=pwic.revision, author1=pwic.author|urlencode, author2=pwic.author|escape, date=pwic.date|escape, time=pwic.time|escape, hash=pwic.hash|escape, shash=pwic.hash[:16]|escape) }}
		</p>

		{% if pwic.env.legal_notice %}
			<div id="page_legal_notice">{{pwic.env.legal_notice.value|escape|replace('\n','<br>')}}</div>
		{% endif %}
	</article>

	<!-- Scripts -->
	{% include 'js/page.js' %}
	{% if not pwic.env.no_search %}
		{% include 'js/search.js' %}
	{% endif %}
{% endblock %}
