- Sone sone = webInterface.getCore().getSone(soneId, false);
- templateContext.set("sone", sone);
- List<Post> sonePosts = sone.getPosts();
- Pagination<Post> postPagination = new Pagination<Post>(sonePosts, 10).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0));
+ Optional<Sone> sone = webInterface.getCore().getSone(soneId);
+ if (sone.isPresent()) {
+ String soneName = SoneAccessor.getNiceName(sone.get());
+ return soneName + " - " + webInterface.getL10n().getString("Page.ViewSone.Title");
+ }
+ return webInterface.getL10n().getString("Page.ViewSone.Page.TitleWithoutSone");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
+ String soneId = request.getHttpRequest().getParam("sone");
+ Optional<Sone> sone = webInterface.getCore().getSone(soneId);
+ templateContext.set("sone", sone.orNull());
+ templateContext.set("soneId", soneId);
+ if (!sone.isPresent()) {
+ return;
+ }
+ List<Post> sonePosts = sone.get().getPosts();
+ sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
+ Collections.sort(sonePosts, Post.NEWEST_FIRST);
+ Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("postPage"), 0));