public class StringUtils {\r
\r
public static final String MD5_TYPE = "MD5:";\r
- \r
+\r
public static final String COMBINED_MD5_TYPE = "CMD5:";\r
\r
/**\r
}\r
});\r
}\r
-}\r
+\r
+ public static String getColor(String value) {\r
+ int cs = 0;\r
+ for (char c : getMD5(value.toLowerCase()).toCharArray()) {\r
+ cs += c;\r
+ }\r
+ int n = (cs % 360); \r
+ float hue = ((float) n) / 360;\r
+ return hsvToRgb(hue, 0.90f, 0.65f);\r
+ }\r
+\r
+ public static String hsvToRgb(float hue, float saturation, float value) {\r
+ int h = (int) (hue * 6);\r
+ float f = hue * 6 - h;\r
+ float p = value * (1 - saturation);\r
+ float q = value * (1 - f * saturation);\r
+ float t = value * (1 - (1 - f) * saturation);\r
+\r
+ switch (h) {\r
+ case 0:\r
+ return rgbToString(value, t, p);\r
+ case 1:\r
+ return rgbToString(q, value, p);\r
+ case 2:\r
+ return rgbToString(p, value, t);\r
+ case 3:\r
+ return rgbToString(p, q, value);\r
+ case 4:\r
+ return rgbToString(t, p, value);\r
+ case 5:\r
+ return rgbToString(value, p, q);\r
+ default:\r
+ throw new RuntimeException(\r
+ "Something went wrong when converting from HSV to RGB. Input was " + hue + ", "\r
+ + saturation + ", " + value);\r
+ }\r
+ }\r
+\r
+ public static String rgbToString(float r, float g, float b) {\r
+ String rs = Integer.toHexString((int) (r * 256));\r
+ String gs = Integer.toHexString((int) (g * 256));\r
+ String bs = Integer.toHexString((int) (b * 256));\r
+ return "#" + rs + gs + bs;\r
+ }\r
+}
\ No newline at end of file
</wicket:fragment>\r
\r
<wicket:fragment wicket:id="repositoryRow">\r
- <td class="left" style="padding-left:10px;" ><div class="list" wicket:id="repositoryName">[repository name]</div></td>\r
+ <td class="left" style="padding-left:3px;" ><span class="repositorySwatch" wicket:id="repositorySwatch"></span> <span style="padding-left:3px;" wicket:id="repositoryName">[repository name]</span></td>\r
<td><div class="list" wicket:id="repositoryDescription">[repository description]</div></td>\r
<td class="author"><span wicket:id="repositoryOwner">[repository owner]</span></td>\r
<td style="text-align: right;padding-right:10px;"><img class="inlineIcon" wicket:id="ticketsIcon" /><img class="inlineIcon" wicket:id="docsIcon" /><img class="inlineIcon" wicket:id="frozenIcon" /><img class="inlineIcon" wicket:id="federatedIcon" /><img class="inlineIcon" wicket:id="accessRestrictionIcon" /></td>\r
}\r
\r
final String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
+ final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);\r
\r
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("row", dp) {\r
private static final long serialVersionUID = 1L;\r
}\r
Fragment row = new Fragment("rowContent", "repositoryRow", this);\r
item.add(row);\r
- \r
+\r
// try to strip group name for less cluttered list\r
String repoName = entry.name;\r
if (!StringUtils.isEmpty(currGroupName) && (repoName.indexOf('/') > -1)) {\r
repoName = repoName.substring(currGroupName.length() + 1);\r
}\r
- \r
+\r
+ // repository swatch\r
+ Label swatch = new Label("repositorySwatch", " ");\r
+ WicketUtils.setCssBackground(swatch, entry.name);\r
+ row.add(swatch);\r
+ swatch.setVisible(showSwatch);\r
+\r
if (entry.hasCommits && linksActive) {\r
PageParameters pp = WicketUtils.newRepositoryParameter(entry.name);\r
row.add(new LinkPanel("repositoryName", "list", repoName, SummaryPage.class, pp));\r