summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils/StringUtils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-09-30 17:20:15 -0400
committerJames Moger <james.moger@gitblit.com>2011-09-30 17:20:15 -0400
commit94750e9faea7e383db64df6d2ac4290eaa267770 (patch)
treebde723962baf325c17f946374df2df609756ece2 /src/com/gitblit/utils/StringUtils.java
parentfd6ac68c0b1136182b5d713ec88ea94e26c4a76d (diff)
downloadgitblit-94750e9faea7e383db64df6d2ac4290eaa267770.tar.gz
gitblit-94750e9faea7e383db64df6d2ac4290eaa267770.zip
More Bootstrap improvements.
* Strip leading group name from repositories page. * Put topbars on all pages. * Properly sort repositories in all locations. * White Gitblit logo.
Diffstat (limited to 'src/com/gitblit/utils/StringUtils.java')
-rw-r--r--src/com/gitblit/utils/StringUtils.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/com/gitblit/utils/StringUtils.java b/src/com/gitblit/utils/StringUtils.java
index 77d3cbbc..f4e9256f 100644
--- a/src/com/gitblit/utils/StringUtils.java
+++ b/src/com/gitblit/utils/StringUtils.java
@@ -19,6 +19,8 @@ import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.regex.PatternSyntaxException;
@@ -395,4 +397,44 @@ public class StringUtils {
}
return false;
}
+
+ /**
+ * Compare two repository names for proper group sorting.
+ *
+ * @param r1
+ * @param r2
+ * @return
+ */
+ public static int compareRepositoryNames(String r1, String r2) {
+ // sort root repositories first, alphabetically
+ // then sort grouped repositories, alphabetically
+ int s1 = r1.indexOf('/');
+ int s2 = r2.indexOf('/');
+ if (s1 == -1 && s2 == -1) {
+ // neither grouped
+ return r1.compareTo(r2);
+ } else if (s1 > -1 && s2 > -1) {
+ // both grouped
+ return r1.compareTo(r2);
+ } else if (s1 == -1) {
+ return -1;
+ } else if (s2 == -1) {
+ return 1;
+ }
+ return 0;
+ }
+
+ /**
+ * Sort grouped repository names.
+ *
+ * @param list
+ */
+ public static void sortRepositorynames(List<String> list) {
+ Collections.sort(list, new Comparator<String>() {
+ @Override
+ public int compare(String o1, String o2) {
+ return compareRepositoryNames(o1, o2);
+ }
+ });
+ }
}