Move parent directory link inline with back to commits

Both tree.html and blob.html now show '< Parent directory' on the
same line as '< Back to commits', separated by '|'. In blob view,
parent directory navigates to the containing directory tree.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-27 10:20:07 +01:00
parent d68933bc2f
commit eb222716cd
3 changed files with 11 additions and 7 deletions

View File

@@ -114,6 +114,7 @@ public class RepoController
model.addAttribute("hash", hash);
model.addAttribute("shortHash", hash.substring(0, Math.min(7, hash.length())));
model.addAttribute("path", path);
model.addAttribute("parentPath", path.contains("/") ? path.substring(0, path.lastIndexOf('/')) : "");
model.addAttribute("files", gitService.listFilesAtCommit(name, hash, path));
return "tree";
}
@@ -127,9 +128,11 @@ public class RepoController
String filePath = fullPath.substring(prefix.length());
String ext = filePath.contains(".") ? filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase() : "";
boolean isImage = IMAGE_EXTENSIONS.contains(ext);
String parentPath = filePath.contains("/") ? filePath.substring(0, filePath.lastIndexOf('/')) : "";
model.addAttribute("name", name);
model.addAttribute("hash", hash);
model.addAttribute("filePath", filePath);
model.addAttribute("parentPath", parentPath);
model.addAttribute("isImage", isImage);
if (!isImage)
model.addAttribute("content", gitService.getFileContentAtCommit(name, hash, filePath));

View File

@@ -9,7 +9,7 @@
<p>
<a th:href="@{/repo/{name}/commits(name=${name})}">&lt; Back to commits</a>
|
<a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash})}">&lt; Back to tree</a>
<a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash}, path=${parentPath})}">&lt; Parent directory</a>
</p>
<table border="0" cellpadding="4" cellspacing="0">

View File

@@ -6,14 +6,15 @@
<body>
<h2>Browse <span th:text="${shortHash}"></span></h2>
<p><a th:href="@{/repo/{name}/commits(name=${name})}">&lt; Back to commits</a></p>
<p th:if="${!path.isEmpty()}">
Path: <b th:text="${path}"></b>
<br>
<a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash}, path=${path.contains('/') ? path.substring(0, path.lastIndexOf('/')) : ''})}">&lt; Parent directory</a>
<p>
<a th:href="@{/repo/{name}/commits(name=${name})}">&lt; Back to commits</a>
<span th:if="${!path.isEmpty()}">
| <a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash}, path=${parentPath})}">&lt; Parent directory</a>
</span>
</p>
<p th:if="${!path.isEmpty()}">Path: <b th:text="${path}"></b></p>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th>Type</th>