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:
@@ -114,6 +114,7 @@ public class RepoController
|
|||||||
model.addAttribute("hash", hash);
|
model.addAttribute("hash", hash);
|
||||||
model.addAttribute("shortHash", hash.substring(0, Math.min(7, hash.length())));
|
model.addAttribute("shortHash", hash.substring(0, Math.min(7, hash.length())));
|
||||||
model.addAttribute("path", path);
|
model.addAttribute("path", path);
|
||||||
|
model.addAttribute("parentPath", path.contains("/") ? path.substring(0, path.lastIndexOf('/')) : "");
|
||||||
model.addAttribute("files", gitService.listFilesAtCommit(name, hash, path));
|
model.addAttribute("files", gitService.listFilesAtCommit(name, hash, path));
|
||||||
return "tree";
|
return "tree";
|
||||||
}
|
}
|
||||||
@@ -127,9 +128,11 @@ public class RepoController
|
|||||||
String filePath = fullPath.substring(prefix.length());
|
String filePath = fullPath.substring(prefix.length());
|
||||||
String ext = filePath.contains(".") ? filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase() : "";
|
String ext = filePath.contains(".") ? filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase() : "";
|
||||||
boolean isImage = IMAGE_EXTENSIONS.contains(ext);
|
boolean isImage = IMAGE_EXTENSIONS.contains(ext);
|
||||||
|
String parentPath = filePath.contains("/") ? filePath.substring(0, filePath.lastIndexOf('/')) : "";
|
||||||
model.addAttribute("name", name);
|
model.addAttribute("name", name);
|
||||||
model.addAttribute("hash", hash);
|
model.addAttribute("hash", hash);
|
||||||
model.addAttribute("filePath", filePath);
|
model.addAttribute("filePath", filePath);
|
||||||
|
model.addAttribute("parentPath", parentPath);
|
||||||
model.addAttribute("isImage", isImage);
|
model.addAttribute("isImage", isImage);
|
||||||
if (!isImage)
|
if (!isImage)
|
||||||
model.addAttribute("content", gitService.getFileContentAtCommit(name, hash, filePath));
|
model.addAttribute("content", gitService.getFileContentAtCommit(name, hash, filePath));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<a th:href="@{/repo/{name}/commits(name=${name})}">< Back to commits</a>
|
<a th:href="@{/repo/{name}/commits(name=${name})}">< Back to commits</a>
|
||||||
|
|
|
|
||||||
<a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash})}">< Back to tree</a>
|
<a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash}, path=${parentPath})}">< Parent directory</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table border="0" cellpadding="4" cellspacing="0">
|
<table border="0" cellpadding="4" cellspacing="0">
|
||||||
|
|||||||
@@ -6,14 +6,15 @@
|
|||||||
<body>
|
<body>
|
||||||
<h2>Browse <span th:text="${shortHash}"></span></h2>
|
<h2>Browse <span th:text="${shortHash}"></span></h2>
|
||||||
|
|
||||||
<p><a th:href="@{/repo/{name}/commits(name=${name})}">< Back to commits</a></p>
|
<p>
|
||||||
|
<a th:href="@{/repo/{name}/commits(name=${name})}">< Back to commits</a>
|
||||||
<p th:if="${!path.isEmpty()}">
|
<span th:if="${!path.isEmpty()}">
|
||||||
Path: <b th:text="${path}"></b>
|
| <a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash}, path=${parentPath})}">< Parent directory</a>
|
||||||
<br>
|
</span>
|
||||||
<a th:href="@{/repo/{name}/tree/{hash}(name=${name}, hash=${hash}, path=${path.contains('/') ? path.substring(0, path.lastIndexOf('/')) : ''})}">< Parent directory</a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p th:if="${!path.isEmpty()}">Path: <b th:text="${path}"></b></p>
|
||||||
|
|
||||||
<table border="1" cellpadding="4" cellspacing="0">
|
<table border="1" cellpadding="4" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user