import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.sone.template.PostAccessor;
import net.pterodactylus.sone.template.SoneAccessor;
+import net.pterodactylus.sone.template.SubstringFilter;
import net.pterodactylus.sone.web.page.PageToadlet;
import net.pterodactylus.sone.web.page.PageToadletFactory;
import net.pterodactylus.sone.web.page.StaticPage;
private void registerToadlets() {
DefaultTemplateFactory templateFactory = new DefaultTemplateFactory();
templateFactory.addAccessor(Object.class, new ReflectionAccessor());
- templateFactory.addAccessor(Sone.class, new SoneAccessor());
+ templateFactory.addAccessor(Sone.class, new SoneAccessor(core()));
templateFactory.addAccessor(Post.class, new PostAccessor(core()));
templateFactory.addFilter("date", new DateFilter());
templateFactory.addFilter("l10n", new L10nFilter(l10n()));
+ templateFactory.addFilter("substring", new SubstringFilter());
templateFactory.setTemplateProvider(new ClassPathTemplateProvider(templateFactory));
String formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
Template editProfileTemplate = templateFactory.createTemplate(createReader("/templates/editProfile.html"));
editProfileTemplate.set("formPassword", formPassword);
+ Template backupProfileTemplate = templateFactory.createTemplate(createReader("/templates/backup.xml"));
+ backupProfileTemplate.set("formPassword", formPassword);
+
Template viewSoneTemplate = templateFactory.createTemplate(createReader("/templates/viewSone.html"));
viewSoneTemplate.set("formPassword", formPassword);
+ Template blockSoneTemplate = templateFactory.createTemplate(createReader("/templates/blockSone.html"));
+ blockSoneTemplate.set("formPassword", formPassword);
+
+ Template unblockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unblockSone.html"));
+ unblockSoneTemplate.set("formPassword", formPassword);
+
Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html"));
viewPostTemplate.set("formPassword", formPassword);
Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
followSoneTemplate.set("formPassword", formPassword);
+ Template unfollowSoneTemplate = templateFactory.createTemplate(createReader("/templates/unfollowSone.html"));
+ unfollowSoneTemplate.set("formPassword", formPassword);
+
Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
deleteSoneTemplate.set("formPassword", formPassword);
pageToadlets.add(pageToadletFactory.createPageToadlet(new AddSonePage(addSoneTemplate, this), "AddSone"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new BackupProfilePage(backupProfileTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new BlockSonePage(blockSoneTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new UnblockSonePage(unblockSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(unfollowSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(logoutTemplate, this), "Logout"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.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")));
ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Name", "Navigation.Menu.Tooltip", sonePlugin);