<modelVersion>4.0.0</modelVersion>
<groupId>net.pterodactylus</groupId>
<artifactId>sone</artifactId>
- <version>0.9</version>
+ <version>0.9.1</version>
<dependencies>
<dependency>
<groupId>net.pterodactylus</groupId>
}
logger.info(String.format("Adding Sone from OwnIdentity: %s", ownIdentity));
Sone sone = database.newSoneBuilder().local().from(ownIdentity).build();
- sone.setLatestEdition(fromNullable(tryParse(ownIdentity.getProperty("Sone.LatestEdition"))).or(0L));
+ String property = fromNullable(ownIdentity.getProperty("Sone.LatestEdition")).or("0");
+ sone.setLatestEdition(fromNullable(tryParse(property)).or(0L));
sone.setClient(new Client("Sone", SonePlugin.VERSION.toString()));
sone.setKnown(true);
+ loadSone(sone);
+ sone.setStatus(SoneStatus.idle);
+ database.storeSone(sone);
SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, ownIdentity.getId());
eventBus.register(soneInserter);
synchronized (soneInserters) {
soneInserters.put(sone, soneInserter);
}
- loadSone(sone);
- sone.setStatus(SoneStatus.idle);
soneInserter.start();
return sone;
}
for (Album album : topLevelAlbums) {
sone.getRootAlbum().addAlbum(album);
}
- database.storeSone(sone);
synchronized (soneInserters) {
soneInserters.get(sone).setLastInsertFingerprint(lastInsertFingerprint);
}
--- /dev/null
+package net.pterodactylus.sone.main;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Map;
+
+import net.pterodactylus.util.template.Filter;
+import net.pterodactylus.util.template.Template;
+import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.template.TemplateException;
+import net.pterodactylus.util.template.TemplateParser;
+
+/**
+ * Takes the input and parses it as a new {@link Template}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ReparseFilter implements Filter {
+
+ @Override
+ public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
+ Template template = TemplateParser.parse(new StringReader(String.valueOf(data)));
+ StringWriter stringWriter = new StringWriter();
+ try {
+ template.render(templateContext, stringWriter);
+ } catch (TemplateException e) {
+ throw new RuntimeException(e);
+ } finally {
+ return stringWriter.toString();
+ }
+ }
+
+}
}
/** The version. */
- public static final Version VERSION = new Version(0, 9);
+ public static final Version VERSION = new Version(0, 9, 1);
/** The current year at time of release. */
private static final int YEAR = 2015;
private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/";
- private static final int LATEST_EDITION = 66;
+ private static final int LATEST_EDITION = 68;
/** The logger. */
private static final Logger logger = getLogger("Sone.Plugin");
import net.pterodactylus.sone.freenet.L10nFilter;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.freenet.wot.Trust;
+import net.pterodactylus.sone.main.ReparseFilter;
import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.sone.notify.ListNotification;
import net.pterodactylus.sone.template.AlbumAccessor;
templateContextFactory.addFilter("css", new CssClassNameFilter());
templateContextFactory.addFilter("js", new JavascriptFilter());
templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), templateContextFactory, soneTextParser));
+ templateContextFactory.addFilter("reparse", new ReparseFilter());
templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
templateContextFactory.addFilter("format", new FormatFilter());
templateContextFactory.addFilter("sort", new CollectionSortFilter());
<h2><%= Page.About.Homepage.Title|l10n|html></h2>
<p>
- <%= Page.About.Homepage.Description|l10n|html|replace needle=="{link}" replacement=='<a href="/<% homepage|html>/">'|replace needle=="{/link}" replacement=='</a>'>
+ <%= Page.About.Homepage.Description|l10n|html|replace needle=="{link}" replacement=='<a href="/<% homepage|html>/">'|reparse|replace needle=="{/link}" replacement=='</a>'>
</p>
<h2><%= Page.About.License.Title|l10n|html></h2>
--- /dev/null
+package net.pterodactylus.sone.main;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import java.util.Collections;
+
+import net.pterodactylus.util.template.TemplateContext;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link ReparseFilter}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ReparseFilterTest {
+
+ private final ReparseFilter reparseFilter = new ReparseFilter();
+
+ @Test
+ public void filterParsesTemplateCorrectly() {
+ TemplateContext templateContext = new TemplateContext();
+ templateContext.set("bar", "baz");
+ assertThat(reparseFilter.format(templateContext, "foo <% bar>", Collections.<String, Object>emptyMap()),
+ is((Object) "foo baz"));
+ }
+
+}