mount("/mytickets", MyTicketsPage.class, "r", "h");
// setup the markup document urls
- mount("/docs", DocsPage.class, "r");
+ mount("/docs", DocsPage.class, "r", "h");
mount("/doc", DocPage.class, "r", "h", "f");
// federation urls
public DocsPage(PageParameters params) {\r
super(params);\r
\r
+ String objectId = WicketUtils.getObject(params);\r
+\r
MarkupProcessor processor = new MarkupProcessor(app().settings(), app().xssFilter());\r
\r
Repository r = getRepository();\r
- RevCommit head = JGitUtils.getCommit(r, null);\r
+ RevCommit head = JGitUtils.getCommit(r, objectId);\r
final String commitId = getBestCommitId(head);\r
+\r
List<String> extensions = processor.getAllExtensions();\r
List<PathModel> paths = JGitUtils.getDocuments(r, extensions);\r
\r
}\r
\r
// document list\r
- final String id = getBestCommitId(head);\r
final ByteFormat byteFormat = new ByteFormat();\r
Fragment docs = new Fragment("documents", "documentsFragment", this);\r
ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);\r
item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));\r
item.add(new Label("docSize", byteFormat.format(entry.size)));\r
item.add(new LinkPanel("docName", "list", StringUtils.stripFileExtension(entry.name),\r
- DocPage.class, WicketUtils.newPathParameter(repositoryName, id, entry.path)));\r
+ DocPage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path)));\r
\r
// links\r
item.add(new BookmarkablePageLink<Void>("view", DocPage.class, WicketUtils\r
- .newPathParameter(repositoryName, id, entry.path)));\r
- String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, id, entry.path);\r
+ .newPathParameter(repositoryName, commitId, entry.path)));\r
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, commitId, entry.path);\r
item.add(new ExternalLink("raw", rawUrl));\r
item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils\r
- .newPathParameter(repositoryName, id, entry.path)));\r
+ .newPathParameter(repositoryName, commitId, entry.path)));\r
item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils\r
- .newPathParameter(repositoryName, id, entry.path)));\r
+ .newPathParameter(repositoryName, commitId, entry.path)));\r
WicketUtils.setAlternatingBackground(item, counter);\r
counter++;\r
}\r
}\r
\r
private List<NavLink> registerNavLinks() {\r
+ Repository r = getRepository();\r
+ RepositoryModel model = getRepositoryModel();\r
+\r
PageParameters params = null;\r
+ PageParameters objectParams = null;\r
if (!StringUtils.isEmpty(repositoryName)) {\r
params = WicketUtils.newRepositoryParameter(getRepositoryName());\r
+ objectParams = params;\r
+\r
+ // preserve the objectid iff the objectid directly (or indirectly) refers to a ref\r
+ if (!StringUtils.isEmpty(objectId)) {\r
+ RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ String bestId = getBestCommitId(commit);\r
+ if (!commit.getName().equals(bestId)) {\r
+ objectParams = WicketUtils.newObjectParameter(getRepositoryName(), bestId);\r
+ }\r
+ }\r
}\r
List<NavLink> navLinks = new ArrayList<NavLink>();\r
\r
- Repository r = getRepository();\r
- RepositoryModel model = getRepositoryModel();\r
\r
// standard links\r
if (RefLogUtils.getRefLogBranch(r) == null) {\r
return navLinks;\r
}\r
\r
- navLinks.add(new PageNavLink("gb.commits", LogPage.class, params));\r
- navLinks.add(new PageNavLink("gb.tree", TreePage.class, params));\r
+ navLinks.add(new PageNavLink("gb.commits", LogPage.class, objectParams));\r
+ navLinks.add(new PageNavLink("gb.tree", TreePage.class, objectParams));\r
if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) {\r
PageParameters tParams = WicketUtils.newOpenTicketsParameter(getRepositoryName());\r
navLinks.add(new PageNavLink("gb.tickets", TicketsPage.class, tParams));
}
- navLinks.add(new PageNavLink("gb.docs", DocsPage.class, params, true));\r
+ navLinks.add(new PageNavLink("gb.docs", DocsPage.class, objectParams, true));\r
if (app().settings().getBoolean(Keys.web.allowForking, true)) {\r
navLinks.add(new PageNavLink("gb.forks", ForksPage.class, params, true));\r
}\r
// find first branch match\r
for (RefModel ref : JGitUtils.getLocalBranches(r, false, -1)) {\r
if (ref.getObjectId().getName().equals(id)) {\r
- return ref.getName();\r
+ return Repository.shortenRefName(ref.getName());\r
}\r
}\r
\r