<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:fragment="head(title)">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title th:text="${#strings.isEmpty(repoName)} ? ${title} + ' — Werkator' : ${title} + ' — ' + ${repoName} + ' — Werkator'">Werkator</title>
    <link rel="icon" href="/favicon.svg" type="image/svg+xml">
    <link rel="stylesheet" href="/werkator.css">
    <meta name="werkator-gitea-repo-url" th:content="${giteaRepoUrl}">
    <!-- Empty with one served repository, `/repos/<name>` with several: werkator.js
         builds its action and artifact URLs from it, so a page stays in its repository. -->
    <meta name="werkator-repo-base" th:content="${repoBase}">
</head>
<body>

<h1 th:fragment="header(title)">
    <a class="title-home" th:href="${homeUrl}" href="/" aria-label="Open latest builds"><img src="/favicon.svg" alt=""></a>
    <span class="title-text" th:text="${title}">Latest Builds</span>
    <!-- The repository switcher (ADR 0009): what makes several repositories one UI. It sits
         where the repository name sits, because it *is* the repository name — the page's
         subject, not a navigation target. Its option values are the repository roots;
         werkator.js appends the current view, so switching keeps the reader on the same page.
         With a single served repository there is nothing to switch, and the name is plain text. -->
    <select th:if="${multiRepo}" id="repo-select" class="repo-select" aria-label="Repository">
        <option th:each="r : ${repos}" th:value="${r.url}" th:selected="${r.current}" th:text="${r.name}">werkator</option>
    </select>
    <span class="repo-name" th:unless="${multiRepo} or ${#strings.isEmpty(repoName)}" th:text="${repoName}">owner/repo</span>
</h1>

<th:block th:fragment="nav(view)">
<div class="view-row">
    <nav class="view-toggle">
        <span th:if="${view == 'latest'}">Latest</span>
        <a th:unless="${view == 'latest'}" th:href="${homeUrl}" href="/">Latest</a>
        <span th:if="${view == 'branches'}">Branches</span>
        <a th:unless="${view == 'branches'}" th:href="${repoBase} + '/branches'" href="/branches">Branches</a>
        <span th:if="${view == 'history'}">History</span>
        <a th:unless="${view == 'history'}" th:href="${repoBase} + '/history'" href="/history">History</a>
        <span th:if="${view == 'current'}">Current</span>
        <span th:if="${view == 'system'}">System</span>
        <a th:unless="${view == 'system'}" href="/system">System</a>
    </nav>
    <span class="view-row-actions">
        <span id="live-indicator" class="status status-unknown" title="live-update state">static</span>
        <button id="reload-button" class="reload-button" type="button" title="Reload view" aria-label="Reload view">⟳</button>
    </span>
</div>
<!-- Filled by werkator.js from /api/watcher: while the watcher cannot reach origin, every
     row below is as old as its last successful poll, and a calm list would imply otherwise. -->
<div id="watcher-banner" class="watcher-banner" role="status" hidden></div>
</th:block>

<footer th:fragment="footer" class="site-footer">
    <strong><a href="/releases" title="Release notes"><em th:text="'Werkator v' + ${version}">Werkator</em></a></strong>
    — © <a href="https://michael.hoennig.de" target="_blank" rel="noopener noreferrer">Michael Hönnig</a>, 2026
    <th:block th:unless="${#strings.isEmpty(impressumUrl)}">
        — <a th:href="${impressumUrl}" target="_blank" rel="noopener noreferrer">Impressum (Legal Disclosure)</a>
    </th:block>
</footer>

</body>
</html>
