+++ /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, true);
- }
-
- //
- // TEMPLATEPAGE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Response handleRequest(Request request) {
- StringWriter stringWriter = new StringWriter();
- template.set("currentSone", getCurrentSone(request.getToadletContext()));
- 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;
- }
-
-}
Template createPostTemplate = templateFactory.createTemplate(createReader("/templates/createPost.html"));
Template createReplyTemplate = templateFactory.createTemplate(createReader("/templates/createReply.html"));
Template editProfileTemplate = templateFactory.createTemplate(createReader("/templates/editProfile.html"));
- Template backupProfileTemplate = templateFactory.createTemplate(createReader("/templates/backup.xml"));
Template viewSoneTemplate = templateFactory.createTemplate(createReader("/templates/viewSone.html"));
Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html"));
Template likePostTemplate = templateFactory.createTemplate(createReader("/templates/like.html"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
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)));
+++ /dev/null
-<?xml version="1.0" encoding="utf-8" ?>
-<sone>
-
- <id><% currentSone.id|xml></id>
- <time><% currentSone.time|xml></time>
- <request-uri><% currentSone.requestUri|xml></request-uri>
- <insert-uri><% currentSone.insertUri|xml></insert-uri>
-
- <profile>
- <first-name><% currentSone.profile.firstName|xml></first-name>
- <middle-name><% currentSone.profile.middleName|xml></middle-name>
- <last-name><% currentSone.profile.lastName|xml></last-name>
- <birth-day><% currentSone.profile.birthDay|xml></birth-day>
- <birth-month><% currentSone.profile.birthMonth|xml></birth-month>
- <birth-year><% currentSone.profile.birthYear|xml></birth-year>
- </profile>
-
- <posts>
- <%foreach currentSone.posts post>
- <post>
- <id><% post.id|xml></id>
- <time><% post.time></time>
- <text><% post.text|xml></text>
- </post>
- <%/foreach>
- </posts>
-
- <replies>
- <%foreach currentSone.replies reply>
- <reply>
- <id><% reply.id></id>
- <post-id><% reply.post.id|xml></post-id>
- <time><% reply.time></time>
- <text><% reply.text|xml></text>
- </reply>
- <%/foreach>
- </replies>
-
- <post-likes>
- <%foreach currentSone.likedPostIds postId>
- <post-like><% postId|xml></post-like>
- <%/foreach>
- </post-likes>
-
- <reply-likes>
- <%foreach currentSone.likedReplyIds replyId>
- <reply-like><% replyId|xml></reply-like>
- <%/foreach>
- </reply-likes>
-
- <friends>
- <%foreach currentSone.friends friend>
- <friend>
- <sone-id><% friend.id|xml></sone-id>
- <sone-key><% friend.requestUri|xml></sone-key>
- <sone-name><% friend.name|xml></sone-name>
- </friend>
- <%/foreach>
- </friends>
-
-</sone>
</form>
- <h1><%= Page.EditProfile.Keys.Title|l10n|html></h1>
-
- <p><%= Page.EditProfile.Keys.Description.RequestKey|l10n|html></p>
- <p><%= Page.EditProfile.Keys.Description.InsertKey|l10n|html></p>
- <p><%= Page.EditProfile.Keys.Description.Summary|l10n|html></p>
-
- <div>
- <label><%= Page.EditProfile.Label.RequestKey|l10n|html></label>
- <input type="text" class="key" readonly="readonly" value="<% currentSone.requestUri|html>" />
- </div>
- <div>
- <label><%= Page.EditProfile.Label.InsertKey|l10n|html></label>
- <input type="text" class="key" readonly="readonly" value="<% currentSone.insertUri|html>" />
- </div>
-
- <h1><%= Page.EditProfile.Backup.Title|l10n|html></h1>
-
- <p><%= Page.EditProfile.Backup.Description|l10n|html></p>
-
- <form action="backupProfile.html" method="post">
- <input type="hidden" name="formPassword" value="<% formPassword|html>" />
- <button type="submit"><%= Page.EditProfile.Backup.Button.DownloadBackup|l10n|html></button>
- </form>
-
<%include include/tail.html>