import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.pterodactylus.sone.freenet.L10nFilter;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.main.SonePlugin;
+import net.pterodactylus.sone.template.CollectionAccessor;
import net.pterodactylus.sone.template.GetPagePlugin;
import net.pterodactylus.sone.template.IdentityAccessor;
import net.pterodactylus.sone.template.PostAccessor;
import net.pterodactylus.sone.web.page.PageToadletFactory;
import net.pterodactylus.sone.web.page.StaticPage;
import net.pterodactylus.util.logging.Logging;
-import net.pterodactylus.util.service.AbstractService;
import net.pterodactylus.util.template.DateFilter;
import net.pterodactylus.util.template.DefaultTemplateFactory;
import net.pterodactylus.util.template.MatchFilter;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class WebInterface extends AbstractService {
+public class WebInterface {
/** The logger. */
private static final Logger logger = Logging.getLogger(WebInterface.class);
* The Sone plugin
*/
public WebInterface(SonePlugin sonePlugin) {
- super("Sone Web Interface", false);
this.sonePlugin = sonePlugin;
formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
}
*
* @return The node’s l10n helper
*/
- public BaseL10n l10n() {
+ public BaseL10n getL10n() {
return sonePlugin.l10n().getBase();
}
*
* @return The node’s session manager
*/
- public SessionManager sessionManager() {
+ public SessionManager getSessionManager() {
try {
return sonePlugin.pluginRespirator().getSessionManager(new URI("/"));
} catch (URISyntaxException use1) {
*
* @return The form password
*/
- public String formPassword() {
+ public String getFormPassword() {
return formPassword;
}
//
- // SERVICE METHODS
+ // ACTIONS
//
/**
- * {@inheritDoc}
+ * Starts the web interface and registers all toadlets.
*/
- @Override
- protected void serviceStart() {
+ public void start() {
registerToadlets();
}
/**
- * {@inheritDoc}
+ * Stops the web interface and unregisters all toadlets.
*/
- @Override
- protected void serviceStop() {
+ public void stop() {
unregisterToadlets();
}
private void registerToadlets() {
DefaultTemplateFactory templateFactory = new DefaultTemplateFactory();
templateFactory.addAccessor(Object.class, new ReflectionAccessor());
+ templateFactory.addAccessor(Collection.class, new CollectionAccessor());
templateFactory.addAccessor(Sone.class, new SoneAccessor(core()));
templateFactory.addAccessor(Post.class, new PostAccessor(core()));
templateFactory.addAccessor(Reply.class, new ReplyAccessor(core()));
templateFactory.addAccessor(Identity.class, new IdentityAccessor(core()));
templateFactory.addFilter("date", new DateFilter());
- templateFactory.addFilter("l10n", new L10nFilter(l10n()));
+ templateFactory.addFilter("l10n", new L10nFilter(getL10n()));
templateFactory.addFilter("substring", new SubstringFilter());
templateFactory.addFilter("xml", new XmlFilter());
templateFactory.addFilter("change", new RequestChangeFilter());