]> source.dussan.org Git - gitblit.git/commitdiff
Split refs into 2 lines if there are remotes. Use more glyphicons.
authorJames Moger <james.moger@gitblit.com>
Sat, 25 Feb 2012 15:54:22 +0000 (10:54 -0500)
committerJames Moger <james.moger@gitblit.com>
Sat, 25 Feb 2012 15:54:22 +0000 (10:54 -0500)
18 files changed:
src/com/gitblit/Constants.java
src/com/gitblit/utils/StringUtils.java
src/com/gitblit/wicket/WicketUtils.java
src/com/gitblit/wicket/pages/DocsPage.html
src/com/gitblit/wicket/pages/SummaryPage.html
src/com/gitblit/wicket/panels/ActivityPanel.html
src/com/gitblit/wicket/panels/ActivityPanel.java
src/com/gitblit/wicket/panels/BranchesPanel.html
src/com/gitblit/wicket/panels/BranchesPanel.java
src/com/gitblit/wicket/panels/HistoryPanel.java
src/com/gitblit/wicket/panels/LogPanel.html
src/com/gitblit/wicket/panels/LogPanel.java
src/com/gitblit/wicket/panels/RefsPanel.html
src/com/gitblit/wicket/panels/RefsPanel.java
src/com/gitblit/wicket/panels/SearchPanel.java
src/com/gitblit/wicket/panels/TagsPanel.html
src/com/gitblit/wicket/panels/TagsPanel.java
tests/com/gitblit/tests/StringUtilsTest.java

index a28a871a589aab909cb8d37ea7221ab75a765610..3f823de194271d88eced216fa617dfbd511bafe7 100644 (file)
@@ -65,6 +65,10 @@ public class Constants {
        \r
        public static final String ENCODING = "UTF-8";\r
        \r
+       public static final int LEN_SHORTLOG = 80;\r
+       \r
+       public static final int LEN_SHORTLOG_REFS = 60;\r
+       \r
        public static String getGitBlitVersion() {\r
                return NAME + " v" + VERSION;\r
        }\r
index fc0bf42ffa928059fc36ed02aa33daddb9674672..a465e0d7e8068fd8c08102ec75f64a2b10e6a86a 100644 (file)
@@ -168,16 +168,6 @@ public class StringUtils {
                return value.substring(0, max - 3) + "...";\r
        }\r
 \r
-       /**\r
-        * Returns a trimmed shortlog message.\r
-        * \r
-        * @param string\r
-        * @return trimmed shortlog message\r
-        */\r
-       public static String trimShortLog(String string) {\r
-               return trimString(string, 60);\r
-       }\r
-\r
        /**\r
         * Left pad a string with the specified character, if the string length is\r
         * less than the specified length.\r
index 7be5328eb79ecb7fd6665cdf913d3fe67e11aaa8..864ebe6aa0f30b5b2a3b2bb5b037c8503cfe5e64 100644 (file)
@@ -220,6 +220,19 @@ public class WicketUtils {
                return img;\r
        }\r
 \r
+       public static Label newIcon(String wicketId, String css) {\r
+               Label lbl = new Label(wicketId);\r
+               setCssClass(lbl, css);          \r
+               return lbl;\r
+       }\r
+       \r
+       public static Label newBlankIcon(String wicketId) {\r
+               Label lbl = new Label(wicketId);\r
+               setCssClass(lbl, "");\r
+               lbl.setRenderBodyOnly(true);\r
+               return lbl;\r
+       }\r
+       \r
        public static ContextRelativeResource getResource(String file) {\r
                return new ContextRelativeResource(file);\r
        }\r
index 0da4bde44d99de51ab2d8032bf41009271ea79fa..98432b5e4b3f3413d63e4486740b1285f0fdab79 100644 (file)
@@ -8,7 +8,7 @@
 <wicket:extend>\r
        \r
        <!-- header -->\r
-       <div style="margin-top:5px;" class="header"><span wicket:id="header">[header]</span></div>\r
+       <div style="margin-top:5px;" class="header"><i class="icon-book" style="vertical-align: middle;"></i> <b><span wicket:id="header">[header]</span></b></div>\r
        \r
        <!-- documents -->      \r
        <table style="width:100%" class="pretty">\r
index 941e777d36d8ad92483302bbb2e5daa8fe41f630..c2096a6fccb239e614b5e4e9c25b9c0b63cc6b51 100644 (file)
@@ -38,7 +38,7 @@
        \r
        <wicket:fragment wicket:id="markdownPanel">\r
                <div class="header" style="margin-top:10px;" >\r
-                       <img style="vertical-align: middle; border: 1px solid #888;" src="book_16x16.png"/>\r
+                       <i style="vertical-align: middle;" class="icon-book"></i>\r
                        <span style="font-weight:bold;vertical-align:middle;" wicket:id="readmeFile"></span>\r
                </div>\r
                <div style="border:1px solid #ddd;border-radius: 0 0 3px 3px;padding: 20px;">\r
index 4c0566cf4eae15ac53b8b3e3475ed6311767aae0..3a603bfbc43e6c5fdd21c7ae022167f2391eb02d 100644 (file)
@@ -8,7 +8,7 @@
 <wicket:panel>\r
 \r
        <div wicket:id="activity">\r
-               <div class="header"><span style="font-weight:bold;" wicket:id="title">[title]</span></div>\r
+               <div class="header"><i class="icon-refresh" style="vertical-align: middle;"></i> <span style="font-weight:bold;" wicket:id="title">[title]</span></div>\r
                <table class="activity" wicket:id="commits">\r
                        <tr wicket:id="commit"></tr>            \r
                </table>        \r
index 34a281fbafb32f6e782e0881ec94374141843760..dc94f3c1766b329ebe461648bd54f679d153b345 100644 (file)
@@ -113,7 +113,12 @@ public class ActivityPanel extends BasePanel {
 \r
                                                // message/commit link\r
                                                String shortMessage = commit.getShortMessage();\r
-                                               String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
+                                               String trimmedMessage = shortMessage;\r
+                                               if (commit.getRefs() != null && commit.getRefs().size() > 0) {\r
+                                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS);\r
+                                               } else {\r
+                                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);\r
+                                               }\r
                                                LinkPanel shortlog = new LinkPanel("message", "list subject",\r
                                                                trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(\r
                                                                                commit.repository, commit.getName()), true);\r
index 01fb8bac38b7bbcdfe10e9d3198e462835b68511..114541fba75dcb3e836b412093aecab971a57cbd 100644 (file)
@@ -8,7 +8,7 @@
 <wicket:panel>\r
 \r
        <!-- header -->\r
-       <div class="header"><img style="vertical-align: middle;" src="commit_branch_16x16.png"></img><span wicket:id="branches">[branches header]</span></div>  \r
+       <div class="header"><i class="icon-random" style="vertical-align: middle;"></i> <b><span wicket:id="branches">[branches header]</span></b></div>        \r
        \r
        <table class="pretty">\r
                <tbody>\r
index 6eb4019940c30f0d4b9c14ff535c4d16dbc01fa6..0d2fe4a941fbbdbd26706f9742ade469aea6fa66 100644 (file)
@@ -41,7 +41,6 @@ import com.gitblit.wicket.pages.CommitPage;
 import com.gitblit.wicket.pages.LogPage;\r
 import com.gitblit.wicket.pages.MetricsPage;\r
 import com.gitblit.wicket.pages.SearchPage;\r
-import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class BranchesPanel extends BasePanel {\r
@@ -73,9 +72,7 @@ public class BranchesPanel extends BasePanel {
                                        null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name)));\r
                } else {\r
                        // branches page\r
-                       // show repository summary page link\r
-                       add(new LinkPanel("branches", "title", model.name, SummaryPage.class,\r
-                                       WicketUtils.newRepositoryParameter(model.name)));\r
+                       add(new Label("branches", new StringResourceModel("gb.branches", this, null)));\r
                }\r
 \r
                ListDataProvider<RefModel> branchesDp = new ListDataProvider<RefModel>(branches);\r
@@ -101,7 +98,7 @@ public class BranchesPanel extends BasePanel {
 \r
                                // short message\r
                                String shortMessage = entry.getShortMessage();\r
-                               String trimmedMessage = StringUtils.trimShortLog(shortMessage);\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
index 16f95f227555969eca7dab88a53a8ebff0077736..36a768062ea411937f73f8c3b176b5859bcef815 100644 (file)
@@ -121,7 +121,12 @@ public class HistoryPanel extends BasePanel {
                                }\r
 \r
                                String shortMessage = entry.getShortMessage();\r
-                               String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
+                               String trimmedMessage = shortMessage;\r
+                               if (allRefs.containsKey(entry.getId())) {\r
+                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS);\r
+                               } else {\r
+                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);\r
+                               }\r
                                LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject",\r
                                                trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(\r
                                                                repositoryName, entry.getName()));\r
index 700f66a1389c8f0b4e418caf343cba44fff25256..96173062d7b02edb23a8c879858b02b63f67219d 100644 (file)
@@ -8,14 +8,14 @@
 <wicket:panel>\r
 \r
        <!-- header --> \r
-       <div class="header"><img style="vertical-align: middle;" src="commit_changes_16x16.png"></img><span wicket:id="header">[log header]</span></div>\r
+       <div class="header"><i class="icon-refresh" style="vertical-align: middle;"></i> <b><span wicket:id="header">[log header]</span></b></div>\r
        <table class="pretty">\r
                <tbody>\r
                        <tr wicket:id="commit">\r
                        <td class="date"><span wicket:id="commitDate">[commit date]</span></td>\r
                        <td class="author"><span wicket:id="commitAuthor">[commit author]</span></td>\r
                        <td class="icon"><img wicket:id="commitIcon" /></td>\r
-                       <td><div class="references" wicket:id="commitRefs">[commit refs]</div><span wicket:id="commitShortMessage">[commit short message]</span></td>\r
+                       <td><div class="references" wicket:id="commitRefs">[commit refs]</div><div style="vertical-align:middle;" wicket:id="commitShortMessage">[commit short message]</div></td>\r
                        <td class="rightAlign">\r
                                <span class="link">\r
                                                <a wicket:id="view"><wicket:message key="gb.view"></wicket:message></a> | <a wicket:id="diff"><wicket:message key="gb.diff"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>\r
index 74764d6d2a4c66f674d63df03db2e3dc78fdf60c..a960f6e0bc89e80962ebee9c5fbd6e73396924de 100644 (file)
@@ -40,7 +40,6 @@ import com.gitblit.wicket.pages.CommitDiffPage;
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
 import com.gitblit.wicket.pages.SearchPage;\r
-import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class LogPanel extends BasePanel {\r
@@ -75,9 +74,7 @@ public class LogPanel extends BasePanel {
                // header\r
                if (pageResults) {\r
                        // shortlog page\r
-                       // show repository summary page link\r
-                       add(new LinkPanel("header", "title", objectId, SummaryPage.class,\r
-                                       WicketUtils.newRepositoryParameter(repositoryName)));\r
+                       add(new Label("header", objectId));\r
                } else {\r
                        // summary page\r
                        // show shortlog page link\r
@@ -113,7 +110,12 @@ public class LogPanel extends BasePanel {
 \r
                                // short message\r
                                String shortMessage = entry.getShortMessage();\r
-                               String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
+                               String trimmedMessage = shortMessage;\r
+                               if (allRefs.containsKey(entry.getId())) {\r
+                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS);\r
+                               } else {\r
+                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);\r
+                               }\r
                                LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject",\r
                                                trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(\r
                                                                repositoryName, entry.getName()));\r
index 5d301931d7b061b15258b35c6bb0fc5434fef174..a3c0ec496bc872ed9ede426c046eb873146ecdc6 100644 (file)
@@ -6,7 +6,7 @@
 \r
 <wicket:panel>\r
        <span wicket:id="ref">\r
-               <span wicket:id="refName">ref</span>\r
+               <span wicket:id="lineBreak">[LB]</span><span wicket:id="refName">ref</span>\r
        </span> \r
 </wicket:panel>\r
 </html>
\ No newline at end of file
index f25b53b2e032d785d0ed786b72c08fc4474141b8..86e74a145c99ac94e156ffe54322b67d0822d6ff 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;\r
 \r
 import org.apache.wicket.Component;\r
+import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.panel.Panel;\r
 import org.apache.wicket.markup.repeater.Item;\r
 import org.apache.wicket.markup.repeater.data.DataView;\r
@@ -54,19 +55,48 @@ public class RefsPanel extends Panel {
                Collections.sort(refs, new Comparator<RefModel>() {\r
                        @Override\r
                        public int compare(RefModel o1, RefModel o2) {\r
+                               // sort remote heads last, otherwise sort by name\r
+                               // this is so we can insert a break on the refs panel\r
+                               // [head][branch][branch][tag][tag]\r
+                               // [remote][remote][remote]\r
+                               boolean remote1 = o1.displayName.startsWith(Constants.R_REMOTES);\r
+                               boolean remote2 = o2.displayName.startsWith(Constants.R_REMOTES);\r
+                               if (remote1 && remote2) {\r
+                                       // both are remote heads, sort by name\r
+                                       return o1.displayName.compareTo(o2.displayName);        \r
+                               }\r
+                               if (remote1) {\r
+                                       // o1 is remote, o2 comes first\r
+                                       return 1;\r
+                               }\r
+                               if (remote2) {\r
+                                       // remote is o2, o1 comes first\r
+                                       return -1;\r
+                               }\r
+                               // standard sort\r
                                return o1.displayName.compareTo(o2.displayName);\r
                        }\r
                });\r
-\r
+               \r
+               // count remote and determine if we should insert a break\r
+               int remoteCount = 0;\r
+               for (RefModel ref : refs) {\r
+                       if (ref.displayName.startsWith(Constants.R_REMOTES)) {\r
+                               remoteCount++;\r
+                       }\r
+               }\r
+               final boolean shouldBreak = remoteCount < refs.size();\r
+               \r
                ListDataProvider<RefModel> refsDp = new ListDataProvider<RefModel>(refs);\r
                DataView<RefModel> refsView = new DataView<RefModel>("ref", refsDp) {\r
                        private static final long serialVersionUID = 1L;\r
+                       private boolean alreadyInsertedBreak = !shouldBreak;\r
 \r
                        public void populateItem(final Item<RefModel> item) {\r
                                RefModel entry = item.getModelObject();\r
                                String name = entry.displayName;\r
                                String objectid = entry.getReferencedObjectId().getName();\r
-\r
+                               boolean breakLine = false;\r
                                Class<? extends RepositoryPage> linkClass = CommitPage.class;\r
                                String cssClass = "";\r
                                if (name.startsWith(Constants.R_HEADS)) {\r
@@ -83,6 +113,10 @@ public class RefsPanel extends Panel {
                                        linkClass = LogPage.class;\r
                                        name = name.substring(Constants.R_REMOTES.length());\r
                                        cssClass = "remoteBranch";\r
+                                       if (!alreadyInsertedBreak) {\r
+                                               breakLine = true;\r
+                                               alreadyInsertedBreak = true;\r
+                                       }\r
                                } else if (name.startsWith(Constants.R_TAGS)) {\r
                                        // tag\r
                                        if (entry.isAnnotatedTag()) {\r
@@ -104,6 +138,10 @@ public class RefsPanel extends Panel {
                                WicketUtils.setCssClass(c, cssClass);\r
                                WicketUtils.setHtmlTooltip(c, name);\r
                                item.add(c);\r
+                               Label lb = new Label("lineBreak", "<br/>");\r
+                               lb.setVisible(breakLine);\r
+                               lb.setRenderBodyOnly(true);\r
+                               item.add(lb.setEscapeModelStrings(false));\r
                        }\r
                };\r
                add(refsView);\r
index 44b499b23f48bf8cedff0679575cea95af3193cc..b9b13a50cbaad6bdfc307ea377d1695df3e58248 100644 (file)
@@ -105,7 +105,12 @@ public class SearchPanel extends BasePanel {
                                }\r
 \r
                                String shortMessage = entry.getShortMessage();\r
-                               String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
+                               String trimmedMessage = shortMessage;\r
+                               if (allRefs.containsKey(entry.getId())) {\r
+                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS);\r
+                               } else {\r
+                                       trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);\r
+                               }\r
                                LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject",\r
                                                trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(\r
                                                                repositoryName, entry.getName()));\r
index c9c19a376b34894320abcb389fc4bf5f95eb3183..899f9cbcea46bf4db5cefacfa0ef52f897f170e9 100644 (file)
@@ -8,7 +8,7 @@
 <wicket:panel>\r
 \r
        <!-- tags -->\r
-       <div class="header"><img style="vertical-align: middle;" src="tag_16x16.png"></img><span wicket:id="header">[tags header]</span></div>  \r
+       <div class="header"><i class="icon-tags" style="vertical-align: middle;"></i> <b><span wicket:id="header">[tags header]</span></b></div>        \r
        <table class="pretty">\r
                <tbody>\r
                <tr wicket:id="tag">\r
index 39d4092bb2074d40dd997f0db38983d2d680806c..a06c1c2e8bacf9a8e4d048759cddfb991eaeb07f 100644 (file)
@@ -36,7 +36,6 @@ import com.gitblit.wicket.pages.CommitPage;
 import com.gitblit.wicket.pages.LogPage;\r
 import com.gitblit.wicket.pages.RawPage;\r
 import com.gitblit.wicket.pages.RepositoryPage;\r
-import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TagPage;\r
 import com.gitblit.wicket.pages.TagsPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
@@ -59,9 +58,7 @@ public class TagsPanel extends BasePanel {
                                        TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
                } else {\r
                        // tags page\r
-                       // show repository summary page link\r
-                       add(new LinkPanel("header", "title", repositoryName, SummaryPage.class,\r
-                                       WicketUtils.newRepositoryParameter(repositoryName)));\r
+                       add(new Label("header", new StringResourceModel("gb.tags", this, null)));\r
                }\r
 \r
                ListDataProvider<RefModel> tagsDp = new ListDataProvider<RefModel>(tags);\r
@@ -92,7 +89,8 @@ public class TagsPanel extends BasePanel {
                                                                .getReferencedObjectId().getName())));\r
 \r
                                // workaround for RevTag returning a lengthy shortlog. :(\r
-                               String message = StringUtils.trimShortLog(entry.getShortMessage());\r
+                               String message = StringUtils.trimString(entry.getShortMessage(), \r
+                                               com.gitblit.Constants.LEN_SHORTLOG);\r
 \r
                                if (linkClass.equals(BlobPage.class)) {\r
                                        // Blob Tag Object\r
index 71d055f46b88e0387b4811026271ef6320faf77c..2e00fa3e5f4f2597fa3339e719751ea5353be1b0 100644 (file)
@@ -76,7 +76,7 @@ public class StringUtilsTest {
        public void testTrim() throws Exception {\r
                String input = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 ";\r
                String output = "123456789 123456789 123456789 123456789 123456789 1234567...";\r
-               assertEquals(output, StringUtils.trimShortLog(input));\r
+               assertEquals(output, StringUtils.trimString(input, 60));\r
                assertEquals(input, StringUtils.trimString(input, input.length()));\r
        }\r
 \r