diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-23 11:18:40 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-23 11:18:40 -0400 |
commit | ddaed96036ebf82430e09ad62ff9f7a7dc828dfe (patch) | |
tree | eef3dccc5b9588b59178f641295f654e60016be3 /src | |
parent | 67278f5d0cd5ffec4d0a1517f2b2077ab2cbf7d4 (diff) | |
download | gitblit-ddaed96036ebf82430e09ad62ff9f7a7dc828dfe.tar.gz gitblit-ddaed96036ebf82430e09ad62ff9f7a7dc828dfe.zip |
Fix subdirectory links in pages servlet (issue-411)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/servlet/PagesServlet.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/servlet/PagesServlet.java b/src/main/java/com/gitblit/servlet/PagesServlet.java index 74c1cb2d..5124b8ca 100644 --- a/src/main/java/com/gitblit/servlet/PagesServlet.java +++ b/src/main/java/com/gitblit/servlet/PagesServlet.java @@ -28,6 +28,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTree;
@@ -228,11 +229,17 @@ 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}\">{0}</a></td><td>{1}</td><td>{2}</td></tr>";
+ String pattern = "<tr><td><a href=\"{0}\">{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()) {
+ if (entries.get(0).path.indexOf('/') > -1) {
+ // we are in a subdirectory, add parent directory link
+ entries.add(0, new PathModel("..", resource + "/..", 0, FileMode.TREE.getBits(), null, null));
+ }
+ }
for (PathModel entry : entries) {
- response.getWriter().append(MessageFormat.format(pattern, entry.name, JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));
+ response.getWriter().append(MessageFormat.format(pattern, entry.path, entry.name, JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));
}
response.getWriter().append("</tbody>");
response.getWriter().append("</table>");
|