--- /dev/null
+/*
+ * Sone - BackupProfilePage.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 java.io.StringWriter;
+
+import net.pterodactylus.util.io.Closer;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * This page lets the user store a backup file containing the settings of the
+ * logged in Sone.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class BackupProfilePage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “backup profile” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public BackupProfilePage(Template template, WebInterface webInterface) {
+ super("backupProfile.html", template, "Page.BackupProfile.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Response handleRequest(Request request) {
+ StringWriter stringWriter = new StringWriter();
+ try {
+ template.render(stringWriter);
+ } finally {
+ Closer.close(stringWriter);
+ }
+
+ Response response = new Response(200, "OK", "text/xml; charset=utf-8", stringWriter.toString());
+ response.setHeader("Content-Disposition", "attachment; filename=Sone_" + getCurrentSone(request.getToadletContext()).getName() + ".xml");
+ return response;
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean requiresLogin() {
+ return true;
+ }
+
+}
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);
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)));
Page.EditProfile.Label.LastName=Last name:
Page.EditProfile.Page.Status.Changed=Your changes have been saved and will be inserted shortly.
Page.EditProfile.Button.Save=Save Profile
+Page.EditProfile.Backup.Title=Backup
+Page.EditProfile.Backup.Description=Various unforeseen events can make it necessary to install a clean version of Sone. With a profile backup you can restore your Sone at a later point from any installation of Sone and by downloading all your posts and replies from Freenet again.
+Page.EditProfile.Backup.Button.DownloadBackup=Download Backup
+
+Page.BackupProfile.Title=Backup Profile - Sone
Page.CreatePost.Title=Create Post - Sone
Page.CreatePost.Page.Title=Create Post