From: David ‘Bombe’ Roden Date: Thu, 17 Mar 2011 06:15:28 +0000 (+0100) Subject: Merge branch 'release-0.5.1' X-Git-Tag: 0.5.1^0 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=963582b5c941b1abb4fa26555aece340184956e1;hp=13b6e1517335f9e1bcf883ddd6f27fde95ce551b Merge branch 'release-0.5.1' --- diff --git a/pom.xml b/pom.xml index a085e53..229f2ef 100644 --- a/pom.xml +++ b/pom.xml @@ -2,12 +2,12 @@ 4.0.0 net.pterodactylus sone - 0.5 + 0.5.1 net.pterodactylus utils - 0.9 + 0.9.1 junit diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index b2d1da4..7022f5e 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -93,10 +93,10 @@ public class SoneDownloader extends AbstractService { * The Sone to add */ public void addSone(Sone sone) { - if (sones.add(sone)) { + if (!sones.add(sone)) { freenetInterface.unregisterUsk(sone); - freenetInterface.registerUsk(sone, this); } + freenetInterface.registerUsk(sone, this); } /** diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 9c1b7da..0f7f0e8 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -78,7 +78,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 } /** The version. */ - public static final Version VERSION = new Version(0, 5); + public static final Version VERSION = new Version(0, 5, 1); /** The logger. */ private static final Logger logger = Logging.getLogger(SonePlugin.class); diff --git a/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java b/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java index d8a18c8..d6f63aa 100644 --- a/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java +++ b/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java @@ -24,6 +24,8 @@ import java.util.Set; import net.pterodactylus.sone.data.Post; import net.pterodactylus.util.collection.Pagination; +import net.pterodactylus.util.filter.Filter; +import net.pterodactylus.util.filter.Filters; import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -57,12 +59,20 @@ public class BookmarksPage extends SoneTemplatePage { @Override protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); - Set posts = webInterface.getCore().getBookmarkedPosts(); - List sortedPosts = new ArrayList(posts); + Set allPosts = webInterface.getCore().getBookmarkedPosts(); + Set loadedPosts = Filters.filteredSet(allPosts, new Filter() { + + @Override + public boolean filterObject(Post post) { + return post.getSone() != null; + } + }); + List sortedPosts = new ArrayList(loadedPosts); Collections.sort(sortedPosts, Post.TIME_COMPARATOR); Pagination pagination = new Pagination(sortedPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0)); templateContext.set("pagination", pagination); templateContext.set("posts", pagination.getItems()); + templateContext.set("postsNotLoaded", allPosts.size() != loadedPosts.size()); } } diff --git a/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java b/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java index 85a0359..85f46f0 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java @@ -17,6 +17,9 @@ package net.pterodactylus.sone.web; +import java.util.Set; + +import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.web.page.Page.Request.Method; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -54,6 +57,16 @@ public class UnbookmarkPage extends SoneTemplatePage { webInterface.getCore().unbookmarkPost(id); throw new RedirectException(returnPage); } + String id = request.getHttpRequest().getParam("post"); + if (id.equals("allNotLoaded")) { + Set posts = webInterface.getCore().getBookmarkedPosts(); + for (Post post : posts) { + if (post.getSone() == null) { + webInterface.getCore().unbookmark(post); + } + } + throw new RedirectException("bookmarks.html"); + } } } diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 4d912e9..9b48cad 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -167,7 +167,7 @@ Page.Unbookmark.Title=Remove Bookmark - Sone Page.Bookmarks.Title=Bookmarks - Sone Page.Bookmarks.Page.Title=Bookmarks Page.Bookmarks.Text.NoBookmarks=You don’t have any bookmarks defined right now. You can bookmark posts by clicking the star below the post. -Page.Bookmarks.Text.PostsNotLoaded=Some of your bookmarked posts have not been shown because they could not be loaded. This can happen if your restarted Sone recently or if the originating Sone has deleted the post. +Page.Bookmarks.Text.PostsNotLoaded=Some of your bookmarked posts have not been shown because they could not be loaded. This can happen if you restarted Sone recently or if the originating Sone has deleted the post. If you are reasonable sure that these posts do not exist anymore, you can {link}unbookmark them{/link}. Page.NoPermission.Title=Unauthorized Access - Sone Page.NoPermission.Page.Title=Unauthorized Access diff --git a/src/main/resources/templates/bookmarks.html b/src/main/resources/templates/bookmarks.html index af592db..8768b5a 100644 --- a/src/main/resources/templates/bookmarks.html +++ b/src/main/resources/templates/bookmarks.html @@ -7,21 +7,14 @@
<%include include/pagination.html> <%foreach posts post> - <%if post.loaded> - <%= true|store key=postShown> - <%include include/viewPost.html> - <%else> - <%= true|store key=postNotLoaded> - <%/if> + <%include include/viewPost.html> <%/foreach> - <%if postNotLoaded> -

<%= Page.Bookmarks.Text.PostsNotLoaded|l10n|html>

- <%else> - <%if !postShown> -

<%= Page.Bookmarks.Text.NoBookmarks|l10n|html>

- <%/if> - <%/if> <%include include/pagination.html> + <%if postsNotLoaded> +

<%= Page.Bookmarks.Text.PostsNotLoaded|l10n|html|replace needle='{link}' replacement=''|replace needle='{/link}' replacement=''>

+ <%elseif posts.empty> +

<%= Page.Bookmarks.Text.NoBookmarks|l10n|html>

+ <%/if>
<%include include/tail.html>