diff options
author | James Moger <james.moger@gitblit.com> | 2013-03-29 15:44:08 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-03-29 15:44:08 -0400 |
commit | d37bce55bbb60aa2130b40673d28ec8c8f4049c1 (patch) | |
tree | d4ac23efe4c8579da8b237707805cca5f65a47de /src/main/java/com/gitblit | |
parent | ffe9bd0ea959cf768983ff1a3d2de897390016d7 (diff) | |
download | gitblit-d37bce55bbb60aa2130b40673d28ec8c8f4049c1.tar.gz gitblit-d37bce55bbb60aa2130b40673d28ec8c8f4049c1.zip |
Support username substitution in web.otherUrls (issue 213)
Diffstat (limited to 'src/main/java/com/gitblit')
4 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index 83769d36..12815e78 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -454,12 +454,13 @@ public class GitBlit implements ServletContextListener { * 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;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java index be0dad9e..cccf8a69 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java @@ -25,7 +25,9 @@ import org.apache.wicket.markup.html.basic.Label; 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 @@ public class EmptyRepositoryPage extends RootPage { // 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));
diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java index bd40a1b7..d68add0f 100644 --- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java @@ -53,6 +53,7 @@ import com.gitblit.utils.ArrayUtils; 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 @@ public class SummaryPage extends RepositoryPage { Repository r = getRepository();
RepositoryModel model = getRepositoryModel();
+ UserModel user = GitBlitWebSession.get().getUser();
List<Metric> metrics = null;
Metric metricsTotal = null;
@@ -148,7 +150,7 @@ public class SummaryPage extends RepositoryPage { } 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));
diff --git a/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java b/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java index 7b4ee9f0..f2b56e17 100644 --- a/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java @@ -221,7 +221,7 @@ public class ProjectRepositoryPanel extends BasePanel { // 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));
|