James Moger
2012-10-19 79dfe69726b6255464599ab852018e4d2ff96fdc
commit | author | age
82df52 1 /*
JM 2  * Copyright 2011 gitblit.com.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.gitblit.wicket.pages;
17
18 import java.text.MessageFormat;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.apache.wicket.PageParameters;
23 import org.apache.wicket.markup.html.basic.Label;
24
25 import com.gitblit.GitBlit;
26 import com.gitblit.Keys;
e21181 27 import com.gitblit.models.RepositoryModel;
JM 28 import com.gitblit.utils.ArrayUtils;
9bdf88 29 import com.gitblit.wicket.GitblitRedirectException;
82df52 30 import com.gitblit.wicket.WicketUtils;
JM 31 import com.gitblit.wicket.panels.RepositoryUrlPanel;
32
33 public class EmptyRepositoryPage extends RootPage {
34
35     public EmptyRepositoryPage(PageParameters params) {
36         super(params);
37
9bdf88 38         setVersioned(false);
JM 39
82df52 40         String repositoryName = WicketUtils.getRepositoryName(params);
e21181 41         RepositoryModel repository = GitBlit.self().getRepositoryModel(repositoryName);
4e1cc8 42         
JM 43         if (repository.hasCommits) {
44             // redirect to the summary page if this repository is not empty
9bdf88 45             throw new GitblitRedirectException(SummaryPage.class, params);
4e1cc8 46         }
JM 47         
82df52 48         setupPage(repositoryName, getString("gb.emptyRepository"));
JM 49
50         List<String> repositoryUrls = new ArrayList<String>();
51
52         if (GitBlit.getBoolean(Keys.git.enableGitServlet, true)) {
e21181 53             // add the Gitblit repository url
JM 54             repositoryUrls.add(getRepositoryUrl(repository));
82df52 55         }
JM 56         repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));
57         
e21181 58         String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.get(0);
82df52 59         add(new Label("repository", repositoryName));
e21181 60         add(new RepositoryUrlPanel("pushurl", primaryUrl));
02e0f7 61         add(new Label("cloneSyntax", MessageFormat.format("git clone {0}", repositoryUrls.get(0))));
e21181 62         add(new Label("remoteSyntax", MessageFormat.format("git remote add gitblit {0}\ngit push gitblit master", primaryUrl)));
82df52 63     }
JM 64 }