From: David ‘Bombe’ Roden Date: Wed, 19 Jan 2011 18:12:40 +0000 (+0100) Subject: Merge branch 'mark-as-read' into next X-Git-Tag: 0.4.2^2~27 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ecf753a31601e558b681daab0598009fe9eec99a;p=Sone.git Merge branch 'mark-as-read' into next Conflicts: src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java --- ecf753a31601e558b681daab0598009fe9eec99a diff --cc src/main/java/net/pterodactylus/sone/template/SoneAccessor.java index 119a28e,911f5cd..27b4c24 --- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java @@@ -74,12 -74,12 +74,12 @@@ public class SoneAccessor extends Refle if (member.equals("niceName")) { return getNiceName(sone); } else if (member.equals("local")) { - return sone.getInsertUri() != null; + return core.isLocalSone(sone); } else if (member.equals("friend")) { - Sone currentSone = (Sone) dataProvider.get("currentSone"); + Sone currentSone = (Sone) templateContext.get("currentSone"); return (currentSone != null) && currentSone.hasFriend(sone.getId()); } else if (member.equals("current")) { - Sone currentSone = (Sone) dataProvider.get("currentSone"); + Sone currentSone = (Sone) templateContext.get("currentSone"); return (currentSone != null) && currentSone.equals(sone); } else if (member.equals("modified")) { return core.isModifiedSone(sone); diff --cc src/main/java/net/pterodactylus/sone/web/CreatePostPage.java index ef88fd6,8e60287..57eb18a --- a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java @@@ -56,20 -56,15 +56,20 @@@ public class CreatePostPage extends Son if (request.getMethod() == Method.POST) { String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim(); if (text.length() != 0) { + String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43); String recipientId = request.getHttpRequest().getPartAsStringFailsafe("recipient", 43); - Sone recipient = webInterface.getCore().getSone(recipientId, false); Sone currentSone = getCurrentSone(request.getToadletContext()); - webInterface.getCore().createPost(currentSone, recipient, System.currentTimeMillis(), text); + Sone sender = webInterface.getCore().getLocalSone(senderId, false); + if (sender == null) { + sender = currentSone; + } + Sone recipient = webInterface.getCore().getSone(recipientId, false); + webInterface.getCore().createPost(sender, recipient, System.currentTimeMillis(), text); throw new RedirectException(returnPage); } - dataProvider.set("errorTextEmpty", true); + templateContext.set("errorTextEmpty", true); } - dataProvider.set("returnPage", returnPage); + templateContext.set("returnPage", returnPage); } } diff --cc src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java index d3b7c35,0b7e88f..aae5e83 --- a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java @@@ -58,19 -58,15 +58,19 @@@ public class CreateReplyPage extends So if (request.getMethod() == Method.POST) { Post post = webInterface.getCore().getPost(postId); if (text.length() > 0) { - Sone currentSone = getCurrentSone(request.getToadletContext()); - webInterface.getCore().createReply(currentSone, post, text); + String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43); + Sone sender = webInterface.getCore().getLocalSone(senderId, false); + if (sender == null) { + sender = getCurrentSone(request.getToadletContext()); + } + webInterface.getCore().createReply(sender, post, text); throw new RedirectException(returnPage); } - dataProvider.set("errorTextEmpty", true); + templateContext.set("errorTextEmpty", true); } - dataProvider.set("postId", postId); - dataProvider.set("text", text); - dataProvider.set("returnPage", returnPage); + templateContext.set("postId", postId); + templateContext.set("text", text); + templateContext.set("returnPage", returnPage); } } diff --cc src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index 78c9f22,ecbb368..7a36d02 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@@ -18,9 -18,10 +18,9 @@@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.Page.Request.Method; - import net.pterodactylus.util.template.DataProvider; import net.pterodactylus.util.template.Template; + import net.pterodactylus.util.template.TemplateContext; /** * Lets the user delete a post they made. diff --cc src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java index e10036b,67a6f3d..782589f --- a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java @@@ -18,9 -18,10 +18,9 @@@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Reply; -import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.Page.Request.Method; - import net.pterodactylus.util.template.DataProvider; import net.pterodactylus.util.template.Template; + import net.pterodactylus.util.template.TemplateContext; /** * This page lets the user delete a reply. diff --cc src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 9619531,c1afade..fa43945 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@@ -186,15 -186,14 +186,15 @@@ public class SoneTemplatePage extends T * {@inheritDoc} */ @Override - protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException { - super.processTemplate(request, dataProvider); - dataProvider.set("currentSone", getCurrentSone(request.getToadletContext(), false)); - dataProvider.set("localSones", webInterface.getCore().getLocalSones()); - dataProvider.set("request", request); - dataProvider.set("currentVersion", SonePlugin.VERSION); - dataProvider.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion()); - dataProvider.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); - dataProvider.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); + protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + super.processTemplate(request, templateContext); + templateContext.set("currentSone", getCurrentSone(request.getToadletContext(), false)); ++ templateContext.set("localSones", webInterface.getCore().getLocalSones()); + templateContext.set("request", request); + templateContext.set("currentVersion", SonePlugin.VERSION); + templateContext.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion()); + templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); + templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); } /**