Merge branch 'edit-wot-trust' into next
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 15 Jan 2011 20:30:26 +0000 (21:30 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 15 Jan 2011 20:30:26 +0000 (21:30 +0100)
Conflicts:
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/web/OptionsPage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java

1  2 
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/java/net/pterodactylus/sone/web/CreateSonePage.java
src/main/java/net/pterodactylus/sone/web/DistrustPage.java
src/main/java/net/pterodactylus/sone/web/OptionsPage.java
src/main/java/net/pterodactylus/sone/web/TrustPage.java
src/main/java/net/pterodactylus/sone/web/UntrustPage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js

@@@ -46,7 -47,7 +48,8 @@@ import net.pterodactylus.util.config.Co
  import net.pterodactylus.util.config.ConfigurationException;
  import net.pterodactylus.util.logging.Logging;
  import net.pterodactylus.util.number.Numbers;
+ import net.pterodactylus.util.validation.Validation;
 +import net.pterodactylus.util.version.Version;
  import freenet.keys.FreenetURI;
  
  /**
@@@ -1469,8 -1552,10 +1591,11 @@@ public class Core implements IdentityLi
  
                /* store the options first. */
                try {
 +                      configuration.getIntValue("Option/ConfigurationVersion").setValue(0);
                        configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal());
+                       configuration.getIntValue("Option/PositiveTrust").setValue(options.getIntegerOption("PositiveTrust").getReal());
+                       configuration.getIntValue("Option/NegativeTrust").setValue(options.getIntegerOption("NegativeTrust").getReal());
+                       configuration.getStringValue("Option/TrustComment").setValue(options.getStringOption("TrustComment").getReal());
                        configuration.getBooleanValue("Option/SoneRescueMode").setValue(options.getBooleanOption("SoneRescueMode").getReal());
                        configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal());
                        configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal());
         * {@inheritDoc}
         */
        @Override
-       public void identityRemoved(Identity identity) {
-               /* TODO */
+       public void identityRemoved(OwnIdentity ownIdentity, Identity identity) {
+               trustedIdentities.get(ownIdentity).remove(identity);
        }
  
 +      //
 +      // INTERFACE UpdateListener
 +      //
 +
 +      /**
 +       * {@inheritDoc}
 +       */
 +      @Override
 +      public void updateFound(Version version, long releaseTime) {
 +              coreListenerManager.fireUpdateFound(version, releaseTime);
 +      }
 +
  }
index 0000000,021fa6b..9cbbb55
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,68 +1,69 @@@
 -      protected void processTemplate(Request request, Template template) throws RedirectException {
 -              super.processTemplate(request, template);
+ /*
+  * Sone - TrustPage.java - Copyright © 2011 David Roden
+  *
+  * This program is free software: you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License as published by
+  * the Free Software Foundation, either version 3 of the License, or
+  * (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  */
+ package net.pterodactylus.sone.web;
+ import net.pterodactylus.sone.core.Core;
+ 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;
+ /**
+  * Page that lets the user distrust another Sone. This will assign a
+  * configurable (negative) amount of trust to an identity.
+  *
+  * @see Core#distrustSone(Sone, Sone)
+  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+  */
+ public class DistrustPage extends SoneTemplatePage {
+       /**
+        * Creates a new “distrust Sone” page.
+        *
+        * @param template
+        *            The template to render
+        * @param webInterface
+        *            The Sone web interface
+        */
+       public DistrustPage(Template template, WebInterface webInterface) {
+               super("distrust.html", template, "Page.Distrust.Title", webInterface, true);
+       }
+       //
+       // SONETEMPLATEPAGE METHODS
+       //
+       /**
+        * {@inheritDoc}
+        */
+       @Override
++      protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
++              super.processTemplate(request, dataProvider);
+               if (request.getMethod() == Method.POST) {
+                       String returnPath = request.getHttpRequest().getPartAsStringFailsafe("returnPath", 256);
+                       String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
+                       Sone currentSone = getCurrentSone(request.getToadletContext());
+                       Sone sone = webInterface.getCore().getSone(identity, false);
+                       if (sone != null) {
+                               webInterface.getCore().distrustSone(currentSone, sone);
+                       }
+                       throw new RedirectException(returnPath);
+               }
+       }
+ }
@@@ -65,10 -73,13 +74,13 @@@ public class OptionsPage extends SoneTe
                        webInterface.getCore().saveConfiguration();
                        throw new RedirectException(getPath());
                }
 -              template.set("insertion-delay", options.getIntegerOption("InsertionDelay").get());
 -              template.set("positive-trust", options.getIntegerOption("PositiveTrust").get());
 -              template.set("negative-trust", options.getIntegerOption("NegativeTrust").get());
 -              template.set("trust-comment", options.getStringOption("TrustComment").get());
 -              template.set("sone-rescue-mode", options.getBooleanOption("SoneRescueMode").get());
 -              template.set("clear-on-next-restart", options.getBooleanOption("ClearOnNextRestart").get());
 -              template.set("really-clear-on-next-restart", options.getBooleanOption("ReallyClearOnNextRestart").get());
 +              dataProvider.set("insertion-delay", options.getIntegerOption("InsertionDelay").get());
++              dataProvider.set("positive-trust", options.getIntegerOption("PositiveTrust").get());
++              dataProvider.set("negative-trust", options.getIntegerOption("NegativeTrust").get());
++              dataProvider.set("trust-comment", options.getStringOption("TrustComment").get());
 +              dataProvider.set("sone-rescue-mode", options.getBooleanOption("SoneRescueMode").get());
 +              dataProvider.set("clear-on-next-restart", options.getBooleanOption("ClearOnNextRestart").get());
 +              dataProvider.set("really-clear-on-next-restart", options.getBooleanOption("ReallyClearOnNextRestart").get());
        }
  
  }
index 0000000,ef64d62..85341ad
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,68 +1,69 @@@
 -      protected void processTemplate(Request request, Template template) throws RedirectException {
 -              super.processTemplate(request, template);
+ /*
+  * Sone - TrustPage.java - Copyright © 2011 David Roden
+  *
+  * This program is free software: you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License as published by
+  * the Free Software Foundation, either version 3 of the License, or
+  * (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  */
+ package net.pterodactylus.sone.web;
+ import net.pterodactylus.sone.core.Core;
+ 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;
+ /**
+  * Page that lets the user trust another Sone. This will assign a configurable
+  * amount of trust to an identity.
+  *
+  * @see Core#trustSone(Sone, Sone)
+  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+  */
+ public class TrustPage extends SoneTemplatePage {
+       /**
+        * Creates a new “trust Sone” page.
+        *
+        * @param template
+        *            The template to render
+        * @param webInterface
+        *            The Sone web interface
+        */
+       public TrustPage(Template template, WebInterface webInterface) {
+               super("trust.html", template, "Page.Trust.Title", webInterface, true);
+       }
+       //
+       // SONETEMPLATEPAGE METHODS
+       //
+       /**
+        * {@inheritDoc}
+        */
+       @Override
++      protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
++              super.processTemplate(request, dataProvider);
+               if (request.getMethod() == Method.POST) {
+                       String returnPath = request.getHttpRequest().getPartAsStringFailsafe("returnPath", 256);
+                       String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
+                       Sone currentSone = getCurrentSone(request.getToadletContext());
+                       Sone sone = webInterface.getCore().getSone(identity, false);
+                       if (sone != null) {
+                               webInterface.getCore().trustSone(currentSone, sone);
+                       }
+                       throw new RedirectException(returnPath);
+               }
+       }
+ }
index 0000000,8126215..cc9e26d
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,68 +1,69 @@@
 -      protected void processTemplate(Request request, Template template) throws RedirectException {
 -              super.processTemplate(request, template);
+ /*
+  * Sone - TrustPage.java - Copyright © 2011 David Roden
+  *
+  * This program is free software: you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License as published by
+  * the Free Software Foundation, either version 3 of the License, or
+  * (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  */
+ package net.pterodactylus.sone.web;
+ import net.pterodactylus.sone.core.Core;
+ 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;
+ /**
+  * Page that lets the user untrust another Sone. This will remove all trust
+  * assignments for an identity.
+  *
+  * @see Core#untrustSone(Sone, Sone)
+  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+  */
+ public class UntrustPage extends SoneTemplatePage {
+       /**
+        * Creates a new “untrust Sone” page.
+        *
+        * @param template
+        *            The template to render
+        * @param webInterface
+        *            The Sone web interface
+        */
+       public UntrustPage(Template template, WebInterface webInterface) {
+               super("untrust.html", template, "Page.Untrust.Title", webInterface, true);
+       }
+       //
+       // SONETEMPLATEPAGE METHODS
+       //
+       /**
+        * {@inheritDoc}
+        */
+       @Override
++      protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
++              super.processTemplate(request, dataProvider);
+               if (request.getMethod() == Method.POST) {
+                       String returnPath = request.getHttpRequest().getPartAsStringFailsafe("returnPath", 256);
+                       String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
+                       Sone currentSone = getCurrentSone(request.getToadletContext());
+                       Sone sone = webInterface.getCore().getSone(identity, false);
+                       if (sone != null) {
+                               webInterface.getCore().untrustSone(currentSone, sone);
+                       }
+                       throw new RedirectException(returnPath);
+               }
+       }
+ }
@@@ -56,10 -58,9 +59,11 @@@ import net.pterodactylus.sone.template.
  import net.pterodactylus.sone.web.ajax.CreatePostAjaxPage;
  import net.pterodactylus.sone.web.ajax.CreateReplyAjaxPage;
  import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage;
 +import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage;
  import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
  import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
+ import net.pterodactylus.sone.web.ajax.DistrustAjaxPage;
 +import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage;
  import net.pterodactylus.sone.web.ajax.FollowSoneAjaxPage;
  import net.pterodactylus.sone.web.ajax.GetLikesAjaxPage;
  import net.pterodactylus.sone.web.ajax.GetPostAjaxPage;
@@@ -70,7 -71,7 +74,8 @@@ import net.pterodactylus.sone.web.ajax.
  import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
  import net.pterodactylus.sone.web.ajax.MarkPostAsKnownPage;
  import net.pterodactylus.sone.web.ajax.MarkReplyAsKnownPage;
 +import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage;
+ import net.pterodactylus.sone.web.ajax.TrustAjaxPage;
  import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
  import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
  import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
@@@ -478,25 -474,14 +486,17 @@@ public class WebInterface implements Co
                Template createPostTemplate = templateFactory.createTemplate(createReader("/templates/createPost.html"));
                Template createReplyTemplate = templateFactory.createTemplate(createReader("/templates/createReply.html"));
                Template editProfileTemplate = templateFactory.createTemplate(createReader("/templates/editProfile.html"));
 +              Template editProfileFieldTemplate = templateFactory.createTemplate(createReader("/templates/editProfileField.html"));
 +              Template deleteProfileFieldTemplate = templateFactory.createTemplate(createReader("/templates/deleteProfileField.html"));
                Template viewSoneTemplate = templateFactory.createTemplate(createReader("/templates/viewSone.html"));
                Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html"));
-               Template likePostTemplate = templateFactory.createTemplate(createReader("/templates/like.html"));
-               Template unlikePostTemplate = templateFactory.createTemplate(createReader("/templates/unlike.html"));
                Template deletePostTemplate = templateFactory.createTemplate(createReader("/templates/deletePost.html"));
                Template deleteReplyTemplate = templateFactory.createTemplate(createReader("/templates/deleteReply.html"));
-               Template lockSoneTemplate = templateFactory.createTemplate(createReader("/templates/lockSone.html"));
-               Template unlockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unlockSone.html"));
-               Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
-               Template unfollowSoneTemplate = templateFactory.createTemplate(createReader("/templates/unfollowSone.html"));
                Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
                Template noPermissionTemplate = templateFactory.createTemplate(createReader("/templates/noPermission.html"));
-               Template dismissNotificationTemplate = templateFactory.createTemplate(createReader("/templates/dismissNotification.html"));
-               Template logoutTemplate = templateFactory.createTemplate(createReader("/templates/logout.html"));
                Template optionsTemplate = templateFactory.createTemplate(createReader("/templates/options.html"));
                Template aboutTemplate = templateFactory.createTemplate(createReader("/templates/about.html"));
 +              Template invalidTemplate = templateFactory.createTemplate(createReader("/templates/invalid.html"));
                Template postTemplate = templateFactory.createTemplate(createReader("/templates/include/viewPost.html"));
                Template replyTemplate = templateFactory.createTemplate(createReader("/templates/include/viewReply.html"));
  
                pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.VERSION), "About"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(dismissNotificationTemplate, this)));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
 +              pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("css/", "/static/css/", "text/css")));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("javascript/", "/static/javascript/", "text/javascript")));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("images/", "/static/images/", "image/png")));