| | |
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | | import org.apache.wicket.model.IModel;
|
| | | import org.apache.wicket.model.Model;
|
| | | import org.apache.wicket.protocol.http.RequestUtils;
|
| | | import org.apache.wicket.request.target.basic.RedirectRequestTarget;
|
| | | import org.eclipse.jgit.diff.DiffEntry.ChangeType;
|
| | | import org.eclipse.jgit.lib.PersonIdent;
|
| | |
| | |
|
| | | public abstract class RepositoryPage extends RootPage {
|
| | |
|
| | | private final Logger logger = LoggerFactory.getLogger(getClass());
|
| | | protected final Logger logger = LoggerFactory.getLogger(getClass());
|
| | |
|
| | | private final String PARAM_STAR = "star";
|
| | |
|
| | |
| | |
|
| | | // conditional links
|
| | | // per-repository extra page links
|
| | | if (model.showReadme || model.useDocs) {
|
| | | if (model.useDocs) {
|
| | | pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
|
| | | }
|
| | | if (JGitUtils.getPagesBranch(r) != null) {
|
| | |
| | | }
|
| | | getSubmodules(commit);
|
| | | return commit;
|
| | | }
|
| | |
|
| | | protected String getBestCommitId(RevCommit commit) {
|
| | | String head = null;
|
| | | try {
|
| | | head = r.resolve(getRepositoryModel().HEAD).getName();
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | String id = commit.getName();
|
| | | if (!StringUtils.isEmpty(head) && head.equals(id)) {
|
| | | // match default branch
|
| | | return Repository.shortenRefName(getRepositoryModel().HEAD);
|
| | | }
|
| | |
|
| | | // find first branch match
|
| | | for (RefModel ref : JGitUtils.getLocalBranches(r, false, -1)) {
|
| | | if (ref.getObjectId().getName().equals(id)) {
|
| | | return ref.getName();
|
| | | }
|
| | | }
|
| | |
|
| | | // return sha
|
| | | return id;
|
| | | }
|
| | |
|
| | | protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) {
|
| | |
| | | String searchString = searchBoxModel.getObject();
|
| | | if (StringUtils.isEmpty(searchString)) {
|
| | | // redirect to self to avoid wicket page update bug
|
| | | PageParameters params = RepositoryPage.this.getPageParameters();
|
| | | String relativeUrl = urlFor(RepositoryPage.this.getClass(), params).toString();
|
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
|
| | | String absoluteUrl = getCanonicalUrl();
|
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | return;
|
| | | }
|
| | |
| | | // use an absolute url to workaround Wicket-Tomcat problems with
|
| | | // mounted url parameters (issue-111)
|
| | | PageParameters params = WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType);
|
| | | String relativeUrl = urlFor(searchPageClass, params).toString();
|
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
|
| | | String absoluteUrl = getCanonicalUrl(searchPageClass, params);
|
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | }
|
| | | }
|