Add “sort by image count” for Known Sones.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 30 Sep 2011 12:57:37 +0000 (14:57 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 30 Sep 2011 12:57:37 +0000 (14:57 +0200)
src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java
src/main/resources/templates/knownSones.html

index e5acad5..0e27265 100644 (file)
@@ -97,6 +97,12 @@ public class KnownSonesPage extends SoneTemplatePage {
                        } else {
                                Collections.sort(knownSones, Sone.POST_COUNT_COMPARATOR);
                        }
+               } else if ("images".equals(sortField)) {
+                       if ("asc".equals(sortOrder)) {
+                               Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.IMAGE_COUNT_COMPARATOR));
+                       } else {
+                               Collections.sort(knownSones, Sone.IMAGE_COUNT_COMPARATOR);
+                       }
                } else {
                        if ("desc".equals(sortOrder)) {
                                Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.NICE_NAME_COMPARATOR));
index 260a321..72bc80a 100644 (file)
@@ -7,7 +7,7 @@
                $(document).ready(function() {
                        $("select[name=sort]").change(function() {
                                value = $(this).val();
-                               if ((value == "activity") || (value == "posts")) {
+                               if ((value == "activity") || (value == "posts") || (value == "images")) {
                                        $("select[name=order]").val("desc");
                                } else if (value == "name") {
                                        $("select[name=order]").val("asc");
@@ -30,6 +30,7 @@
                                        <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>
+                                       <option value="images"<%if sort|match value="images"> selected="selected"<%/if>>Number of images</option>
                                </select>
                                <select name="order">
                                        <option value="asc"<%if order|match value="asc"> selected="selected"<%/if>>Ascending</option>