<!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 class="{% mbd_menu_active "home" %}">
						<a href="{% url 'home' %}">
							<img class="mbd-icon" src="{% static '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/places/folder.svg' %}" alt="dirview" title="Browse">&nbsp;▼</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,mbd-dim' }}">{{ user.username|default:"Logged Off" }}&nbsp;▼</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-severity{{ mbd.daemon.report.severity }} {% endif %}">
						<a href="{{ mbd.config.URIS.setup.view.uri }}" title="{% if mbd.daemon.report %}{{ mbd.daemon.report }}{% else %}No setup inspection run yet{% endif %}">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="{{ mbd.daemon.crontab.attention }}">Crontab</a>
					</li>
					<li class="{% mbd_menu_active "log" %}">
						<a href="{{ mbd.config.URIS.log.view.uri }}" title="">Log</a>
					</li>
					<li>&vert;</li>
					<li class="{% mbd_menu_active "api" %}">
						<a href="{{ mbd.config.URIS.api.view.uri }}" title="">Api</a>
					</li>
					<li class="{% mbd_menu_active "manual" %}">
						<a href="{{ mbd.config.URIS.manual.view.uri }}" title="">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/actions/go-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/actions/go-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/mimetypes/text-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/places/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>
