<modelVersion>4.0.0</modelVersion>
<groupId>net.pterodactylus</groupId>
<artifactId>sone</artifactId>
- <version>0.5</version>
+ <version>0.5.1</version>
<dependencies>
<dependency>
<groupId>net.pterodactylus</groupId>
<artifactId>utils</artifactId>
- <version>0.9</version>
+ <version>0.9.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
* 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);
}
/**
}
/** 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);
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;
@Override
protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
- Set<Post> posts = webInterface.getCore().getBookmarkedPosts();
- List<Post> sortedPosts = new ArrayList<Post>(posts);
+ Set<Post> allPosts = webInterface.getCore().getBookmarkedPosts();
+ Set<Post> loadedPosts = Filters.filteredSet(allPosts, new Filter<Post>() {
+
+ @Override
+ public boolean filterObject(Post post) {
+ return post.getSone() != null;
+ }
+ });
+ List<Post> sortedPosts = new ArrayList<Post>(loadedPosts);
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
Pagination<Post> pagination = new Pagination<Post>(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());
}
}
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;
webInterface.getCore().unbookmarkPost(id);
throw new RedirectException(returnPage);
}
+ String id = request.getHttpRequest().getParam("post");
+ if (id.equals("allNotLoaded")) {
+ Set<Post> posts = webInterface.getCore().getBookmarkedPosts();
+ for (Post post : posts) {
+ if (post.getSone() == null) {
+ webInterface.getCore().unbookmark(post);
+ }
+ }
+ throw new RedirectException("bookmarks.html");
+ }
}
}
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
<div id="posts">
<%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>
- <p><%= Page.Bookmarks.Text.PostsNotLoaded|l10n|html></p>
- <%else>
- <%if !postShown>
- <p><%= Page.Bookmarks.Text.NoBookmarks|l10n|html></p>
- <%/if>
- <%/if>
<%include include/pagination.html>
+ <%if postsNotLoaded>
+ <p><%= Page.Bookmarks.Text.PostsNotLoaded|l10n|html|replace needle='{link}' replacement='<a href="unbookmark.html?post=allNotLoaded">'|replace needle='{/link}' replacement='</a>'></p>
+ <%elseif posts.empty>
+ <p><%= Page.Bookmarks.Text.NoBookmarks|l10n|html></p>
+ <%/if>
</div>
<%include include/tail.html>