From eb222716cdae2328221b36b02f95222c0a69228b Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Fri, 27 Feb 2026 10:20:07 +0100 Subject: [PATCH] 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> --- .../webgit/controller/RepoController.java | 3 +++ src/main/resources/templates/blob.html | 2 +- src/main/resources/templates/tree.html | 13 +++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/be/seeseepuff/webgit/controller/RepoController.java b/src/main/java/be/seeseepuff/webgit/controller/RepoController.java index 2609751..6503e9b 100644 --- a/src/main/java/be/seeseepuff/webgit/controller/RepoController.java +++ b/src/main/java/be/seeseepuff/webgit/controller/RepoController.java @@ -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)); diff --git a/src/main/resources/templates/blob.html b/src/main/resources/templates/blob.html index f7578f6..f51b523 100644 --- a/src/main/resources/templates/blob.html +++ b/src/main/resources/templates/blob.html @@ -9,7 +9,7 @@

< Back to commits | -< Back to tree +< Parent directory

diff --git a/src/main/resources/templates/tree.html b/src/main/resources/templates/tree.html index 47cdf2c..b140913 100644 --- a/src/main/resources/templates/tree.html +++ b/src/main/resources/templates/tree.html @@ -6,14 +6,15 @@

Browse

-

< Back to commits

- -

-Path: -
-< Parent directory +

+< Back to commits + +| < Parent directory +

+

Path:

+
Type