Merge branch 'mark-as-read' into next
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Jan 2011 18:12:40 +0000 (19:12 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Jan 2011 18:12:40 +0000 (19:12 +0100)
Conflicts:
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java

1  2 
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java
src/main/java/net/pterodactylus/sone/web/DeletePostPage.java
src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js

@@@ -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);
@@@ -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);
        }
  
  }
@@@ -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);
        }
  
  }
  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.
  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.
@@@ -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());
        }
  
        /**