<!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>
				<div class="mbd-tooltip"></div>
				<ul>
					<li>{% mbd_api "search" popup=False %}</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' %}">Logout</a></li>
								<li><a href="{% url 'profile' %}">Profile</a></li>
								<li><a href="{% url 'password_change' %}">Change&nbsp;Password</a></li>
								<li><a href="{% url 'login' %}?next={{ request.get_full_path|urlencode }}">Change&nbsp;User</a></li>
							{% else %}
								<li><a href="{% url 'login' %}?next={{ request.get_full_path|urlencode }}">Login</a></li>
								<li><a href="{% url 'register' %}">Register</a></li>
								<li><a href="{% url 'password_reset' %}">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 yet{% 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 %}
					</ul>
					{% url route path as view_uri %}
					<ul class="mbd-browse-buttons{% if view.mbd_dirview or not view.mbd_dirview and view_uri|slice:":26" != "/mini_buildd/repositories/" %} move{% endif %}{% if view.mbd_isfile %} file{% endif %}">
						{% if view.mbd_dirview %}
							{% if not view.mbd_isfile %}
								{% if view_uri %}
									<li>
										<a class="mbd-icon" href="{{ view_uri }}">
											<img class="mbd-icon" src="{% static 'icons/list-view.svg' %}" alt="listview" title="List View">
										</a>
									</li>
								{% endif %}
							{% else %}
								<li class="mbd-back-button">
									<img class="mbd-icon" src="{% static 'icons/back.svg' %}" alt="Back">
								</li>
							{% endif %}
						{% else %}
							{% url route|add:'-dir' path as dir_uri %}
							{% if dir_uri %}
								<li>
									<a class="mbd-icon" href="{{ dir_uri }}">
										<img class="mbd-icon" src="{% static 'icons/browse-directory-view.svg' %}" alt="dirview" title="Browse directory">
									</a>
								</li>
							{% endif %}
						{% endif %}
						{% if path %}
							<li>
								<a class="mbd-icon" 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 class="mbd-icon" href="{{ up }}">
										<img class="mbd-icon" src="{% static 'icons/up.svg' %}" alt="Up">
									</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>
					<li>{% mbd_api "ls" %}</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>
