Add web controllers and HTML templates

Home page lists repositories with clone form. Repo page shows
branch management, file staging, commit, push and pull controls.
Table-based layout with no JavaScript or CSS for retro browser
compatibility. Includes MockMvc integration tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-26 08:43:15 +01:00
parent 239b5367a3
commit 88385d39a1
6 changed files with 433 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="'WebGit - ' + ${name}">WebGit - repo</title>
</head>
<body>
<h1><a href="/">WebGit</a></h1>
<h2 th:text="${name}">repo</h2>
<h3>Branch</h3>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td>Current branch:</td>
<td><b th:text="${currentBranch}"></b></td>
</tr>
</table>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td>
<form method="post" th:action="@{/repo/{name}/checkout(name=${name})}">
Switch to:
<select name="branch">
<option th:each="b : ${branches}" th:value="${b}" th:text="${b}" th:selected="${b == currentBranch}"></option>
</select>
<input type="submit" value="Checkout">
</form>
</td>
<td>
<form method="post" th:action="@{/repo/{name}/new-branch(name=${name})}">
New branch: <input type="text" name="branch" size="20">
<input type="submit" value="Create">
</form>
</td>
</tr>
</table>
<hr>
<h3>Modified Files (unstaged)</h3>
<form method="post" th:action="@{/repo/{name}/stage(name=${name})}" th:if="${!#lists.isEmpty(modifiedFiles)}">
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th>Stage</th>
<th>File</th>
</tr>
<tr th:each="file : ${modifiedFiles}">
<td><input type="checkbox" name="files" th:value="${file}"></td>
<td th:text="${file}"></td>
</tr>
</table>
<br>
<input type="submit" value="Stage Selected">
</form>
<p th:if="${#lists.isEmpty(modifiedFiles)}"><i>No modified files.</i></p>
<h3>Staged Files</h3>
<table border="1" cellpadding="4" cellspacing="0" th:if="${!#lists.isEmpty(stagedFiles)}">
<tr>
<th>File</th>
</tr>
<tr th:each="file : ${stagedFiles}">
<td th:text="${file}"></td>
</tr>
</table>
<p th:if="${#lists.isEmpty(stagedFiles)}"><i>No staged files.</i></p>
<form method="post" th:action="@{/repo/{name}/commit(name=${name})}" th:if="${!#lists.isEmpty(stagedFiles)}">
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td>Commit message:</td>
<td><input type="text" name="message" size="60"></td>
<td><input type="submit" value="Commit"></td>
</tr>
</table>
</form>
<hr>
<h3>Remote</h3>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td>
<form method="post" th:action="@{/repo/{name}/push(name=${name})}">
<input type="submit" value="Push">
</form>
</td>
<td>
<form method="post" th:action="@{/repo/{name}/pull(name=${name})}">
<input type="submit" value="Pull">
</form>
</td>
</tr>
</table>
</body>
</html>