diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-23 12:06:59 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-23 12:06:59 -0400 |
commit | 1cfce55191f8ae63b1830892fc0883506fd8507d (patch) | |
tree | 63174f9e2a3aceb6de6bd1141f546b4368c70ce6 | |
parent | ddaed96036ebf82430e09ad62ff9f7a7dc828dfe (diff) | |
download | gitblit-1cfce55191f8ae63b1830892fc0883506fd8507d.tar.gz gitblit-1cfce55191f8ae63b1830892fc0883506fd8507d.zip |
Improve pages servlet raw navigation (issue-411)
-rw-r--r-- | src/main/java/com/gitblit/servlet/PagesServlet.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/servlet/PagesServlet.java b/src/main/java/com/gitblit/servlet/PagesServlet.java index 5124b8ca..f4e8bb23 100644 --- a/src/main/java/com/gitblit/servlet/PagesServlet.java +++ b/src/main/java/com/gitblit/servlet/PagesServlet.java @@ -111,6 +111,10 @@ public class PagesServlet extends DaggerServlet { // strip leading /
path = path.substring(1);
}
+ if (path.charAt(path.length() - 1) == '/') {
+ // strip trailing slash
+ path = path.substring(0, path.length() - 1);
+ }
// determine repository and resource from url
String repository = "";
@@ -229,7 +233,7 @@ public class PagesServlet extends DaggerServlet { response.getWriter().append("<thead><tr><th>path</th><th>mode</th><th>size</th></tr>");
response.getWriter().append("</thead>");
response.getWriter().append("<tbody>");
- String pattern = "<tr><td><a href=\"{0}\">{1}</a></td><td>{2}</td><td>{3}</td></tr>";
+ String pattern = "<tr><td><a href=\"{0}/{1}\">{1}</a></td><td>{2}</td><td>{3}</td></tr>";
final ByteFormat byteFormat = new ByteFormat();
List<PathModel> entries = JGitUtils.getFilesInPath(r, resource, commit);
if (!entries.isEmpty()) {
@@ -238,8 +242,15 @@ public class PagesServlet extends DaggerServlet { entries.add(0, new PathModel("..", resource + "/..", 0, FileMode.TREE.getBits(), null, null));
}
}
+
+ String basePath = request.getServletPath() + request.getPathInfo();
+ if (basePath.charAt(basePath.length() - 1) == '/') {
+ // strip trailing slash
+ basePath = basePath.substring(0, basePath.length() - 1);
+ }
for (PathModel entry : entries) {
- response.getWriter().append(MessageFormat.format(pattern, entry.path, entry.name, JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));
+ response.getWriter().append(MessageFormat.format(pattern, basePath, entry.name,
+ JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));
}
response.getWriter().append("</tbody>");
response.getWriter().append("</table>");
|