James Moger
2013-03-29 d37bce55bbb60aa2130b40673d28ec8c8f4049c1
Support username substitution in web.otherUrls (issue-213)
6 files modified
28 ■■■■ changed files
releases.moxie 1 ●●●● patch | view | raw | blame | history
src/main/distrib/data/gitblit.properties 11 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/GitBlit.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/pages/SummaryPage.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java 2 ●●● patch | view | raw | blame | history
releases.moxie
@@ -30,6 +30,7 @@
     - Implemented multiple repository owners
     - Chinese translation
     - Added weblogic.xml to WAR for deployment on WebLogic (issue 199)
     - Support username substitution in web.otherUrls (issue 213)
     - Option to force client-side basic authentication instead of form-based authentication if web.authenticateViewPages=true (issue 222)
    contributors:
src/main/distrib/data/gitblit.properties
@@ -723,9 +723,16 @@
web.forwardSlashCharacter = /
# Show other URLs on the summary page for accessing your git repositories
# Use spaces to separate urls. {0} is the token for the repository name.
# Use spaces to separate urls.
#
# {0} is the token for the repository name
# {1} is the token for the username
#
# The username is only practical if you have setup your other git serving
# solutions accounts to have the same username as the Gitblit account.
#
# e.g.
# web.otherUrls = ssh://localhost/git/{0} git://localhost/git/{0}
# web.otherUrls = ssh://localhost/git/{0} git://localhost/git/{0} https://{1}@localhost/r/{0}
#
# SPACE-DELIMITED
# SINCE 0.5.0
src/main/java/com/gitblit/GitBlit.java
@@ -454,12 +454,13 @@
     * advertise alternative urls for Git client repository access.
     * 
     * @param repositoryName
     * @param userName
     * @return list of non-gitblit clone urls
     */
    public List<String> getOtherCloneUrls(String repositoryName) {
    public List<String> getOtherCloneUrls(String repositoryName, String username) {
        List<String> cloneUrls = new ArrayList<String>();
        for (String url : settings.getStrings(Keys.web.otherUrls)) {
            cloneUrls.add(MessageFormat.format(url, repositoryName));
            cloneUrls.add(MessageFormat.format(url, repositoryName, username));
        }
        return cloneUrls;
    }
src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
@@ -25,7 +25,9 @@
import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.GitblitRedirectException;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.RepositoryUrlPanel;
@@ -56,7 +58,8 @@
            // add the Gitblit repository url
            repositoryUrls.add(getRepositoryUrl(repository));
        }
        repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));
        UserModel user = GitBlitWebSession.get().getUser();
        repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName, user == null ? "" : user.username));
        
        String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.get(0);
        add(new Label("repository", repositoryName));
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
@@ -53,6 +53,7 @@
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.BranchesPanel;
import com.gitblit.wicket.panels.LinkPanel;
@@ -73,6 +74,7 @@
        Repository r = getRepository();
        RepositoryModel model = getRepositoryModel();
        UserModel user = GitBlitWebSession.get().getUser();
        List<Metric> metrics = null;
        Metric metricsTotal = null;
@@ -148,7 +150,7 @@
        } else {
            add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));
        }
        repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));
        repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName, user == null ? "" : user.username));
        
        String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.remove(0);
        add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl));
src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
@@ -221,7 +221,7 @@
            // add the Gitblit repository url
            repositoryUrls.add(BasePage.getRepositoryUrl(entry));
        }
        repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(entry.name));
        repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(entry.name, user == null ? "" : user.username));
        String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.remove(0);
        add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl));