\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
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
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
<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
\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
<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
\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
<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
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
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
\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
}\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
<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
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
// 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
\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
\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
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
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
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
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
}\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
<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
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
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
.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
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