<!DOCTYPE html>
<html lang="en-us">
	<head>
		{% include "mini_buildd/includes/head.html" %}
		<title>mini-buildd ({{ mbd.daemon.get_title }}): {% block titledup %}{% endblock %}</title>
	</head>

	<body>
		<header class="mbd-grid-lcr {{ mbd.daemon.is_alive|yesno:',mbd-off' }}">
			<nav>
				<ul>
					<li>
						<a href="/">
							<img class="mbd-logo" src="{% static 'icons/mini-buildd.svg' %}" alt="Home" title="Home: {{ mbd.daemon.get_title }}">
						</a>
					</li>
					<li class="{% mbd_menu_active "events" %}">
						<a href="{{ mbd.config.URIS.events.view.uri }}" title="">Events</a>
					</li>
					<li class="{% mbd_menu_active "repositories" %}">
						<a href="{{ mbd.config.URIS.repositories.view.uri }}" title="">Repositories</a>
					</li>
					<li class="{% mbd_menu_active "builders" %}">
						<a href="{{ mbd.config.URIS.builders.view.uri }}" title="">Builders</a>
					</li>
					<li>&vert;</li>
					<li>
						<div><img class="mbd-icon" src="{% static 'icons/open-folder.svg' %}" alt="dirview" title="Browse"></div>
						<ul>
							<li><a href="{% url 'events-dir' %}">Events</a></li>
							<li><a href="{% url 'repositories-dir' %}">Repositories</a></li>
							<li><a href="{% url 'builds-dir' %}">Builds</a></li>
						</ul>
					</li>
				</ul>
			</nav>

			<nav>
				<ul>
					<li>{% mbd_api "ls" %}</li>
				</ul>
			</nav>

			<nav>
				<ul>
					<li>
						<div class="{{ user.is_authenticated|yesno:'mbd-success' }}">
							{% if user.username %}
								<img class="mbd-icon" src="{% static 'icons/logged-in.svg' %}" alt="{{user.username}}" title="logged in as &quot;{{user.username}}&quot;">
							{% else %}
								<img class="mbd-icon" src="{% static 'icons/logged-off.svg' %}" alt="logged off" title="logged off">
							{% endif %}
						</div>
						<ul>
							{% if user.is_authenticated %}
								<li><a href="{% url 'logout' %}?next={{ request.path }}">Logout</a></li>
								<li><a href="{% url 'profile' %}?next={{ request.path }}">Profile</a></li>
								<li><a href="{% url 'password_change' %}?next={{ request.path }}">Change&nbsp;Password</a></li>
								<li><a href="{% url 'login' %}?next={{ request.path }}">Change&nbsp;User</a></li>
							{% else %}
								<li><a href="{% url 'login' %}?next={{ request.path }}">Login</a></li>
								<li><a href="{% url 'register' %}?next={{ request.path }}">Register</a></li>
								<li><a href="{% url 'password_reset' %}?next={{ request.path }}">Reset</a></li>
							{% endif %}
						</ul>
					</li>
					<li>&vert;</li>
					<li>{% mbd_api mbd.daemon.is_alive|yesno:"stop,start" %}</li>
					<li>&vert;</li>
					<li class="{% mbd_menu_active "setup" %} {% if mbd.daemon.report %}mbd-inspect-severity{{ mbd.daemon.report.severity }} {% endif %}">
						<a href="{{ mbd.config.URIS.setup.view.uri }}" title="𝗦𝗲𝘁𝘂𝗽&#013;&#013;{% if mbd.daemon.report %}{{ mbd.daemon.report }}{% else %}No inspection crontab run{% endif %}"><img class="mbd-icon" src="{% static 'icons/setup.svg' %}" alt="Setup"></a>
					</li>
					<li class="{% mbd_menu_active "crontab" %} {{ mbd.daemon.crontab.attention|yesno:'mbd-attention,' }}">
						<a href="{{ mbd.config.URIS.crontab.view.uri }}" title="{% if mbd.daemon.crontab.attention %}𝗖𝗿𝗼𝗻𝘁𝗮𝗯&#013;&#013;{{ mbd.daemon.crontab.attention }}{% else %}Crontab{% endif %}"><img class="mbd-icon" src="{% static 'icons/crontab.svg' %}" alt="Crontab"></a>
					</li>
					<li>&vert;</li>
					<li class="{% mbd_menu_active "api" %}">
						<a href="{{ mbd.config.URIS.api.view.uri }}" title="API"><img class="mbd-icon" src="{% static 'icons/api.svg' %}" alt="API"></a>
					</li>
					<li class="{% mbd_menu_active "manual" %}">
						<a href="{{ mbd.config.URIS.manual.view.uri }}" title="Manual"><img class="mbd-icon" src="{% static 'icons/manual.svg' %}" alt="Manual"></a>
					</li>
				</ul>
			</nav>
		</header>

		<div class="mbd-warning">
			<noscript><section><strong>JavaScript not available</strong> -- usability limited</section></noscript>
			{% if not mbd.daemon.is_alive %}
				<section>
					<strong>Daemon stopped</strong>: {% if mbd.api.MAINTENANCE_LOCK.locked %}<em class="mbd-ongoing">Maintenance ongoing</em>{% else %}Administrator may <em>start</em> or enter <em>Setup</em> for reconfiguration or bootstrap{% endif %}
				</section>
			{% endif %}
		</div>

		<main>
			{% include "mini_buildd/includes/messages.html" %}
			{% include "mini_buildd/includes/popup.html" %}

			<header class="mbd-grid-lr">
				<h1 title="{% block tooltip %}{% endblock %}">{% block title %}{% endblock %}</h1>
				<nav>
					<ul>
						{% block menu %}{% endblock %}
						{% if path %}
							<li>
								<a href="{% url name %}">
									<img class="mbd-icon" src="{% static 'icons/top.svg' %}" alt="Top">
								</a>
							</li>
							{% url name path|mbd_parent as up %}
							{% if up %}
								<li>
									<a href="{{ up }}">
										<img class="mbd-icon" src="{% static 'icons/up.svg' %}" alt="Up">
									</a>
								</li>
							{% endif %}
						{% endif %}
						{% if view.mbd_dirview %}
							{% if not view.mbd_isfile %}
								{% url route path as view_uri %}
								{% if view_uri %}
									<li>
										<a href="{{ view_uri }}">
											<img class="mbd-icon" src="{% static 'icons/html.svg' %}" alt="htmlview" title="Switch To Standard View">
										</a>
									</li>
								{% endif %}
							{% endif %}
						{% else %}
							{% url route|add:'-dir' path as dir_uri %}
							{% if dir_uri %}
								<li>
									<a href="{{ dir_uri }}">
										<img class="mbd-icon" src="{% static 'icons/folder.svg' %}" alt="dirview" title="Switch to Directory View">
									</a>
								</li>
							{% endif %}
						{% endif %}
					</ul>
				</nav>
			</header>
			<section>
				{% block content %}{% endblock %}
			</section>
		</main>

		<footer class="mbd-grid-lcr">
			<div title="{{ mbd.VERSIONS }}">{{ mbd.VERSIONS.version }}</div>
			<nav>
				<ul>
					<li title="Key id and fingerprint of instance">&raquo; <strong>{{ mbd.daemon.get_title }}</strong> ({{ mbd.daemon.gnupg.pub_key_id }})</li>
					<li>{% mbd_api "pub_key" %}</li>
					<li>{% mbd_api "sources_list" %}</li>
					<li>{% mbd_api "dput_conf" %}</li>
				</ul>
			</nav>
			<nav>
				<ul>
					<li><a href="{% url "sitemap" %}">Sitemap</a></li>
					<li><a href="{{ mbd.config.URIS.homepage.view.uri }}">Homepage➚</a></li>
				</ul>
			</nav>
		</footer>
		{# <pre>{% debug %}</pre> #}
	</body>
</html>
