From: David ‘Bombe’ Roden Date: Fri, 7 Sep 2012 07:27:11 +0000 (+0200) Subject: Create links to posts using an excerpt from the parsed post, not the raw text. X-Git-Tag: 0.8.3^2~53 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=efb1006429e52a74f41fb6e1d7736736156bb13a;hp=00be7dff1eec2c325b03b0a6bbe7b1c9c515003b Create links to posts using an excerpt from the parsed post, not the raw text. This resolves #282. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 4001f46..9a40e5c 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -112,6 +112,9 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis /** The update checker. */ private final UpdateChecker updateChecker; + /** The trust updater. */ + private final TrustUpdater trustUpdater; + /** The FCP interface. */ private volatile FcpInterface fcpInterface; @@ -185,7 +188,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis * @param identityManager * The identity manager */ - public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager) { + public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, TrustUpdater trustUpdater) { super("Sone Core"); this.configuration = configuration; this.freenetInterface = freenetInterface; @@ -193,6 +196,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis this.soneDownloader = new SoneDownloader(this, freenetInterface); this.imageInserter = new ImageInserter(this, freenetInterface); this.updateChecker = new UpdateChecker(freenetInterface); + this.trustUpdater = trustUpdater; } // @@ -1054,6 +1058,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis logger.log(Level.WARNING, String.format("Tried to get trust from remote Sone: %s", origin)); return null; } + trustUpdater.getTrust((OwnIdentity) origin.getIdentity(), target.getIdentity()); return target.getIdentity().getTrust((OwnIdentity) origin.getIdentity()); } @@ -1069,11 +1074,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis */ public void setTrust(Sone origin, Sone target, int trustValue) { Validation.begin().isNotNull("Trust Origin", origin).check().isInstanceOf("Trust Origin", origin.getIdentity(), OwnIdentity.class).isNotNull("Trust Target", target).isLessOrEqual("Trust Value", trustValue, 100).isGreaterOrEqual("Trust Value", trustValue, -100).check(); - try { - ((OwnIdentity) origin.getIdentity()).setTrust(target.getIdentity(), trustValue, preferences.getTrustComment()); - } catch (WebOfTrustException wote1) { - logger.log(Level.WARNING, String.format("Could not set trust for Sone: %s", target), wote1); - } + trustUpdater.setTrust((OwnIdentity) origin.getIdentity(), target.getIdentity(), trustValue, preferences.getTrustComment()); } /** @@ -1086,11 +1087,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis */ public void removeTrust(Sone origin, Sone target) { Validation.begin().isNotNull("Trust Origin", origin).isNotNull("Trust Target", target).check().isInstanceOf("Trust Origin Identity", origin.getIdentity(), OwnIdentity.class).check(); - try { - ((OwnIdentity) origin.getIdentity()).removeTrust(target.getIdentity()); - } catch (WebOfTrustException wote1) { - logger.log(Level.WARNING, String.format("Could not remove trust for Sone: %s", target), wote1); - } + trustUpdater.setTrust((OwnIdentity) origin.getIdentity(), target.getIdentity(), null, null); } /** @@ -1967,6 +1964,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis loadConfiguration(); updateChecker.addUpdateListener(this); updateChecker.start(); + trustUpdater.start(); } /** @@ -1999,6 +1997,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis soneInserter.stop(); } } + trustUpdater.stop(); updateChecker.stop(); updateChecker.removeUpdateListener(this); soneDownloader.stop(); @@ -2174,9 +2173,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis configuration.getStringValue("Option/TrustComment").setValue(options.getStringOption("TrustComment").getReal()); configuration.getBooleanValue("Option/ActivateFcpInterface").setValue(options.getBooleanOption("ActivateFcpInterface").getReal()); configuration.getIntValue("Option/FcpFullAccessRequired").setValue(options.getIntegerOption("FcpFullAccessRequired").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()); /* save known Sones. */ int soneCounter = 0; @@ -2276,20 +2272,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis } })); - options.addBooleanOption("SoneRescueMode", new DefaultOption(false)); - options.addBooleanOption("ClearOnNextRestart", new DefaultOption(false)); - options.addBooleanOption("ReallyClearOnNextRestart", new DefaultOption(false)); - - /* read options from configuration. */ - options.getBooleanOption("ClearOnNextRestart").set(configuration.getBooleanValue("Option/ClearOnNextRestart").getValue(null)); - options.getBooleanOption("ReallyClearOnNextRestart").set(configuration.getBooleanValue("Option/ReallyClearOnNextRestart").getValue(null)); - boolean clearConfiguration = options.getBooleanOption("ClearOnNextRestart").get() && options.getBooleanOption("ReallyClearOnNextRestart").get(); - options.getBooleanOption("ClearOnNextRestart").set(null); - options.getBooleanOption("ReallyClearOnNextRestart").set(null); - if (clearConfiguration) { - /* stop loading the configuration. */ - return; - } loadConfigurationValue("InsertionDelay"); loadConfigurationValue("PostsPerPage"); @@ -2302,7 +2284,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis options.getStringOption("TrustComment").set(configuration.getStringValue("Option/TrustComment").getValue(null)); options.getBooleanOption("ActivateFcpInterface").set(configuration.getBooleanValue("Option/ActivateFcpInterface").getValue(null)); options.getIntegerOption("FcpFullAccessRequired").set(configuration.getIntValue("Option/FcpFullAccessRequired").getValue(null)); - options.getBooleanOption("SoneRescueMode").set(configuration.getBooleanValue("Option/SoneRescueMode").getValue(null)); /* load known Sones. */ int soneCounter = 0; @@ -2940,58 +2921,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis return this; } - /** - * Returns whether Sone should clear its settings on the next restart. - * In order to be effective, {@link #isReallyClearOnNextRestart()} needs - * to return {@code true} as well! - * - * @return {@code true} if Sone should clear its settings on the next - * restart, {@code false} otherwise - */ - public boolean isClearOnNextRestart() { - return options.getBooleanOption("ClearOnNextRestart").get(); - } - - /** - * Sets whether Sone will clear its settings on the next restart. - * - * @param clearOnNextRestart - * {@code true} if Sone should clear its settings on the next - * restart, {@code false} otherwise - * @return This preferences - */ - public Preferences setClearOnNextRestart(Boolean clearOnNextRestart) { - options.getBooleanOption("ClearOnNextRestart").set(clearOnNextRestart); - return this; - } - - /** - * Returns whether Sone should really clear its settings on next - * restart. This is a confirmation option that needs to be set in - * addition to {@link #isClearOnNextRestart()} in order to clear Sone’s - * settings on the next restart. - * - * @return {@code true} if Sone should really clear its settings on the - * next restart, {@code false} otherwise - */ - public boolean isReallyClearOnNextRestart() { - return options.getBooleanOption("ReallyClearOnNextRestart").get(); - } - - /** - * Sets whether Sone should really clear its settings on the next - * restart. - * - * @param reallyClearOnNextRestart - * {@code true} if Sone should really clear its settings on - * the next restart, {@code false} otherwise - * @return This preferences - */ - public Preferences setReallyClearOnNextRestart(Boolean reallyClearOnNextRestart) { - options.getBooleanOption("ReallyClearOnNextRestart").set(reallyClearOnNextRestart); - return this; - } - } } diff --git a/src/main/java/net/pterodactylus/sone/core/TrustUpdater.java b/src/main/java/net/pterodactylus/sone/core/TrustUpdater.java new file mode 100644 index 0000000..3f347d5 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/core/TrustUpdater.java @@ -0,0 +1,324 @@ +/* + * Sone - TrustUpdater.java - Copyright © 2012 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 . + */ + +package net.pterodactylus.sone.core; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.pterodactylus.sone.freenet.plugin.PluginException; +import net.pterodactylus.sone.freenet.wot.DefaultIdentity; +import net.pterodactylus.sone.freenet.wot.Identity; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; +import net.pterodactylus.sone.freenet.wot.Trust; +import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector; +import net.pterodactylus.sone.freenet.wot.WebOfTrustException; +import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.service.AbstractService; + +/** + * Updates identity’s trust in a background thread because getting updates from + * the WebOfTrust plugin can potentially last quite long. + * + * @author David ‘Bombe’ Roden + */ +public class TrustUpdater extends AbstractService { + + /** The logger. */ + private static final Logger logger = Logging.getLogger(TrustUpdater.class); + + /** Stop job. */ + private static final TrustUpdateJob stopJob = new TrustUpdateJob(null, null); + + /** The web of trust connector. */ + private final WebOfTrustConnector webOfTrustConnector; + + /** The queue for jobs. */ + private final BlockingQueue updateJobs = new LinkedBlockingQueue(); + + /** + * Creates a new trust updater. + * + * @param webOfTrustConnector + * The web of trust connector + */ + public TrustUpdater(WebOfTrustConnector webOfTrustConnector) { + super("Trust Updater"); + this.webOfTrustConnector = webOfTrustConnector; + } + + // + // ACTIONS + // + + /** + * Retrieves the trust relation between the truster and the trustee. This + * method will return immediately and perform a trust update in the + * background. + * + * @param truster + * The identity giving the trust + * @param trustee + * The identity receiving the trust + */ + public void getTrust(OwnIdentity truster, Identity trustee) { + GetTrustJob getTrustJob = new GetTrustJob(truster, trustee); + if (!updateJobs.contains(getTrustJob)) { + logger.log(Level.FINER, "Adding Trust Update Job: " + getTrustJob); + try { + updateJobs.put(getTrustJob); + } catch (InterruptedException ie1) { + /* the queue is unbounded so it should never block. */ + } + } + } + + /** + * Updates the trust relation between the truster and the trustee. This + * method will return immediately and perform a trust update in the + * background. + * + * @param truster + * The identity giving the trust + * @param trustee + * The identity receiving the trust + * @param score + * The new level of trust (from -100 to 100, may be {@code null} + * to remove the trust completely) + * @param comment + * The comment of the trust relation + */ + public void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment) { + SetTrustJob setTrustJob = new SetTrustJob(truster, trustee, score, comment); + if (updateJobs.contains(setTrustJob)) { + updateJobs.remove(setTrustJob); + } + logger.log(Level.FINER, "Adding Trust Update Job: " + setTrustJob); + try { + updateJobs.put(setTrustJob); + } catch (InterruptedException e) { + /* the queue is unbounded so it should never block. */ + } + } + + // + // SERVICE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected void serviceRun() { + while (!shouldStop()) { + try { + TrustUpdateJob updateJob = updateJobs.take(); + if (shouldStop() || (updateJob == stopJob)) { + break; + } + logger.log(Level.FINE, "Running Trust Update Job: " + updateJob); + long startTime = System.currentTimeMillis(); + updateJob.run(); + long endTime = System.currentTimeMillis(); + logger.log(Level.FINE, "Trust Update Job finished, took " + (endTime - startTime) + " ms."); + } catch (InterruptedException ie1) { + /* happens, ignore, loop. */ + } + } + } + + /** + * {@inheritDoc} + */ + @Override + protected void serviceStop() { + try { + updateJobs.put(stopJob); + } catch (InterruptedException ie1) { + /* the queue is unbounded so it should never block. */ + } + } + + /** + * Base class for trust update jobs. + * + * @author David ‘Bombe’ Roden + */ + private static class TrustUpdateJob { + + /** The identity giving the trust. */ + protected final OwnIdentity truster; + + /** The identity receiving the trust. */ + protected final Identity trustee; + + /** + * Creates a new trust update job. + * + * @param truster + * The identity giving the trust + * @param trustee + * The identity receiving the trust + */ + public TrustUpdateJob(OwnIdentity truster, Identity trustee) { + this.truster = truster; + this.trustee = trustee; + } + + // + // ACCESSORS + // + + /** + * Performs the actual update operation. + *

+ * The implementation of this class does nothing. + */ + public void run() { + /* does nothing. */ + } + + // + // OBJECT METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object object) { + if ((object == null) || !object.getClass().equals(getClass())) { + return false; + } + TrustUpdateJob updateJob = (TrustUpdateJob) object; + return ((truster == null) ? (updateJob.truster == null) : updateJob.truster.equals(truster)) && ((trustee == null) ? (updateJob.trustee == null) : updateJob.trustee.equals(trustee)); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return getClass().hashCode() ^ ((truster == null) ? 0 : truster.hashCode()) ^ ((trustee == null) ? 0 : trustee.hashCode()); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return String.format("%s[truster=%s,trustee=%s]", getClass().getSimpleName(), (truster == null) ? null : truster.getId(), (trustee == null) ? null : trustee.getId()); + } + + } + + /** + * Update job that sets the trust relation between two identities. + * + * @author David ‘Bombe’ Roden + */ + private class SetTrustJob extends TrustUpdateJob { + + /** The score of the relation. */ + private final Integer score; + + /** The comment of the relation. */ + private final String comment; + + /** + * Creates a new set trust job. + * + * @param truster + * The identity giving the trust + * @param trustee + * The identity receiving the trust + * @param score + * The score of the trust (from -100 to 100, may be + * {@code null} to remote the trust relation completely) + * @param comment + * The comment of the trust relation + */ + public SetTrustJob(OwnIdentity truster, Identity trustee, Integer score, String comment) { + super(truster, trustee); + this.score = score; + this.comment = comment; + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("synthetic-access") + public void run() { + try { + if (score != null) { + if (trustee instanceof DefaultIdentity) { + ((DefaultIdentity) trustee).setTrust(truster, new Trust(score, null, 0)); + } + webOfTrustConnector.setTrust(truster, trustee, score, comment); + } else { + if (trustee instanceof DefaultIdentity) { + ((DefaultIdentity) trustee).setTrust(truster, null); + } + webOfTrustConnector.removeTrust(truster, trustee); + } + } catch (WebOfTrustException wote1) { + logger.log(Level.WARNING, "Could not set Trust value for " + truster + " -> " + trustee + " to " + score + " (" + comment + ")!", wote1); + } + } + + } + + /** + * Update job that retrieves the trust relation between two identities. + * + * @author David ‘Bombe’ Roden + */ + private class GetTrustJob extends TrustUpdateJob { + + /** + * Creates a new trust update job. + * + * @param truster + * The identity giving the trust + * @param trustee + * The identity receiving the trust + */ + public GetTrustJob(OwnIdentity truster, Identity trustee) { + super(truster, trustee); + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("synthetic-access") + public void run() { + try { + Trust trust = webOfTrustConnector.getTrust(truster, trustee); + if (trustee instanceof DefaultIdentity) { + ((DefaultIdentity) trustee).setTrust(truster, trust); + } + } catch (PluginException pe1) { + logger.log(Level.WARNING, "Could not get Trust value for " + truster + " -> " + trustee + "!", pe1); + } + } + } + +} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java index 6fe4101..f200022 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java @@ -22,17 +22,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.logging.Level; import java.util.logging.Logger; -import net.pterodactylus.sone.freenet.plugin.PluginException; -import net.pterodactylus.util.cache.CacheException; -import net.pterodactylus.util.cache.CacheItem; -import net.pterodactylus.util.cache.DefaultCacheItem; -import net.pterodactylus.util.cache.MemoryCache; -import net.pterodactylus.util.cache.ValueRetriever; -import net.pterodactylus.util.cache.WritableCache; -import net.pterodactylus.util.collection.TimedMap; import net.pterodactylus.util.logging.Logging; /** @@ -65,19 +56,7 @@ public class DefaultIdentity implements Identity { /** Cached trust. */ /* synchronize on itself. */ - private final WritableCache trustCache = new MemoryCache(new ValueRetriever() { - - @Override - @SuppressWarnings("synthetic-access") - public CacheItem retrieve(OwnIdentity ownIdentity) throws CacheException { - try { - return new DefaultCacheItem(webOfTrustConnector.getTrust(ownIdentity, DefaultIdentity.this)); - } catch (PluginException pe1) { - throw new CacheException("Could not retrieve trust for OwnIdentity: " + ownIdentity, pe1); - } - } - - }, new TimedMap>(60 * 60 * 1000)); + private final Map trustCache = new HashMap(); /** * Creates a new identity. @@ -249,13 +228,8 @@ public class DefaultIdentity implements Identity { */ @Override public Trust getTrust(OwnIdentity ownIdentity) { - try { - synchronized (trustCache) { - return trustCache.get(ownIdentity); - } - } catch (CacheException ce1) { - logger.log(Level.WARNING, String.format("Could not get trust for OwnIdentity: %s", ownIdentity), ce1); - return null; + synchronized (trustCache) { + return trustCache.get(ownIdentity); } } @@ -267,7 +241,7 @@ public class DefaultIdentity implements Identity { * @param trust * The trust received for this identity */ - void setTrustPrivate(OwnIdentity ownIdentity, Trust trust) { + public void setTrust(OwnIdentity ownIdentity, Trust trust) { synchronized (trustCache) { trustCache.put(ownIdentity, trust); } diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java index c461c8b..6acdd70 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java @@ -167,7 +167,7 @@ public class DefaultOwnIdentity extends DefaultIdentity implements OwnIdentity { Validation.begin().isNotNull("Trust Target", target).isNotNull("Trust Comment", comment).isLessOrEqual("Trust Value", trustValue, 100).isGreaterOrEqual("Trust Value", trustValue, -100).check(); webOfTrustConnector.setTrust(this, target, trustValue, comment); if (target instanceof DefaultIdentity) { - ((DefaultIdentity) target).setTrustPrivate(this, new Trust(trustValue, trustValue, 0)); + ((DefaultIdentity) target).setTrust(this, new Trust(trustValue, trustValue, 0)); } } @@ -179,7 +179,7 @@ public class DefaultOwnIdentity extends DefaultIdentity implements OwnIdentity { Validation.begin().isNotNull("Trust Target", target).check(); webOfTrustConnector.removeTrust(this, target); if (target instanceof DefaultIdentity) { - ((DefaultIdentity) target).setTrustPrivate(this, new Trust(null, null, null)); + ((DefaultIdentity) target).setTrust(this, new Trust(null, null, null)); } } diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index cca2c7b..a02165e 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -24,6 +24,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.FreenetInterface; +import net.pterodactylus.sone.core.TrustUpdater; import net.pterodactylus.sone.fcp.FcpInterface; import net.pterodactylus.sone.freenet.PluginStoreConfigurationBackend; import net.pterodactylus.sone.freenet.plugin.PluginConnector; @@ -188,8 +189,12 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr identityManager = new IdentityManager(webOfTrustConnector); identityManager.setContext("Sone"); + /* create trust updater. */ + TrustUpdater trustUpdater = new TrustUpdater(webOfTrustConnector); + trustUpdater.init(); + /* create core. */ - core = new Core(oldConfiguration, freenetInterface, identityManager); + core = new Core(oldConfiguration, freenetInterface, identityManager, trustUpdater); /* create the web interface. */ webInterface = new WebInterface(this); diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java index 51bb1c0..6efee27 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java @@ -233,7 +233,14 @@ public class ListNotificationFilters { return false; } } else { - return false; + /* + * a null trust means that the trust updater has not yet + * received a trust value for this relation. if we return false, + * the post feed will stay empty until the trust updater has + * received trust values. to prevent this we simply assume that + * posts are visible if there is no trust. + */ + return true; } if ((!postSone.equals(sone)) && !sone.hasFriend(postSone.getId()) && !sone.equals(post.getRecipient())) { return false; diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index ab962d8..c770da3 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -132,10 +132,6 @@ public class OptionsPage extends SoneTemplatePage { Integer fcpFullAccessRequiredInteger = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("fcp-full-access-required", 1), preferences.getFcpFullAccessRequired().ordinal()); FullAccessRequired fcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequiredInteger]; preferences.setFcpFullAccessRequired(fcpFullAccessRequired); - boolean clearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("clear-on-next-restart", 5)); - preferences.setClearOnNextRestart(clearOnNextRestart); - boolean reallyClearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("really-clear-on-next-restart", 5)); - preferences.setReallyClearOnNextRestart(reallyClearOnNextRestart); webInterface.getCore().touchConfiguration(); if (fieldErrors.isEmpty()) { throw new RedirectException(getPath()); @@ -161,8 +157,6 @@ public class OptionsPage extends SoneTemplatePage { templateContext.set("trust-comment", preferences.getTrustComment()); templateContext.set("fcp-interface-active", preferences.isFcpInterfaceActive()); templateContext.set("fcp-full-access-required", preferences.getFcpFullAccessRequired().ordinal()); - templateContext.set("clear-on-next-restart", preferences.isClearOnNextRestart()); - templateContext.set("really-clear-on-next-restart", preferences.isReallyClearOnNextRestart()); } } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java index f25b19c..6e72a5a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java @@ -19,7 +19,6 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; @@ -57,11 +56,7 @@ public class DistrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().distrustSone(currentSone, sone); - Trust trust = webInterface.getCore().getTrust(currentSone, sone); - if (trust == null) { - return createErrorJsonObject("wot-plugin"); - } - return createSuccessJsonObject().put("trustValue", trust.getExplicit()); + return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getNegativeTrust()); } } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java index 9b86c5e..5b27d1b 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java @@ -19,7 +19,6 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; @@ -57,11 +56,7 @@ public class TrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().trustSone(currentSone, sone); - Trust trust = webInterface.getCore().getTrust(currentSone, sone); - if (trust == null) { - return createErrorJsonObject("wot-plugin"); - } - return createSuccessJsonObject().put("trustValue", trust.getExplicit()); + return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getPositiveTrust()); } } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java index 932be6c..916b6e9 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java @@ -19,7 +19,6 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; @@ -57,11 +56,7 @@ public class UntrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().untrustSone(currentSone, sone); - Trust trust = webInterface.getCore().getTrust(currentSone, sone); - if (trust == null) { - return createErrorJsonObject("wot-plugin"); - } - return createSuccessJsonObject().put("trustValue", trust.getExplicit()); + return createSuccessJsonObject().put("trustValue", (String) null); } } diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index c581798..7120d06 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -81,25 +81,27 @@ <%if !post.sone.current> - · -

- - - - -
-
- - - - -
-
- - - - -
+ <%ifnull !post.sone.trust> + · +
+ + + + +
+
+ + + + +
+
+ + + + +
+ <%/if> <%/if> <%/if> <%if post.sone.local> diff --git a/src/main/resources/templates/include/viewReply.html b/src/main/resources/templates/include/viewReply.html index 2962dd9..449a235 100644 --- a/src/main/resources/templates/include/viewReply.html +++ b/src/main/resources/templates/include/viewReply.html @@ -52,25 +52,27 @@ <%if !reply.sone.current> - · -
- - - - -
-
- - - - -
-
- - - - -
+ <%ifnull !reply.sone.trust> + · +
+ + + + +
+
+ + + + +
+
+ + + + +
+ <%/if> <%/if> <%/if> <%if reply.sone.local> diff --git a/src/main/resources/templates/options.html b/src/main/resources/templates/options.html index 119c8a1..4ec88cb 100644 --- a/src/main/resources/templates/options.html +++ b/src/main/resources/templates/options.html @@ -163,14 +163,6 @@

-

<%= Page.Options.Section.Cleaning.Title|l10n|html>

- -

<%= Page.Options.Option.ClearOnNextRestart.Description|l10n|html|replace needle=="{strong}" replacement==""|replace needle=="{/strong}" replacement=="">

-

- -

<%= Page.Options.Option.ReallyClearOnNextRestart.Description|l10n|html|replace needle=="{strong}" replacement==""|replace needle=="{/strong}" replacement=="">

-

-