From e4dd827ce401144136d270059296108e51707205 Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Wed, 1 Jul 2015 01:15:02 -0600 Subject: [PATCH] prefer shortened refs for cleaner/shorter URLs --- .../gitblit/wicket/panels/BranchesPanel.java | 28 ++++++++----------- .../gitblit/wicket/panels/DigestsPanel.java | 4 +-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java index 4bf00f8a..7a564aa5 100644 --- a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java @@ -114,11 +114,13 @@ public class BranchesPanel extends BasePanel { public void populateItem(final Item item) { final RefModel entry = item.getModelObject(); + PageParameters shortUniqRef = WicketUtils.newObjectParameter(model.name, + Repository.shortenRefName(entry.getName())); + item.add(WicketUtils.createDateLabel("branchDate", entry.getDate(), getTimeZone(), getTimeUtils())); item.add(new LinkPanel("branchName", "list name", StringUtils.trimString( - entry.displayName, 28), LogPage.class, WicketUtils.newObjectParameter( - model.name, entry.getName()))); + entry.displayName, 28), LogPage.class, shortUniqRef)); String author = entry.getAuthorIdent().getName(); LinkPanel authorLink = new LinkPanel("branchAuthor", "list", author, @@ -131,8 +133,7 @@ public class BranchesPanel extends BasePanel { String shortMessage = entry.getShortMessage(); String trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); LinkPanel shortlog = new LinkPanel("branchLog", "list subject", trimmedMessage, - CommitPage.class, WicketUtils.newObjectParameter(model.name, - entry.getName())); + CommitPage.class, shortUniqRef); if (!shortMessage.equals(trimmedMessage)) { shortlog.setTooltip(shortMessage); } @@ -140,27 +141,22 @@ public class BranchesPanel extends BasePanel { if (maxCount <= 0) { Fragment fragment = new Fragment("branchLinks", showDelete? "branchPageAdminLinks" : "branchPageLinks", this); - fragment.add(new BookmarkablePageLink("log", LogPage.class, WicketUtils - .newObjectParameter(model.name, entry.getName()))); - fragment.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils - .newObjectParameter(model.name, entry.getName()))); + fragment.add(new BookmarkablePageLink("log", LogPage.class, shortUniqRef)); + fragment.add(new BookmarkablePageLink("tree", TreePage.class, shortUniqRef)); String rawUrl = RawServlet.asLink(getContextUrl(), model.name, Repository.shortenRefName(entry.getName()), null); - fragment.add(new ExternalLink("raw", rawUrl)); - fragment.add(new BookmarkablePageLink("metrics", MetricsPage.class, - WicketUtils.newObjectParameter(model.name, entry.getName()))); + fragment.add(new ExternalLink("raw", rawUrl)); + fragment.add(new BookmarkablePageLink("metrics", MetricsPage.class, shortUniqRef)); fragment.add(new ExternalLink("syndication", SyndicationServlet.asLink( getRequest().getRelativePathPrefixToContextRoot(), model.name, - entry.getName(), 0))); + Repository.shortenRefName(entry.getName()), 0))); if (showDelete) { fragment.add(createDeleteBranchLink(model, entry)); } item.add(fragment); } else { Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this); - fragment.add(new BookmarkablePageLink("log", LogPage.class, WicketUtils - .newObjectParameter(model.name, entry.getName()))); - fragment.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils - .newObjectParameter(model.name, entry.getName()))); + fragment.add(new BookmarkablePageLink("log", LogPage.class, shortUniqRef)); + fragment.add(new BookmarkablePageLink("tree", TreePage.class, shortUniqRef)); String rawUrl = RawServlet.asLink(getContextUrl(), model.name, Repository.shortenRefName(entry.getName()), null); fragment.add(new ExternalLink("raw", rawUrl)); item.add(fragment); diff --git a/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java b/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java index d901945d..0c80f997 100644 --- a/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java @@ -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 -- 2.39.5