| | |
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.html.form.DropDownChoice;
|
| | | import org.apache.wicket.markup.html.form.StatelessForm;
|
| | | import org.apache.wicket.markup.html.form.TextField;
|
| | | import org.apache.wicket.markup.html.link.ExternalLink;
|
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | |
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.PagesServlet;
|
| | | import com.gitblit.SyndicationServlet;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.TicgitUtils;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.PageRegistration;
|
| | | import com.gitblit.wicket.PageRegistration.OtherPageLink;
|
| | | import com.gitblit.wicket.SessionlessForm;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.NavigationPanel;
|
| | |
| | | objectId = WicketUtils.getObject(params);
|
| | |
|
| | | if (StringUtils.isEmpty(repositoryName)) {
|
| | | error(MessageFormat.format("Repository not specified for {0}!", getPageName()), true);
|
| | | error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true);
|
| | | }
|
| | |
|
| | | if (!getRepositoryModel().hasCommits) {
|
| | | setResponsePage(EmptyRepositoryPage.class, params);
|
| | | }
|
| | |
|
| | | // register the available page links for this page and user
|
| | |
| | | if (model.useDocs) {
|
| | | pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params));
|
| | | }
|
| | | if (JGitUtils.getPagesBranch(r) != null) {
|
| | | OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink(
|
| | | getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null));
|
| | | pages.put("pages", pagesLink);
|
| | | }
|
| | |
|
| | | // Conditionally add edit link
|
| | | final boolean showAdmin;
|
| | | if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {
|
| | |
| | |
|
| | | @Override
|
| | | protected void setupPage(String repositoryName, String pageName) {
|
| | | add(new LinkPanel("repositoryName", null, repositoryName, SummaryPage.class,
|
| | | WicketUtils.newRepositoryParameter(repositoryName)));
|
| | | add(new Label("pageName", pageName));
|
| | | add(new LinkPanel("repositoryName", null, StringUtils.stripDotGit(repositoryName),
|
| | | SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
|
| | | add(new Label("pageName", pageName).setRenderBodyOnly(true));
|
| | | if (getRepositoryModel().isBare) {
|
| | | add(new Label("workingCopy").setVisible(false));
|
| | | } else {
|
| | | Fragment fragment = new Fragment("workingCopy", "workingCopyFragment", this);
|
| | | Label lbl = new Label("workingCopy", getString("gb.workingCopy"));
|
| | | WicketUtils.setHtmlTooltip(lbl, getString("gb.workingCopyWarning"));
|
| | | fragment.add(lbl);
|
| | | add(fragment);
|
| | | }
|
| | |
|
| | | super.setupPage(repositoryName, pageName);
|
| | | }
|
| | |
| | | if (r == null) {
|
| | | Repository r = GitBlit.self().getRepository(repositoryName);
|
| | | if (r == null) {
|
| | | error("Can not load repository " + repositoryName, true);
|
| | | error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);
|
| | | return null;
|
| | | }
|
| | | this.r = r;
|
| | |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel(
|
| | | GitBlitWebSession.get().getUser(), repositoryName);
|
| | | if (model == null) {
|
| | | authenticationError("Unauthorized access for repository " + repositoryName);
|
| | | authenticationError(getString("gb.unauthorizedAccessForRepository") + " " + repositoryName);
|
| | | return null;
|
| | | }
|
| | | m = model;
|
| | |
| | | protected RevCommit getCommit() {
|
| | | RevCommit commit = JGitUtils.getCommit(r, objectId);
|
| | | if (commit == null) {
|
| | | error(MessageFormat.format("Failed to find commit \"{0}\" in {1} for {2} page!",
|
| | | error(MessageFormat.format(getString("gb.failedToFindCommit"),
|
| | | objectId, repositoryName, getPageName()), true);
|
| | | }
|
| | | return commit;
|
| | |
| | | }
|
| | |
|
| | | protected void addFullText(String wicketId, String text, boolean substituteRegex) {
|
| | | String html;
|
| | | String html = StringUtils.escapeForHtml(text, true);
|
| | | if (substituteRegex) {
|
| | | html = GitBlit.self().processCommitMessage(repositoryName, text);
|
| | | } else {
|
| | | html = StringUtils.breakLinesForHtml(text);
|
| | | html = StringUtils.breakLinesForHtml(html);
|
| | | }
|
| | | add(new Label(wicketId, html).setEscapeModelStrings(false));
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | | Fragment partial = new Fragment(wicketId, "partialPersonIdent", this);
|
| | | LinkPanel link = new LinkPanel("personName", "list", value, SearchPage.class,
|
| | | LinkPanel link = new LinkPanel("personName", "list", value, GitSearchPage.class,
|
| | | WicketUtils.newSearchParameter(repositoryName, objectId, value, searchType));
|
| | | setPersonSearchTooltip(link, value, searchType);
|
| | | partial.add(link);
|
| | | return partial;
|
| | | } else {
|
| | | Fragment fullPerson = new Fragment(wicketId, "fullPersonIdent", this);
|
| | | LinkPanel nameLink = new LinkPanel("personName", "list", name, SearchPage.class,
|
| | | LinkPanel nameLink = new LinkPanel("personName", "list", name, GitSearchPage.class,
|
| | | WicketUtils.newSearchParameter(repositoryName, objectId, name, searchType));
|
| | | setPersonSearchTooltip(nameLink, name, searchType);
|
| | | fullPerson.add(nameLink);
|
| | |
|
| | | LinkPanel addressLink = new LinkPanel("personAddress", "list", "<" + address + ">",
|
| | | SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,
|
| | | LinkPanel addressLink = new LinkPanel("personAddress", "hidden-phone list", "<" + address + ">",
|
| | | GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId,
|
| | | address, searchType));
|
| | | setPersonSearchTooltip(addressLink, address, searchType);
|
| | | fullPerson.add(addressLink);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {
|
| | | protected void setPersonSearchTooltip(Component component, String value,
|
| | | Constants.SearchType searchType) {
|
| | | if (searchType.equals(Constants.SearchType.AUTHOR)) {
|
| | | WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);
|
| | | } else if (searchType.equals(Constants.SearchType.COMMITTER)) {
|
| | |
| | | return WicketUtils.newObjectParameter(repositoryName, commitId);
|
| | | }
|
| | |
|
| | | private static class SearchForm extends StatelessForm<Void> implements Serializable {
|
| | | private class SearchForm extends SessionlessForm<Void> implements Serializable {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | private final String repositoryName;
|
| | |
|
| | | private final IModel<String> searchBoxModel = new Model<String>("");
|
| | |
|
| | | private final IModel<Constants.SearchType> searchTypeModel = new Model<Constants.SearchType>(Constants.SearchType.COMMIT);
|
| | | private final IModel<Constants.SearchType> searchTypeModel = new Model<Constants.SearchType>(
|
| | | Constants.SearchType.COMMIT);
|
| | |
|
| | | public SearchForm(String id, String repositoryName) {
|
| | | super(id);
|
| | | super(id, RepositoryPage.this.getClass(), RepositoryPage.this.getPageParameters());
|
| | | this.repositoryName = repositoryName;
|
| | | DropDownChoice<Constants.SearchType> searchType = new DropDownChoice<Constants.SearchType>("searchType",
|
| | | Arrays.asList(Constants.SearchType.values()));
|
| | | DropDownChoice<Constants.SearchType> searchType = new DropDownChoice<Constants.SearchType>(
|
| | | "searchType", Arrays.asList(Constants.SearchType.values()));
|
| | | searchType.setModel(searchTypeModel);
|
| | | add(searchType.setVisible(GitBlit.getBoolean(Keys.web.showSearchTypeSelection, false)));
|
| | | TextField<String> searchBox = new TextField<String>("searchBox", searchBoxModel);
|
| | |
| | | Constants.SearchType searchType = searchTypeModel.getObject();
|
| | | String searchString = searchBoxModel.getObject();
|
| | | if (searchString == null) {
|
| | | // FIXME IE intermittently has no searchString. Wicket bug?
|
| | | return;
|
| | | }
|
| | | for (Constants.SearchType type : Constants.SearchType.values()) {
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | setResponsePage(SearchPage.class,
|
| | | Class<? extends BasePage> searchPageClass = GitSearchPage.class;
|
| | | RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);
|
| | | if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)
|
| | | && !ArrayUtils.isEmpty(model.indexedBranches)) {
|
| | | // this repository is Lucene-indexed
|
| | | searchPageClass = LuceneSearchPage.class;
|
| | | }
|
| | | setResponsePage(searchPageClass,
|
| | | WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType));
|
| | | }
|
| | | }
|