use of com.gitblit.extensions.RepositoryNavLinkExtension in project gitblit by gitblit.
the class RepositoryPage method registerNavLinks.
private List<NavLink> registerNavLinks() {
Repository r = getRepository();
RepositoryModel model = getRepositoryModel();
PageParameters params = null;
PageParameters objectParams = null;
if (!StringUtils.isEmpty(repositoryName)) {
params = WicketUtils.newRepositoryParameter(getRepositoryName());
objectParams = params;
// preserve the objectid iff the objectid directly (or indirectly) refers to a ref
if (isCommitPage() && !StringUtils.isEmpty(objectId)) {
RevCommit commit = JGitUtils.getCommit(r, objectId);
if (commit != null) {
String bestId = getBestCommitId(commit);
if (!commit.getName().equals(bestId)) {
objectParams = WicketUtils.newObjectParameter(getRepositoryName(), bestId);
}
}
}
}
List<NavLink> navLinks = new ArrayList<NavLink>();
// standard links
if (RefLogUtils.getRefLogBranch(r) == null) {
navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params));
} else {
navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params));
// pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));
navLinks.add(new PageNavLink("gb.reflog", ReflogPage.class, params));
}
if (!model.hasCommits) {
return navLinks;
}
navLinks.add(new PageNavLink("gb.commits", LogPage.class, objectParams));
navLinks.add(new PageNavLink("gb.tree", TreePage.class, objectParams));
if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) {
PageParameters tParams = WicketUtils.newOpenTicketsParameter(getRepositoryName());
navLinks.add(new PageNavLink("gb.tickets", TicketsPage.class, tParams));
}
navLinks.add(new PageNavLink("gb.docs", DocsPage.class, objectParams, true));
if (app().settings().getBoolean(Keys.web.allowForking, true)) {
navLinks.add(new PageNavLink("gb.forks", ForksPage.class, params, true));
}
navLinks.add(new PageNavLink("gb.compare", ComparePage.class, params, true));
// per-repository extra navlinks
if (JGitUtils.getPagesBranch(r) != null) {
ExternalNavLink pagesLink = new ExternalNavLink("gb.pages", PagesServlet.asLink(getRequest().getRelativePathPrefixToContextRoot(), getRepositoryName(), null), true);
navLinks.add(pagesLink);
}
UserModel user = UserModel.ANONYMOUS;
if (GitBlitWebSession.get().isLoggedIn()) {
user = GitBlitWebSession.get().getUser();
}
// add repository nav link extensions
List<RepositoryNavLinkExtension> extensions = app().plugins().getExtensions(RepositoryNavLinkExtension.class);
for (RepositoryNavLinkExtension ext : extensions) {
navLinks.addAll(ext.getNavLinks(user, model));
}
return navLinks;
}
Aggregations