From: David ‘Bombe’ Roden Date: Wed, 29 Jun 2011 07:13:11 +0000 (+0200) Subject: Add sorting Sones by posts. X-Git-Tag: 0.6.6^2~46 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=cf5e594a01b0ad11b1365e8d3f7b1c56f352d3f2;p=Sone.git Add sorting Sones by posts. --- diff --git a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java index 0eedec6..ad63791 100644 --- a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java +++ b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java @@ -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.POST_COUNT_COMPARATOR)); + } else { + Collections.sort(knownSones, Sone.POST_COUNT_COMPARATOR); + } } else { if ("desc".equals(sortOrder)) { Collections.sort(knownSones, new ReverseComparator(Sone.NICE_NAME_COMPARATOR)); diff --git a/src/main/resources/templates/knownSones.html b/src/main/resources/templates/knownSones.html index ab36861..d3f4846 100644 --- a/src/main/resources/templates/knownSones.html +++ b/src/main/resources/templates/knownSones.html @@ -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 @@