Add stub of “edit profile” page.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 774fe7a..d22d94e 100644 (file)
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.main.SonePlugin;
 import net.pterodactylus.sone.web.page.CSSPage;
 import net.pterodactylus.sone.web.page.PageToadlet;
@@ -66,6 +67,7 @@ public class WebInterface extends AbstractService {
         *            The Sone plugin
         */
        public WebInterface(SonePlugin sonePlugin) {
+               super("Sone Web Interface");
                this.sonePlugin = sonePlugin;
        }
 
@@ -74,6 +76,15 @@ public class WebInterface extends AbstractService {
        //
 
        /**
+        * Returns the Sone core used by the Sone plugin.
+        *
+        * @return The Sone core
+        */
+       public Core core() {
+               return sonePlugin.core();
+       }
+
+       /**
         * Returns the l10n helper of the node.
         *
         * @return The node’s l10n helper
@@ -125,20 +136,40 @@ public class WebInterface extends AbstractService {
         */
        private void registerToadlets() {
                TemplateFactory templateFactory = new SoneTemplateFactory(l10n());
+               String formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
 
                Template loginTemplate = templateFactory.createTemplate(createReader("/templates/login.html"));
-               loginTemplate.set("formPassword", sonePlugin.pluginRespirator().getToadletContainer().getFormPassword());
+               loginTemplate.set("formPassword", formPassword);
+
+               Template indexTemplate = templateFactory.createTemplate(createReader("/templates/index.html"));
+               indexTemplate.set("formPassword", formPassword);
+
+               Template createSoneTemplate = templateFactory.createTemplate(createReader("/templates/createSone.html"));
+               createSoneTemplate.set("formPassword", formPassword);
+
+               Template editProfileTemplate = templateFactory.createTemplate(createReader("/templates/editProfile.html"));
+               editProfileTemplate.set("formPassword", formPassword);
+
+               Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
+               deleteSoneTemplate.set("formPassword", formPassword);
+
+               Template logoutTemplate = templateFactory.createTemplate(createReader("/templates/logout.html"));
 
                PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index"));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
+               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 CSSPage("css/", "/static/css/")));
 
                ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
-               toadletContainer.getPageMaker().addNavigationCategory("/Sone/", "Navigation.Menu.Name", "Navigation.Menu.Tooltip", sonePlugin);
+               toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Name", "Navigation.Menu.Tooltip", sonePlugin);
                for (PageToadlet toadlet : pageToadlets) {
                        String menuName = toadlet.getMenuName();
                        if (menuName != null) {
-                               toadletContainer.register(toadlet, "Navigation.Menu.Name", toadlet.path(), true, "Navigation.Menu.Item." + menuName + ".Name", "Navigation.Menu.Item." + menuName + ".Tooltip", false, new AlwaysEnabledCallback());
+                               toadletContainer.register(toadlet, "Navigation.Menu.Name", toadlet.path(), true, "Navigation.Menu.Item." + menuName + ".Name", "Navigation.Menu.Item." + menuName + ".Tooltip", false, toadlet);
                        } else {
                                toadletContainer.register(toadlet, null, toadlet.path(), true, false);
                        }