--- /dev/null
+/*
+ * Sone - LikePage.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.data.Post;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * Page that lets the user like a {@link Post}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class LikePage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “like post” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public LikePage(Template template, WebInterface webInterface) {
+ super("like.html", template, "Page.LikePost.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ if (request.getMethod() == Method.POST) {
+ String type=request.getHttpRequest().getPartAsStringFailsafe("type", 16);
+ String id = request.getHttpRequest().getPartAsStringFailsafe(type, 36);
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+ Sone currentSone = getCurrentSone(request.getToadletContext());
+ if ("post".equals(type)) {
+ currentSone.addLikedPostId(id);
+ } else if ("reply".equals(type)) {
+ currentSone.addLikedReplyId(id);
+ }
+ throw new RedirectException(returnPage);
+ }
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean requiresLogin() {
+ return true;
+ }
+
+}
+++ /dev/null
-/*
- * Sone - LikePostPage.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.data.Post;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
-import net.pterodactylus.util.template.Template;
-
-/**
- * Page that lets the user like a {@link Post}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class LikePostPage extends SoneTemplatePage {
-
- /**
- * Creates a new “like post” page.
- *
- * @param template
- * The template to render
- * @param webInterface
- * The Sone web interface
- */
- public LikePostPage(Template template, WebInterface webInterface) {
- /* TODO */
- super("likePost.html", template, "Page.LikePost.Title", webInterface);
- }
-
- //
- // TEMPLATEPAGE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void processTemplate(Request request, Template template) throws RedirectException {
- super.processTemplate(request, template);
- if (request.getMethod() == Method.POST) {
- String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
- String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
- Sone currentSone = getCurrentSone(request.getToadletContext());
- currentSone.addLikedPostId(postId);
- throw new RedirectException(returnPage);
- }
- }
-
- //
- // SONETEMPLATEPAGE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean requiresLogin() {
- return true;
- }
-
-}
--- /dev/null
+/*
+ * Sone - UnlikePage.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.data.Post;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * Page that lets the user unlike a {@link Post}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class UnlikePage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “unlike post” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public UnlikePage(Template template, WebInterface webInterface) {
+ super("unlike.html", template, "Page.UnlikePost.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ if (request.getMethod() == Method.POST) {
+ String type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
+ String id = request.getHttpRequest().getPartAsStringFailsafe(type, 36);
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+ Sone currentSone = getCurrentSone(request.getToadletContext());
+ if ("post".equals(type)) {
+ currentSone.removeLikedPostId(id);
+ } else if ("reply".equals(type)) {
+ currentSone.removeLikedReplyId(id);
+ }
+ throw new RedirectException(returnPage);
+ }
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean requiresLogin() {
+ return true;
+ }
+
+}
+++ /dev/null
-/*
- * Sone - UnlikePostPage.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.data.Post;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
-import net.pterodactylus.util.template.Template;
-
-/**
- * Page that lets the user unlike a {@link Post}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class UnlikePostPage extends SoneTemplatePage {
-
- /**
- * Creates a new “unlike post” page.
- *
- * @param template
- * The template to render
- * @param webInterface
- * The Sone web interface
- */
- public UnlikePostPage(Template template, WebInterface webInterface) {
- super("unlikePost.html", template, "Page.UnlikePost.Title", webInterface);
- }
-
- //
- // TEMPLATEPAGE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void processTemplate(Request request, Template template) throws RedirectException {
- super.processTemplate(request, template);
- if (request.getMethod() == Method.POST) {
- String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
- String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
- Sone currentSone = getCurrentSone(request.getToadletContext());
- currentSone.removeLikedPostId(postId);
- throw new RedirectException(returnPage);
- }
- }
-
- //
- // SONETEMPLATEPAGE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean requiresLogin() {
- return true;
- }
-
-}
Template blockSoneTemplate = templateFactory.createTemplate(createReader("/templates/blockSone.html"));
Template unblockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unblockSone.html"));
Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html"));
- Template likePostTemplate = templateFactory.createTemplate(createReader("/templates/likePost.html"));
- Template unlikePostTemplate = templateFactory.createTemplate(createReader("/templates/unlikePost.html"));
+ Template likePostTemplate = templateFactory.createTemplate(createReader("/templates/like.html"));
+ Template unlikePostTemplate = templateFactory.createTemplate(createReader("/templates/unlike.html"));
Template deletePostTemplate = templateFactory.createTemplate(createReader("/templates/deletePost.html"));
Template deleteReplyTemplate = templateFactory.createTemplate(createReader("/templates/deleteReply.html"));
Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
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 LikePostPage(likePostTemplate, this)));
- pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePostPage(unlikePostTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new LikePage(likePostTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(unlikePostTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this)));
<div class="time"><a href="viewPost.html?post=<% post.id|html>"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></a></div>
<div class="likes<%if post.likes.size|match value=0> hidden<%/if>"><span>⬆<span class="like-count"><% post.likes.size></span></span></div>
<%ifnull ! currentSone>
- <form class="like<%if post.liked> hidden<%/if>" action="likePost.html" method="post">
+ <form class="like<%if post.liked> hidden<%/if>" action="like.html" method="post">
<input type="hidden" name="formPassword" value="<% formPassword|html>" />
<input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="type" value="post" />
<input type="hidden" name="post" value="<% post.id|html>" />
<button type="submit" value="1"><%= View.Post.LikeLink|l10n|html></button>
</form>
- <form class="unlike<%if ! post.liked> hidden<%/if>" action="unlikePost.html" method="post">
+ <form class="unlike<%if ! post.liked> hidden<%/if>" action="unlike.html" method="post">
<input type="hidden" name="formPassword" value="<% formPassword|html>" />
<input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <input type="hidden" name="type" value="post" />
<input type="hidden" name="post" value="<% post.id|html>" />
<button type="submit" value="1"><%= View.Post.UnlikeLink|l10n|html></button>
</form>
--- /dev/null
+<%include include/head.html>
+
+<%include include/tail.html>
+++ /dev/null
-<%include include/head.html>
-
-<%include include/tail.html>
--- /dev/null
+<%include include/head.html>
+
+<%include include/tail.html>
+++ /dev/null
-<%include include/head.html>
-
-<%include include/tail.html>