| | |
| | | import com.gitblit.utils.BugtraqProcessor;
|
| | | import com.gitblit.utils.DeepCopier;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.ModelUtils;
|
| | | import com.gitblit.utils.RefLogUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | |
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.NavigationPanel;
|
| | | import com.gitblit.wicket.panels.RefsPanel;
|
| | | import com.google.common.base.Optional;
|
| | |
|
| | | public abstract class RepositoryPage extends RootPage {
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | protected void setupPage(String repositoryName, String pageName) {
|
| | | |
| | | //This method should only be called once in the page lifecycle.
|
| | | //However, it must be called after the constructor has run, hence not in onInitialize
|
| | | //It may be attempted to be called again if an info or error message is displayed.
|
| | | if (get("projectTitle") != null) { return; }
|
| | | |
| | | String projectName = StringUtils.getFirstPathElement(repositoryName);
|
| | | ProjectModel project = app().projects().getProjectModel(projectName);
|
| | |
|
| | | if (project.isUserProject()) {
|
| | | // user-as-project
|
| | | add(new LinkPanel("projectTitle", null, project.getDisplayName(),
|
| | |
| | | RepositoryModel model = getRepositoryModel();
|
| | | if (StringUtils.isEmpty(model.originRepository)) {
|
| | | if (model.isMirror) {
|
| | | add(new Fragment("repoIcon", "mirrorIconFragment", this));
|
| | | Fragment mirrorFrag = new Fragment("originRepository", "mirrorFragment", this);
|
| | | Label lbl = new Label("originRepository", MessageFormat.format(getString("gb.mirrorOf"), "<b>" + model.origin + "</b>"));
|
| | | mirrorFrag.add(lbl.setEscapeModelStrings(false));
|
| | | add(mirrorFrag);
|
| | | } else {
|
| | | add(new Label("originRepository").setVisible(false));
|
| | | if (model.isBare) {
|
| | | add(new Fragment("repoIcon", "repoIconFragment", this));
|
| | | } else {
|
| | | add(new Fragment("repoIcon", "cloneIconFragment", this));
|
| | | }
|
| | | add(new Label("originRepository", Optional.of(model.description).or("")));
|
| | | }
|
| | | } else {
|
| | | RepositoryModel origin = app().repositories().getRepositoryModel(model.originRepository);
|
| | | if (origin == null) {
|
| | | // no origin repository
|
| | | add(new Label("originRepository").setVisible(false));
|
| | | // no origin repository, show description if available
|
| | | if (model.isBare) {
|
| | | add(new Fragment("repoIcon", "repoIconFragment", this));
|
| | | } else {
|
| | | add(new Fragment("repoIcon", "cloneIconFragment", this));
|
| | | }
|
| | | add(new Label("originRepository", Optional.of(model.description).or("")));
|
| | | } else if (!user.canView(origin)) {
|
| | | // show origin repository without link
|
| | | add(new Fragment("repoIcon", "forkIconFragment", this));
|
| | | Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
|
| | | forkFrag.add(new Label("originRepository", StringUtils.stripDotGit(model.originRepository)));
|
| | | add(forkFrag);
|
| | | } else {
|
| | | // link to origin repository
|
| | | add(new Fragment("repoIcon", "forkIconFragment", this));
|
| | | Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
|
| | | forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository),
|
| | | SummaryPage.class, WicketUtils.newRepositoryParameter(model.originRepository)));
|
| | |
| | | add(new ExternalLink("myForkLink", "").setVisible(false));
|
| | | } else {
|
| | | String fork = app().repositories().getFork(user.username, model.name);
|
| | | String userRepo = ModelUtils.getPersonalPath(user.username) + "/" + StringUtils.stripDotGit(StringUtils.getLastPathElement(model.name));
|
| | | boolean hasUserRepo = app().repositories().hasRepository(userRepo);
|
| | | boolean hasFork = fork != null;
|
| | | boolean canFork = user.canFork(model) && model.hasCommits;
|
| | | boolean canFork = user.canFork(model) && model.hasCommits && !hasUserRepo;
|
| | |
|
| | | if (hasFork || !canFork) {
|
| | | // user not allowed to fork or fork already exists or repo forbids forking
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | protected void onBeforeRender() {
|
| | | // dispose of repository object
|
| | |
| | | r.close();
|
| | | r = null;
|
| | | }
|
| | | |
| | | // setup page header and footer
|
| | | setupPage(getRepositoryName(), "/ " + getPageName());
|
| | |
|
| | | super.onBeforeRender();
|
| | | }
|
| | |
|