]> source.dussan.org Git - gitblit.git/commitdiff
Strip trailing .git from displayed repository links, saves room, looks cleaner
authorJames Moger <james.moger@gitblit.com>
Fri, 6 Jan 2012 22:24:55 +0000 (17:24 -0500)
committerJames Moger <james.moger@gitblit.com>
Fri, 6 Jan 2012 22:24:55 +0000 (17:24 -0500)
src/com/gitblit/models/RepositoryModel.java
src/com/gitblit/utils/StringUtils.java
src/com/gitblit/wicket/pages/RepositoryPage.java
src/com/gitblit/wicket/panels/ActivityPanel.java
src/com/gitblit/wicket/panels/RepositoriesPanel.java

index 7e33ab062b63a89a8d76aa1922af08c095aebdfb..ad0adaa6bbfd3ae159dacd35e2d35792db5b67a7 100644 (file)
@@ -59,6 +59,8 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        public List<String> postReceiveScripts;\r
        public List<String> mailingLists;\r
 \r
+       private String displayName;\r
+       \r
        public RepositoryModel() {\r
                this("", "", "", new Date(0));\r
        }\r
@@ -75,7 +77,10 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
 \r
        @Override\r
        public String toString() {\r
-               return name;\r
+               if (displayName == null) {\r
+                       displayName = StringUtils.stripDotGit(name);\r
+               }\r
+               return displayName;\r
        }\r
 \r
        @Override\r
index 1e47899947181c7e942ad3d5f6d76c75a17c383b..fc0bf42ffa928059fc36ed02aa33daddb9674672 100644 (file)
@@ -488,4 +488,11 @@ public class StringUtils {
                String bs = Integer.toHexString((int) (b * 256));\r
                return "#" + rs + gs + bs;\r
        }\r
+       \r
+       public static String stripDotGit(String value) {\r
+               if (value.toLowerCase().endsWith(".git")) {\r
+                       return value.substring(0, value.length() - 4);\r
+               }\r
+               return value;\r
+       }\r
 }
\ No newline at end of file
index 85719f15b7c68b46d948b27fa13fea2b0a999c30..c84ccb0671904b0466e5002f38db54fdd7028e17 100644 (file)
@@ -141,8 +141,8 @@ public abstract class RepositoryPage extends BasePage {
        }\r
 \r
        @Override\r
-       protected void setupPage(String repositoryName, String pageName) {\r
-               add(new LinkPanel("repositoryName", null, repositoryName, SummaryPage.class,\r
+       protected void setupPage(String repositoryName, String pageName) {              \r
+               add(new LinkPanel("repositoryName", null, StringUtils.stripDotGit(repositoryName), SummaryPage.class,\r
                                WicketUtils.newRepositoryParameter(repositoryName)));\r
                add(new Label("pageName", pageName));\r
 \r
index 80621ae48e1b88ad77f7f788c447924bd5baff6a..7cafb828f60655b4c5e92913afb547d3fe263fea 100644 (file)
@@ -94,8 +94,9 @@ public class ActivityPanel extends BasePanel {
                                                fragment.add(authorLink);\r
 \r
                                                // repository\r
+                                               String repoName = StringUtils.stripDotGit(commit.repository);\r
                                                LinkPanel repositoryLink = new LinkPanel("repository", null,\r
-                                                               commit.repository, SummaryPage.class,\r
+                                                               repoName, SummaryPage.class,\r
                                                                WicketUtils.newRepositoryParameter(commit.repository), true);\r
                                                WicketUtils.setCssBackground(repositoryLink, commit.repository);\r
                                                fragment.add(repositoryLink);\r
index 3a876bdd144685d2f06dd0d1abfec93e3dd06ea8..3b3db4923b008620294f7b78a3fb945f98e74f31 100644 (file)
@@ -144,7 +144,7 @@ public class RepositoriesPanel extends BasePanel {
                                item.add(row);\r
 \r
                                // try to strip group name for less cluttered list\r
-                               String repoName = entry.name;\r
+                               String repoName = entry.toString();\r
                                if (!StringUtils.isEmpty(currGroupName) && (repoName.indexOf('/') > -1)) {\r
                                        repoName = repoName.substring(currGroupName.length() + 1);\r
                                }\r