X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewSonePage.java;h=758b93d222ea095a209e8fd3c1a27bea3515a78c;hb=ee05a67b3f1e796b6c4bdcd709ef0983103c455f;hp=3f4d92d730ec47ca7087b856aa8cb55d263523e4;hpb=ece9119924c20b12ef1c2f0908a92dc8323f8884;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index 3f4d92d..758b93d 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -28,6 +28,7 @@ import java.util.Set; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.template.SoneAccessor; import net.pterodactylus.util.collection.Pagination; import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.template.Template; @@ -49,7 +50,7 @@ public class ViewSonePage extends SoneTemplatePage { * The Sone web interface */ public ViewSonePage(Template template, WebInterface webInterface) { - super("viewSone.html", template, "Page.ViewSone.Title", webInterface, false); + super("viewSone.html", template, webInterface, false); } // @@ -60,11 +61,29 @@ public class ViewSonePage extends SoneTemplatePage { * {@inheritDoc} */ @Override + protected String getPageTitle(Request request) { + String soneId = request.getHttpRequest().getParam("sone"); + Sone sone = webInterface.getCore().getSone(soneId, false); + if ((sone != null) && (sone.getTime() > 0)) { + String soneName = SoneAccessor.getNiceName(sone); + return soneName + " - " + webInterface.getL10n().getString("Page.ViewSone.Title"); + } + return webInterface.getL10n().getString("Page.ViewSone.Page.TitleWithoutSone"); + } + + /** + * {@inheritDoc} + */ + @Override protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); String soneId = request.getHttpRequest().getParam("sone"); Sone sone = webInterface.getCore().getSone(soneId, false); templateContext.set("sone", sone); + List sonePosts = sone.getPosts(); + Pagination postPagination = new Pagination(sonePosts, 10).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0)); + templateContext.set("postPagination", postPagination); + templateContext.set("posts", postPagination.getItems()); Set replies = sone.getReplies(); final Map> repliedPosts = new HashMap>(); for (Reply reply : replies) { @@ -100,7 +119,7 @@ public class ViewSonePage extends SoneTemplatePage { return; } webInterface.getCore().markSoneKnown(sone); - List posts = sone.getPosts(); + List posts = (List) templateContext.get("posts"); posts.addAll((List) templateContext.get("repliedPosts")); for (Post post : posts) { if (post.getSone() != null) {