]> source.dussan.org Git - gitblit.git/commitdiff
prefer shortened refs for cleaner/shorter URLs 284/head
authorJoel Johnson <mrjoel@lixil.net>
Wed, 1 Jul 2015 07:15:02 +0000 (01:15 -0600)
committerJoel Johnson <mrjoel@lixil.net>
Wed, 1 Jul 2015 17:15:53 +0000 (11:15 -0600)
src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
src/main/java/com/gitblit/wicket/panels/DigestsPanel.java

index 4bf00f8a04007c66d6cdae0bc08388f8ddb7caa6..7a564aa59f5b3f9611753671d3aa2d537057d95a 100644 (file)
@@ -114,11 +114,13 @@ public class BranchesPanel extends BasePanel {
                        public void populateItem(final Item<RefModel> item) {\r
                                final RefModel entry = item.getModelObject();\r
 \r
+                               PageParameters shortUniqRef = WicketUtils.newObjectParameter(model.name,\r
+                                               Repository.shortenRefName(entry.getName()));\r
+\r
                                item.add(WicketUtils.createDateLabel("branchDate", entry.getDate(), getTimeZone(), getTimeUtils()));\r
 \r
                                item.add(new LinkPanel("branchName", "list name", StringUtils.trimString(\r
-                                               entry.displayName, 28), LogPage.class, WicketUtils.newObjectParameter(\r
-                                               model.name, entry.getName())));\r
+                                               entry.displayName, 28), LogPage.class, shortUniqRef));\r
 \r
                                String author = entry.getAuthorIdent().getName();\r
                                LinkPanel authorLink = new LinkPanel("branchAuthor", "list", author,\r
@@ -131,8 +133,7 @@ public class BranchesPanel extends BasePanel {
                                String shortMessage = entry.getShortMessage();\r
                                String trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);\r
                                LinkPanel shortlog = new LinkPanel("branchLog", "list subject", trimmedMessage,\r
-                                               CommitPage.class, WicketUtils.newObjectParameter(model.name,\r
-                                                               entry.getName()));\r
+                                               CommitPage.class, shortUniqRef);\r
                                if (!shortMessage.equals(trimmedMessage)) {\r
                                        shortlog.setTooltip(shortMessage);\r
                                }\r
@@ -140,27 +141,22 @@ public class BranchesPanel extends BasePanel {
 \r
                                if (maxCount <= 0) {\r
                                        Fragment fragment = new Fragment("branchLinks", showDelete? "branchPageAdminLinks" : "branchPageLinks", this);\r
-                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
-                                                       .newObjectParameter(model.name, entry.getName())));\r
-                                       fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils\r
-                                                       .newObjectParameter(model.name, entry.getName())));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, shortUniqRef));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, shortUniqRef));\r
                                        String rawUrl = RawServlet.asLink(getContextUrl(), model.name, Repository.shortenRefName(entry.getName()), null);\r
-                                       fragment.add(new ExternalLink("raw",  rawUrl));\r
-                                       fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,\r
-                                                       WicketUtils.newObjectParameter(model.name, entry.getName())));\r
+                                       fragment.add(new ExternalLink("raw", rawUrl));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class, shortUniqRef));\r
                                        fragment.add(new ExternalLink("syndication", SyndicationServlet.asLink(\r
                                                        getRequest().getRelativePathPrefixToContextRoot(), model.name,\r
-                                                       entry.getName(), 0)));\r
+                                                       Repository.shortenRefName(entry.getName()), 0)));\r
                                        if (showDelete) {\r
                                                fragment.add(createDeleteBranchLink(model, entry));\r
                                        }\r
                                        item.add(fragment);\r
                                } else {\r
                                        Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this);\r
-                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
-                                                       .newObjectParameter(model.name, entry.getName())));\r
-                                       fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils\r
-                                                       .newObjectParameter(model.name, entry.getName())));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, shortUniqRef));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, shortUniqRef));\r
                                        String rawUrl = RawServlet.asLink(getContextUrl(), model.name, Repository.shortenRefName(entry.getName()), null);\r
                                        fragment.add(new ExternalLink("raw",  rawUrl));\r
                                        item.add(fragment);\r
index d901945d40206c47c01034d2ec150932feabfb84..0c80f9976ec1cc276985e2143ca2797618304171 100644 (file)
@@ -166,7 +166,7 @@ public class DigestsPanel extends BasePanel {
                                } else if (isTag) {
                                        // link to tag
                                        logItem.add(new LinkPanel("refChanged", null, shortRefName,
-                                                       TagPage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
+                                                       TagPage.class, WicketUtils.newObjectParameter(change.repository, shortRefName)));
                                } else if (isTicket) {
                                        // link to ticket
                                        logItem.add(new LinkPanel("refChanged", null, shortRefName,
@@ -174,7 +174,7 @@ public class DigestsPanel extends BasePanel {
                                } else {
                                        // link to tree
                                        logItem.add(new LinkPanel("refChanged", null, shortRefName,
-                                               TreePage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
+                                               TreePage.class, WicketUtils.newObjectParameter(change.repository, shortRefName)));
                                }
 
                                // to/from/etc