]> source.dussan.org Git - gitblit.git/commitdiff
Support username substitution in web.otherUrls (issue 213)
authorJames Moger <james.moger@gitblit.com>
Fri, 29 Mar 2013 19:44:08 +0000 (15:44 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 29 Mar 2013 19:44:08 +0000 (15:44 -0400)
releases.moxie
src/main/distrib/data/gitblit.properties
src/main/java/com/gitblit/GitBlit.java
src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
src/main/java/com/gitblit/wicket/panels/ProjectRepositoryPanel.java

index b34ea3b9624053dfcbd1018aff15e0ae836af49d..a274b0735236c7c551c9bf2fc8dc322d7c586118 100644 (file)
@@ -30,6 +30,7 @@ r17: {
      - Implemented multiple repository owners\r
      - Chinese translation\r
         - Added weblogic.xml to WAR for deployment on WebLogic (issue 199)\r
+        - Support username substitution in web.otherUrls (issue 213)\r
         - Option to force client-side basic authentication instead of form-based authentication if web.authenticateViewPages=true (issue 222)\r
 \r
     contributors:\r
index c1587d6b7150da53df10eee5f4d241fd0cd2ff7c..8c90258bdc33c15fd69fe164a2221aa4e56a2376 100644 (file)
@@ -723,9 +723,16 @@ web.mountParameters = true
 web.forwardSlashCharacter = /\r
 \r
 # Show other URLs on the summary page for accessing your git repositories\r
-# Use spaces to separate urls. {0} is the token for the repository name.\r
+# Use spaces to separate urls.\r
+#\r
+# {0} is the token for the repository name\r
+# {1} is the token for the username\r
+#\r
+# The username is only practical if you have setup your other git serving\r
+# solutions accounts to have the same username as the Gitblit account.\r
+#\r
 # e.g.\r
-# web.otherUrls = ssh://localhost/git/{0} git://localhost/git/{0}\r
+# web.otherUrls = ssh://localhost/git/{0} git://localhost/git/{0} https://{1}@localhost/r/{0}\r
 #\r
 # SPACE-DELIMITED\r
 # SINCE 0.5.0\r
index 83769d364470b0639bbb8be903d9816b4fe9afac..12815e78cea2da3538d19b936a4950fea4ca3f5f 100644 (file)
@@ -454,12 +454,13 @@ public class GitBlit implements ServletContextListener {
         * advertise alternative urls for Git client repository access.\r
         * \r
         * @param repositoryName\r
+        * @param userName\r
         * @return list of non-gitblit clone urls\r
         */\r
-       public List<String> getOtherCloneUrls(String repositoryName) {\r
+       public List<String> getOtherCloneUrls(String repositoryName, String username) {\r
                List<String> cloneUrls = new ArrayList<String>();\r
                for (String url : settings.getStrings(Keys.web.otherUrls)) {\r
-                       cloneUrls.add(MessageFormat.format(url, repositoryName));\r
+                       cloneUrls.add(MessageFormat.format(url, repositoryName, username));\r
                }\r
                return cloneUrls;\r
        }\r
index be0dad9e07f87f126ca2b9adc411c63a7e1f62db..cccf8a69cfe82001de72625436bbc7dbd0ee2753 100644 (file)
@@ -25,7 +25,9 @@ import org.apache.wicket.markup.html.basic.Label;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.ArrayUtils;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.GitblitRedirectException;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.RepositoryUrlPanel;\r
@@ -56,7 +58,8 @@ public class EmptyRepositoryPage extends RootPage {
                        // add the Gitblit repository url\r
                        repositoryUrls.add(getRepositoryUrl(repository));\r
                }\r
-               repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));\r
+               UserModel user = GitBlitWebSession.get().getUser();\r
+               repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName, user == null ? "" : user.username));\r
                \r
                String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.get(0);\r
                add(new Label("repository", repositoryName));\r
index bd40a1b7c2742c4b2443221faf747d35ef586c0e..d68add0f082a58278ca1d72982c0b8f5ba5dc802 100644 (file)
@@ -53,6 +53,7 @@ import com.gitblit.utils.ArrayUtils;
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.MarkdownUtils;\r
 import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.BranchesPanel;\r
 import com.gitblit.wicket.panels.LinkPanel;\r
@@ -73,6 +74,7 @@ public class SummaryPage extends RepositoryPage {
 \r
                Repository r = getRepository();\r
                RepositoryModel model = getRepositoryModel();\r
+               UserModel user = GitBlitWebSession.get().getUser();\r
 \r
                List<Metric> metrics = null;\r
                Metric metricsTotal = null;\r
@@ -148,7 +150,7 @@ public class SummaryPage extends RepositoryPage {
                } else {\r
                        add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));\r
                }\r
-               repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName));\r
+               repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName, user == null ? "" : user.username));\r
                \r
                String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.remove(0);\r
                add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl));\r
index 7b4ee9f0ded26d429048dab936c559a67e4023fb..f2b56e1768752582f6fa2f5334766ea6992157e6 100644 (file)
@@ -221,7 +221,7 @@ public class ProjectRepositoryPanel extends BasePanel {
                        // add the Gitblit repository url\r
                        repositoryUrls.add(BasePage.getRepositoryUrl(entry));\r
                }\r
-               repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(entry.name));\r
+               repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(entry.name, user == null ? "" : user.username));\r
 \r
                String primaryUrl = ArrayUtils.isEmpty(repositoryUrls) ? "" : repositoryUrls.remove(0);\r
                add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl));\r