| | |
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.RefLogUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.TicgitUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.PageRegistration;
|
| | |
| | | import com.gitblit.wicket.panels.RefsPanel;
|
| | |
|
| | | public abstract class RepositoryPage extends RootPage {
|
| | | |
| | |
|
| | | private final Logger logger = LoggerFactory.getLogger(getClass());
|
| | |
|
| | | private final String PARAM_STAR = "star";
|
| | | |
| | |
|
| | | protected final String projectName;
|
| | | protected final String repositoryName;
|
| | | protected final String objectId;
|
| | | |
| | |
|
| | | private transient Repository r;
|
| | |
|
| | | private RepositoryModel m;
|
| | |
|
| | | private Map<String, SubmoduleModel> submodules;
|
| | | |
| | |
|
| | | private final Map<String, PageRegistration> registeredPages;
|
| | | private boolean showAdmin;
|
| | | private boolean isOwner;
|
| | | |
| | |
|
| | | public RepositoryPage(PageParameters params) {
|
| | | super(params);
|
| | | repositoryName = WicketUtils.getRepositoryName(params);
|
| | |
| | | projectName = root;
|
| | | }
|
| | | objectId = WicketUtils.getObject(params);
|
| | | |
| | |
|
| | | if (StringUtils.isEmpty(repositoryName)) {
|
| | | error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true);
|
| | | }
|
| | |
| | | if (!getRepositoryModel().hasCommits) {
|
| | | setResponsePage(EmptyRepositoryPage.class, params);
|
| | | }
|
| | | |
| | |
|
| | | if (getRepositoryModel().isCollectingGarbage) {
|
| | | error(MessageFormat.format(getString("gb.busyCollectingGarbage"), getRepositoryModel().name), true);
|
| | | }
|
| | | |
| | |
|
| | | if (objectId != null) {
|
| | | RefModel branch = null;
|
| | | if ((branch = JGitUtils.getBranch(getRepository(), objectId)) != null) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (params.containsKey(PARAM_STAR)) {
|
| | | // set starred state
|
| | | boolean star = params.getBoolean(PARAM_STAR);
|
| | |
| | | // set stateless page preference
|
| | | setStatelessHint(true);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected Class<? extends BasePage> getRootNavPageClass() {
|
| | | return RepositoriesPage.class;
|
| | |
| | | protected Class<? extends BasePage> getRepoNavPageClass() {
|
| | | return getClass();
|
| | | }
|
| | | |
| | |
|
| | | private Map<String, PageRegistration> registerPages() {
|
| | | PageParameters params = null;
|
| | | if (!StringUtils.isEmpty(repositoryName)) {
|
| | |
| | | pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
|
| | | // pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));
|
| | | pages.put("reflog", new PageRegistration("gb.reflog", ReflogPage.class, params));
|
| | | } |
| | | }
|
| | | pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
|
| | | pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
|
| | | pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));
|
| | |
| | |
|
| | | // conditional links
|
| | | // per-repository extra page links
|
| | | if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {
|
| | | pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params, true));
|
| | | }
|
| | | if (model.showReadme || model.useDocs) {
|
| | | pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
|
| | | }
|
| | |
| | | .getUsername()));
|
| | | return pages;
|
| | | }
|
| | | |
| | |
|
| | | protected boolean allowForkControls() {
|
| | | return GitBlit.getBoolean(Keys.web.allowForking, true);
|
| | | }
|
| | |
| | | add(new LinkPanel("projectTitle", null, project.name,
|
| | | ProjectPage.class, WicketUtils.newProjectParameter(project.name)));
|
| | | }
|
| | | |
| | |
|
| | | String name = StringUtils.stripDotGit(repositoryName);
|
| | | if (!StringUtils.isEmpty(projectName) && name.startsWith(projectName)) {
|
| | | name = name.substring(projectName.length() + 1);
|
| | |
| | | add(new LinkPanel("repositoryName", null, name, SummaryPage.class,
|
| | | WicketUtils.newRepositoryParameter(repositoryName)));
|
| | | add(new Label("pageName", pageName).setRenderBodyOnly(true));
|
| | | |
| | |
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | if (user == null) {
|
| | | user = UserModel.ANONYMOUS;
|
| | |
| | | } else {
|
| | | // link to origin repository
|
| | | Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
|
| | | forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository), |
| | | forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository),
|
| | | SummaryPage.class, WicketUtils.newRepositoryParameter(model.originRepository)));
|
| | | add(forkFrag);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // (un)star link allows a user to star a repository
|
| | | if (user.isAuthenticated) {
|
| | | PageParameters starParams = DeepCopier.copy(getPageParameters());
|
| | |
| | | if (hasFork || !canFork) {
|
| | | // user not allowed to fork or fork already exists or repo forbids forking
|
| | | add(new ExternalLink("forkLink", "").setVisible(false));
|
| | | |
| | |
|
| | | if (hasFork && !fork.equals(model.name)) {
|
| | | // user has fork, view my fork link
|
| | | String url = getRequestCycle().urlFor(SummaryPage.class, WicketUtils.newRepositoryParameter(fork)).toString();
|
| | |
| | | add(new ExternalLink("forkLink", url));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (showAdmin || isOwner) {
|
| | | String url = getRequestCycle().urlFor(EditRepositoryPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();
|
| | | add(new ExternalLink("editLink", url)); |
| | | add(new ExternalLink("editLink", url));
|
| | | } else {
|
| | | add(new Label("editLink").setVisible(false));
|
| | | }
|
| | | |
| | |
|
| | | super.setupPage(repositoryName, pageName);
|
| | | }
|
| | | |
| | |
|
| | | protected void addToolbarButton(String wicketId, String iconClass, String label, String url) {
|
| | | Fragment button = new Fragment(wicketId, "toolbarLinkFragment", this);
|
| | | Label icon = new Label("icon");
|
| | |
| | | getSubmodules(commit);
|
| | | return commit;
|
| | | }
|
| | | |
| | | protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) { |
| | |
|
| | | protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) {
|
| | | if (submodules == null) {
|
| | | submodules = new HashMap<String, SubmoduleModel>();
|
| | | for (SubmoduleModel model : JGitUtils.getSubmodules(r, commit.getTree())) {
|
| | |
| | | }
|
| | | return submodules;
|
| | | }
|
| | | |
| | |
|
| | | protected SubmoduleModel getSubmodule(String path) {
|
| | | SubmoduleModel model = null;
|
| | | if (submodules != null) {
|
| | |
| | | // extract the repository name from the clone url
|
| | | List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns);
|
| | | String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0]));
|
| | | |
| | |
|
| | | // determine the current path for constructing paths relative
|
| | | // to the current repository
|
| | | String currentPath = "";
|
| | |
| | | return model;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // we do not have a copy of the submodule, but we need a path
|
| | | model.gitblitPath = candidates.get(0);
|
| | | return model;
|
| | | } |
| | | }
|
| | | }
|
| | |
|
| | | protected String getShortObjectId(String objectId) {
|
| | |
| | | setupPage(repositoryName, "/ " + getPageName());
|
| | | super.onBeforeRender();
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected void setLastModified() {
|
| | | if (getClass().isAnnotationPresent(CacheControl.class)) {
|
| | |
| | | public boolean isShowAdmin() {
|
| | | return showAdmin;
|
| | | }
|
| | | |
| | |
|
| | | public boolean isOwner() {
|
| | | return isOwner;
|
| | | }
|
| | | |
| | |
|
| | | private class SearchForm extends SessionlessForm<Void> implements Serializable {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | |
| | | Constants.SearchType searchType = searchTypeModel.getObject();
|
| | | String searchString = searchBoxModel.getObject();
|
| | | if (StringUtils.isEmpty(searchString)) {
|
| | | // redirect to self to avoid wicket page update bug |
| | | // 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);
|