From: David ‘Bombe’ Roden Date: Sun, 20 Nov 2011 10:10:05 +0000 (+0100) Subject: Add filter for new/not-new Sones. X-Git-Tag: 0.7.4^2~10 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=00d11d64ca4247b81f54a806c14e7b9cfb961cf5;p=Sone.git Add filter for new/not-new Sones. --- diff --git a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java index 0e27265..6ed5667 100644 --- a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java +++ b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java @@ -62,13 +62,13 @@ public class KnownSonesPage extends SoneTemplatePage { super.processTemplate(request, templateContext); String sortField = request.getHttpRequest().getParam("sort"); String sortOrder = request.getHttpRequest().getParam("order"); - String followedSones = request.getHttpRequest().getParam("followedSones"); + String filter = request.getHttpRequest().getParam("filter"); templateContext.set("sort", (sortField != null) ? sortField : "name"); templateContext.set("order", (sortOrder != null) ? sortOrder : "asc"); - templateContext.set("followedSones", followedSones); + templateContext.set("filter", filter); final Sone currentSone = getCurrentSone(request.getToadletContext(), false); List knownSones = Filters.filteredList(new ArrayList(webInterface.getCore().getSones()), Sone.EMPTY_SONE_FILTER); - if ((currentSone != null) && "show-only".equals(followedSones)) { + if ((currentSone != null) && "followed".equals(filter)) { knownSones = Filters.filteredList(knownSones, new Filter() { @Override @@ -76,7 +76,7 @@ public class KnownSonesPage extends SoneTemplatePage { return currentSone.hasFriend(sone.getId()); } }); - } else if ((currentSone != null) && "hide".equals(followedSones)) { + } else if ((currentSone != null) && "not-followed".equals(filter)) { knownSones = Filters.filteredList(knownSones, new Filter() { @Override @@ -84,6 +84,26 @@ public class KnownSonesPage extends SoneTemplatePage { return !currentSone.hasFriend(sone.getId()); } }); + } else if ("new".equals(filter)) { + knownSones = Filters.filteredList(knownSones, new Filter() { + /** + * {@inheritDoc} + */ + @Override + public boolean filterObject(Sone sone) { + return webInterface.getCore().isNewSone(sone.getId()); + } + }); + } else if ("not-new".equals(filter)) { + knownSones = Filters.filteredList(knownSones, new Filter() { + /** + * {@inheritDoc} + */ + @Override + public boolean filterObject(Sone sone) { + return !webInterface.getCore().isNewSone(sone.getId()); + } + }); } if ("activity".equals(sortField)) { if ("asc".equals(sortOrder)) { diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index afc445a..3bb04b7 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -89,17 +89,19 @@ Page.Index.PostList.Text.NoPostYet=Nobody has written any posts yet. You should Page.KnownSones.Title=Known Sones - Sone Page.KnownSones.Page.Title=Known Sones -Page.KnownSones.Text.NoKnownSones=There are currently no known Sones. +Page.KnownSones.Text.NoKnownSones=There are currently no known Sones that match the given filter. Page.KnownSones.Label.Sort=Sort: -Page.KnownSones.Label.FollowedSones=Followed Sones: +Page.KnownSones.Label.FilterSones=Filter Sones: Page.KnownSones.Sort.Field.Name=Name Page.KnownSones.Sort.Field.LastActivity=Last activity Page.KnownSones.Sort.Field.Posts=Number of posts Page.KnownSones.Sort.Field.Images=Number of images Page.KnownSones.Sort.Order.Ascending=Ascending Page.KnownSones.Sort.Order.Descending=Descending -Page.KnownSones.FollowedSones.ShowOnly=Show only followed Sones -Page.KnownSones.FollowedSones.Hide=Hide followed Sones +Page.KnownSones.Filter.Followed=Show only followed Sones +Page.KnownSones.Filter.NotFollowed=Hide followed Sones +Page.KnownSones.Filter.New=Show only new Sones +Page.KnownSones.Filter.NotNew=Hide new Sones Page.KnownSones.Button.Apply=Apply Page.KnownSones.Button.FollowAllSones=Follow all Sones on this page Page.KnownSones.Button.UnfollowAllSones=Unfollow all Sones on this page diff --git a/src/main/resources/templates/knownSones.html b/src/main/resources/templates/knownSones.html index 7b42d53..b25b11c 100644 --- a/src/main/resources/templates/knownSones.html +++ b/src/main/resources/templates/knownSones.html @@ -39,11 +39,15 @@ <%ifnull !currentSone>
- <%= Page.KnownSones.Label.FollowedSones|l10n|html> - - - + <%ifnull !currentSone> + + + <%/if> + +
<%/if>