--- /dev/null
+/*
+ * Sone - OptionsPage.java - Copyright © 2010 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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.web;
+
+import net.pterodactylus.sone.core.Options;
+import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.util.number.Numbers;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * This page lets the user edit the options of the Sone plugin.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class OptionsPage extends SoneTemplatePage {
+
+ /**
+ * Creates a new options page.
+ *
+ * @param template
+ * @param webInterface
+ */
+ public OptionsPage(Template template, WebInterface webInterface) {
+ super("options.html", template, "Page.Options.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ Options options = webInterface.core().getOptions();
+ if (request.getMethod() == Method.POST) {
+ Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
+ options.getIntegerOption("InsertionDelay").set(insertionDelay);
+ }
+ template.set("insertion-delay", options.getIntegerOption("InsertionDelay").get());
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean requiresLogin() {
+ return false;
+ }
+
+}
Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
Template noPermissionTemplate = templateFactory.createTemplate(createReader("/templates/noPermission.html"));
Template logoutTemplate = templateFactory.createTemplate(createReader("/templates/logout.html"));
+ Template optionsTemplate = templateFactory.createTemplate(createReader("/templates/options.html"));
Template aboutTemplate = templateFactory.createTemplate(createReader("/templates/about.html"));
PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
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 OptionsPage(optionsTemplate, this), "Options"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("about.html", aboutTemplate, "Page.About.Title", this), "About"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("css/", "/static/css/", "text/css")));
Navigation.Menu.Item.DeleteSone.Tooltip=Deletes the current Sone
Navigation.Menu.Item.Logout.Name=Logout
Navigation.Menu.Item.Logout.Tooltip=Logs you out of the current Sone
+Navigation.Menu.Item.Options.Name=Options
+Navigation.Menu.Item.Options.Tooltip=Options for the Sone plugin
Navigation.Menu.Item.About.Name=About
Navigation.Menu.Item.About.Tooltip=Information about Sone
Page.About.Title=About - Sone
Page.About.Page.Title=About
+Page.Options.Title=Options - Sone
+Page.Options.Page.Title=Options
+Page.Options.Page.Description=These options influence the runtime behaviour of the Sone plugin.
+Page.Options.Option.InsertionDelay.Description=The number of seconds the Sone inserter waits after a modification of a Sone before it is being inserted.
+Page.Options.Button.Save=Save
+
Page.Login.Title=Login - Sone
Page.Login.Page.Title=Login
Page.Login.Label.SelectSone=Select Sone:
WebInterface.DefaultText.BirthDay=Day
WebInterface.DefaultText.BirthMonth=Month
WebInterface.DefaultText.BirthYear=Year
+WebInterface.DefaultText.Option.InsertionDelay=Time to wait after a Sone is modified before insert (in seconds)
WebInterface.Confirmation.DeletePostButton=Yes, delete!
WebInterface.Confirmation.DeleteReplyButton=Yes, delete!
--- /dev/null
+<%include include/head.html>
+
+ <script language="javascript">
+ $(document).ready(function() {
+ registerInputTextareaSwap("#sone #options input[name=insertion-delay]", "WebInterface.DefaultText.Option.InsertionDelay", "insertion-delay", true, true);
+ });
+ </script>
+
+ <h1><%= Page.Options.Page.Title|l10n|html></h1>
+
+ <p><%= Page.Options.Page.Description|l10n|html></p>
+
+ <form id="options" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+
+ <p><%= Page.Options.Option.InsertionDelay.Description|l10n|html></p>
+ <p><input type="text" name="insertion-delay" value="<% insertion-delay|html>" /></p>
+
+ <p><button type="submit"><%= Page.Options.Button.Save|l10n|html></button></p>
+
+ </form>
+
+<%include include/tail.html>