From: James Moger Date: Sat, 25 Feb 2012 15:54:22 +0000 (-0500) Subject: Split refs into 2 lines if there are remotes. Use more glyphicons. X-Git-Tag: v0.9.0~82 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a45caac4769a1cd8337c45a1279d130db8c0e539;p=gitblit.git Split refs into 2 lines if there are remotes. Use more glyphicons. --- diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java index a28a871a..3f823de1 100644 --- a/src/com/gitblit/Constants.java +++ b/src/com/gitblit/Constants.java @@ -65,6 +65,10 @@ public class Constants { public static final String ENCODING = "UTF-8"; + public static final int LEN_SHORTLOG = 80; + + public static final int LEN_SHORTLOG_REFS = 60; + public static String getGitBlitVersion() { return NAME + " v" + VERSION; } diff --git a/src/com/gitblit/utils/StringUtils.java b/src/com/gitblit/utils/StringUtils.java index fc0bf42f..a465e0d7 100644 --- a/src/com/gitblit/utils/StringUtils.java +++ b/src/com/gitblit/utils/StringUtils.java @@ -168,16 +168,6 @@ public class StringUtils { return value.substring(0, max - 3) + "..."; } - /** - * Returns a trimmed shortlog message. - * - * @param string - * @return trimmed shortlog message - */ - public static String trimShortLog(String string) { - return trimString(string, 60); - } - /** * Left pad a string with the specified character, if the string length is * less than the specified length. diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java index 7be5328e..864ebe6a 100644 --- a/src/com/gitblit/wicket/WicketUtils.java +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -220,6 +220,19 @@ public class WicketUtils { return img; } + public static Label newIcon(String wicketId, String css) { + Label lbl = new Label(wicketId); + setCssClass(lbl, css); + return lbl; + } + + public static Label newBlankIcon(String wicketId) { + Label lbl = new Label(wicketId); + setCssClass(lbl, ""); + lbl.setRenderBodyOnly(true); + return lbl; + } + public static ContextRelativeResource getResource(String file) { return new ContextRelativeResource(file); } diff --git a/src/com/gitblit/wicket/pages/DocsPage.html b/src/com/gitblit/wicket/pages/DocsPage.html index 0da4bde4..98432b5e 100644 --- a/src/com/gitblit/wicket/pages/DocsPage.html +++ b/src/com/gitblit/wicket/pages/DocsPage.html @@ -8,7 +8,7 @@ -
[header]
+
[header]
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html index 941e777d..c2096a6f 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.html +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -38,7 +38,7 @@
- +
diff --git a/src/com/gitblit/wicket/panels/ActivityPanel.html b/src/com/gitblit/wicket/panels/ActivityPanel.html index 4c0566cf..3a603bfb 100644 --- a/src/com/gitblit/wicket/panels/ActivityPanel.html +++ b/src/com/gitblit/wicket/panels/ActivityPanel.html @@ -8,7 +8,7 @@
-
[title]
+
[title]
diff --git a/src/com/gitblit/wicket/panels/ActivityPanel.java b/src/com/gitblit/wicket/panels/ActivityPanel.java index 34a281fb..dc94f3c1 100644 --- a/src/com/gitblit/wicket/panels/ActivityPanel.java +++ b/src/com/gitblit/wicket/panels/ActivityPanel.java @@ -113,7 +113,12 @@ public class ActivityPanel extends BasePanel { // message/commit link String shortMessage = commit.getShortMessage(); - String trimmedMessage = StringUtils.trimShortLog(shortMessage); + String trimmedMessage = shortMessage; + if (commit.getRefs() != null && commit.getRefs().size() > 0) { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS); + } else { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); + } LinkPanel shortlog = new LinkPanel("message", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter( commit.repository, commit.getName()), true); diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.html b/src/com/gitblit/wicket/panels/BranchesPanel.html index 01fb8bac..114541fb 100644 --- a/src/com/gitblit/wicket/panels/BranchesPanel.html +++ b/src/com/gitblit/wicket/panels/BranchesPanel.html @@ -8,7 +8,7 @@ -
[branches header]
+
[branches header]
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java index 6eb40199..0d2fe4a9 100644 --- a/src/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/com/gitblit/wicket/panels/BranchesPanel.java @@ -41,7 +41,6 @@ import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.MetricsPage; import com.gitblit.wicket.pages.SearchPage; -import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TreePage; public class BranchesPanel extends BasePanel { @@ -73,9 +72,7 @@ public class BranchesPanel extends BasePanel { null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name))); } else { // branches page - // show repository summary page link - add(new LinkPanel("branches", "title", model.name, SummaryPage.class, - WicketUtils.newRepositoryParameter(model.name))); + add(new Label("branches", new StringResourceModel("gb.branches", this, null))); } ListDataProvider branchesDp = new ListDataProvider(branches); @@ -101,7 +98,7 @@ public class BranchesPanel extends BasePanel { // short message String shortMessage = entry.getShortMessage(); - String trimmedMessage = StringUtils.trimShortLog(shortMessage); + String trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); LinkPanel shortlog = new LinkPanel("branchLog", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(model.name, entry.getName())); diff --git a/src/com/gitblit/wicket/panels/HistoryPanel.java b/src/com/gitblit/wicket/panels/HistoryPanel.java index 16f95f22..36a76806 100644 --- a/src/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/com/gitblit/wicket/panels/HistoryPanel.java @@ -121,7 +121,12 @@ public class HistoryPanel extends BasePanel { } String shortMessage = entry.getShortMessage(); - String trimmedMessage = StringUtils.trimShortLog(shortMessage); + String trimmedMessage = shortMessage; + if (allRefs.containsKey(entry.getId())) { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS); + } else { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); + } LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter( repositoryName, entry.getName())); diff --git a/src/com/gitblit/wicket/panels/LogPanel.html b/src/com/gitblit/wicket/panels/LogPanel.html index 700f66a1..96173062 100644 --- a/src/com/gitblit/wicket/panels/LogPanel.html +++ b/src/com/gitblit/wicket/panels/LogPanel.html @@ -8,14 +8,14 @@ -
[log header]
+
[log header]
- +
[commit date] [commit author]
[commit refs]
[commit short message]
[commit refs]
[commit short message]
| | diff --git a/src/com/gitblit/wicket/panels/LogPanel.java b/src/com/gitblit/wicket/panels/LogPanel.java index 74764d6d..a960f6e0 100644 --- a/src/com/gitblit/wicket/panels/LogPanel.java +++ b/src/com/gitblit/wicket/panels/LogPanel.java @@ -40,7 +40,6 @@ import com.gitblit.wicket.pages.CommitDiffPage; import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.SearchPage; -import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TreePage; public class LogPanel extends BasePanel { @@ -75,9 +74,7 @@ public class LogPanel extends BasePanel { // header if (pageResults) { // shortlog page - // show repository summary page link - add(new LinkPanel("header", "title", objectId, SummaryPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); + add(new Label("header", objectId)); } else { // summary page // show shortlog page link @@ -113,7 +110,12 @@ public class LogPanel extends BasePanel { // short message String shortMessage = entry.getShortMessage(); - String trimmedMessage = StringUtils.trimShortLog(shortMessage); + String trimmedMessage = shortMessage; + if (allRefs.containsKey(entry.getId())) { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS); + } else { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); + } LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter( repositoryName, entry.getName())); diff --git a/src/com/gitblit/wicket/panels/RefsPanel.html b/src/com/gitblit/wicket/panels/RefsPanel.html index 5d301931..a3c0ec49 100644 --- a/src/com/gitblit/wicket/panels/RefsPanel.html +++ b/src/com/gitblit/wicket/panels/RefsPanel.html @@ -6,7 +6,7 @@ - ref + [LB]ref \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java index f25b53b2..86e74a14 100644 --- a/src/com/gitblit/wicket/panels/RefsPanel.java +++ b/src/com/gitblit/wicket/panels/RefsPanel.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import org.apache.wicket.Component; +import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; @@ -54,19 +55,48 @@ public class RefsPanel extends Panel { Collections.sort(refs, new Comparator() { @Override public int compare(RefModel o1, RefModel o2) { + // sort remote heads last, otherwise sort by name + // this is so we can insert a break on the refs panel + // [head][branch][branch][tag][tag] + // [remote][remote][remote] + boolean remote1 = o1.displayName.startsWith(Constants.R_REMOTES); + boolean remote2 = o2.displayName.startsWith(Constants.R_REMOTES); + if (remote1 && remote2) { + // both are remote heads, sort by name + return o1.displayName.compareTo(o2.displayName); + } + if (remote1) { + // o1 is remote, o2 comes first + return 1; + } + if (remote2) { + // remote is o2, o1 comes first + return -1; + } + // standard sort return o1.displayName.compareTo(o2.displayName); } }); - + + // count remote and determine if we should insert a break + int remoteCount = 0; + for (RefModel ref : refs) { + if (ref.displayName.startsWith(Constants.R_REMOTES)) { + remoteCount++; + } + } + final boolean shouldBreak = remoteCount < refs.size(); + ListDataProvider refsDp = new ListDataProvider(refs); DataView refsView = new DataView("ref", refsDp) { private static final long serialVersionUID = 1L; + private boolean alreadyInsertedBreak = !shouldBreak; public void populateItem(final Item item) { RefModel entry = item.getModelObject(); String name = entry.displayName; String objectid = entry.getReferencedObjectId().getName(); - + boolean breakLine = false; Class linkClass = CommitPage.class; String cssClass = ""; if (name.startsWith(Constants.R_HEADS)) { @@ -83,6 +113,10 @@ public class RefsPanel extends Panel { linkClass = LogPage.class; name = name.substring(Constants.R_REMOTES.length()); cssClass = "remoteBranch"; + if (!alreadyInsertedBreak) { + breakLine = true; + alreadyInsertedBreak = true; + } } else if (name.startsWith(Constants.R_TAGS)) { // tag if (entry.isAnnotatedTag()) { @@ -104,6 +138,10 @@ public class RefsPanel extends Panel { WicketUtils.setCssClass(c, cssClass); WicketUtils.setHtmlTooltip(c, name); item.add(c); + Label lb = new Label("lineBreak", "
"); + lb.setVisible(breakLine); + lb.setRenderBodyOnly(true); + item.add(lb.setEscapeModelStrings(false)); } }; add(refsView); diff --git a/src/com/gitblit/wicket/panels/SearchPanel.java b/src/com/gitblit/wicket/panels/SearchPanel.java index 44b499b2..b9b13a50 100644 --- a/src/com/gitblit/wicket/panels/SearchPanel.java +++ b/src/com/gitblit/wicket/panels/SearchPanel.java @@ -105,7 +105,12 @@ public class SearchPanel extends BasePanel { } String shortMessage = entry.getShortMessage(); - String trimmedMessage = StringUtils.trimShortLog(shortMessage); + String trimmedMessage = shortMessage; + if (allRefs.containsKey(entry.getId())) { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS); + } else { + trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); + } LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter( repositoryName, entry.getName())); diff --git a/src/com/gitblit/wicket/panels/TagsPanel.html b/src/com/gitblit/wicket/panels/TagsPanel.html index c9c19a37..899f9cbc 100644 --- a/src/com/gitblit/wicket/panels/TagsPanel.html +++ b/src/com/gitblit/wicket/panels/TagsPanel.html @@ -8,7 +8,7 @@ -
[tags header]
+
[tags header]
diff --git a/src/com/gitblit/wicket/panels/TagsPanel.java b/src/com/gitblit/wicket/panels/TagsPanel.java index 39d4092b..a06c1c2e 100644 --- a/src/com/gitblit/wicket/panels/TagsPanel.java +++ b/src/com/gitblit/wicket/panels/TagsPanel.java @@ -36,7 +36,6 @@ import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.RawPage; import com.gitblit.wicket.pages.RepositoryPage; -import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagPage; import com.gitblit.wicket.pages.TagsPage; import com.gitblit.wicket.pages.TreePage; @@ -59,9 +58,7 @@ public class TagsPanel extends BasePanel { TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } else { // tags page - // show repository summary page link - add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); + add(new Label("header", new StringResourceModel("gb.tags", this, null))); } ListDataProvider tagsDp = new ListDataProvider(tags); @@ -92,7 +89,8 @@ public class TagsPanel extends BasePanel { .getReferencedObjectId().getName()))); // workaround for RevTag returning a lengthy shortlog. :( - String message = StringUtils.trimShortLog(entry.getShortMessage()); + String message = StringUtils.trimString(entry.getShortMessage(), + com.gitblit.Constants.LEN_SHORTLOG); if (linkClass.equals(BlobPage.class)) { // Blob Tag Object diff --git a/tests/com/gitblit/tests/StringUtilsTest.java b/tests/com/gitblit/tests/StringUtilsTest.java index 71d055f4..2e00fa3e 100644 --- a/tests/com/gitblit/tests/StringUtilsTest.java +++ b/tests/com/gitblit/tests/StringUtilsTest.java @@ -76,7 +76,7 @@ public class StringUtilsTest { public void testTrim() throws Exception { String input = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 "; String output = "123456789 123456789 123456789 123456789 123456789 1234567..."; - assertEquals(output, StringUtils.trimShortLog(input)); + assertEquals(output, StringUtils.trimString(input, 60)); assertEquals(input, StringUtils.trimString(input, input.length())); }