Add sorting Sones by posts.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 29 Jun 2011 07:13:11 +0000 (09:13 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 29 Jun 2011 07:13:11 +0000 (09:13 +0200)
src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java
src/main/resources/templates/knownSones.html

index 0eedec6..ad63791 100644 (file)
@@ -90,6 +90,12 @@ public class KnownSonesPage extends SoneTemplatePage {
                        } else {
                                Collections.sort(knownSones, Sone.LAST_ACTIVITY_COMPARATOR);
                        }
+               } else if ("posts".equals(sortField)) {
+                       if ("asc".equals(sortOrder)) {
+                               Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.POST_COUNT_COMPARATOR));
+                       } else {
+                               Collections.sort(knownSones, Sone.POST_COUNT_COMPARATOR);
+                       }
                } else {
                        if ("desc".equals(sortOrder)) {
                                Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.NICE_NAME_COMPARATOR));
index ab36861..d3f4846 100644 (file)
@@ -7,7 +7,7 @@
                $(document).ready(function() {
                        $("select[name=sort]").change(function() {
                                value = $(this).val();
-                               if (value == "activity") {
+                               if ((value == "activity") || (value == "posts")) {
                                        $("select[name=order]").val("desc");
                                } else if (value == "name") {
                                        $("select[name=order]").val("asc");
@@ -29,6 +29,7 @@
                                <select name="sort">
                                        <option value="name"<%if sort|match value="name"> selected="selected"<%/if>>Name</option>
                                        <option value="activity"<%if sort|match value="activity"> selected="selected"<%/if>>Last activity</option>
+                                       <option value="posts"<%if sort|match value="posts"> selected="selected"<%/if>>Number of posts</option>
                                </select>
                                <select name="order">
                                        <option value="asc"<%if order|match value="asc"> selected="selected"<%/if>>Ascending</option>