Add filter for new/not-new Sones.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 20 Nov 2011 10:10:05 +0000 (11:10 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 20 Nov 2011 10:10:05 +0000 (11:10 +0100)
src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/templates/knownSones.html

index 0e27265..6ed5667 100644 (file)
@@ -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<Sone> knownSones = Filters.filteredList(new ArrayList<Sone>(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<Sone>() {
 
                                @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<Sone>() {
 
                                @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<Sone>() {
+                               /**
+                                * {@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<Sone>() {
+                               /**
+                                * {@inheritDoc}
+                                */
+                               @Override
+                               public boolean filterObject(Sone sone) {
+                                       return !webInterface.getCore().isNewSone(sone.getId());
+                               }
+                       });
                }
                if ("activity".equals(sortField)) {
                        if ("asc".equals(sortOrder)) {
index afc445a..3bb04b7 100644 (file)
@@ -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
index 7b42d53..b25b11c 100644 (file)
                        </div>
                        <%ifnull !currentSone>
                                <div>
-                                       <%= Page.KnownSones.Label.FollowedSones|l10n|html>
-                                       <select name="followedSones">
+                                       <%= Page.KnownSones.Label.FilterSones|l10n|html>
+                                       <select name="filter">
                                                <option value="none"></option>
-                                               <option value="show-only"<%if followedSones|match value="show-only"> selected="selected"<%/if>><%= Page.KnownSones.FollowedSones.ShowOnly|l10n|html></option>
-                                               <option value="hide"<%if followedSones|match value="hide"> selected="selected"<%/if>><%= Page.KnownSones.FollowedSones.Hide|l10n|html></option>
+                                               <%ifnull !currentSone>
+                                                       <option value="followed"<%if filter|match value="followed"> selected="selected"<%/if>><%= Page.KnownSones.Filter.Followed|l10n|html></option>
+                                                       <option value="not-followed"<%if filter|match value="not-followed"> selected="selected"<%/if>><%= Page.KnownSones.Filter.NotFollowed|l10n|html></option>
+                                               <%/if>
+                                               <option value="new"<%if filter|match value="new"> selected="selected"<%/if>><%= Page.KnownSones.Filter.New|l10n|html></option>
+                                               <option value="not-new"<%if filter|match value="not-new"> selected="selected"<%/if>><%= Page.KnownSones.Filter.NotNew|l10n|html></option>
                                        </select>
                                </div>
                        <%/if>