--- /dev/null
+/*
+ * Sone - LockSonePage.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.Sone;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * This page lets the user lock a {@link Sone} to prevent it from being
+ * inserted.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class LockSonePage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “lock Sone” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public LockSonePage(Template template, WebInterface webInterface) {
+ super("lockSone.html", template, "Page.LockSone.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
+ Sone sone = webInterface.getCore().getLocalSone(soneId, false);
+ if (sone != null) {
+ webInterface.getCore().lockSone(sone);
+ }
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+ throw new RedirectException(returnPage);
+ }
+
+}
--- /dev/null
+/*
+ * Sone - LockSonePage.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.Sone;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * This page lets the user unlock a {@link Sone} to allow its insertion.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class UnlockSonePage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “unlock Sone” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public UnlockSonePage(Template template, WebInterface webInterface) {
+ super("unlockSone.html", template, "Page.UnlockSone.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
+ Sone sone = webInterface.getCore().getLocalSone(soneId, false);
+ if (sone != null) {
+ webInterface.getCore().unlockSone(sone);
+ }
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+ throw new RedirectException(returnPage);
+ }
+
+}
import net.pterodactylus.sone.web.ajax.GetSoneStatusPage;
import net.pterodactylus.sone.web.ajax.GetTranslationPage;
import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
+import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
+import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
import net.pterodactylus.sone.web.page.PageToadlet;
import net.pterodactylus.sone.web.page.PageToadletFactory;
import net.pterodactylus.sone.web.page.StaticPage;
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 lockSoneTemplate = templateFactory.createTemplate(createReader("/templates/lockSone.html"));
+ Template unlockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unlockSone.html"));
Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
Template unfollowSoneTemplate = templateFactory.createTemplate(createReader("/templates/unfollowSone.html"));
Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
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 LockSonePage(lockSoneTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(unlockSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(unfollowSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
--- /dev/null
+/*
+ * Sone - LockSoneAjaxPage.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.ajax;
+
+import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.util.json.JsonObject;
+
+/**
+ * Lets the user {@link Core#lockSone(Sone) lock} a {@link Sone}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class LockSoneAjaxPage extends JsonPage {
+
+ /**
+ * Creates a new “lock Sone” AJAX handler.
+ *
+ * @param webInterface
+ * The Sone web interface
+ */
+ public LockSoneAjaxPage(WebInterface webInterface) {
+ super("ajax/lockSone.ajax", webInterface);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected JsonObject createJsonObject(Request request) {
+ String soneId = request.getHttpRequest().getParam("sone");
+ Sone sone = webInterface.getCore().getLocalSone(soneId, false);
+ if (sone == null) {
+ return createErrorJsonObject("invalid-sone-id");
+ }
+ webInterface.getCore().lockSone(sone);
+ return createSuccessJsonObject();
+ }
+
+}
--- /dev/null
+/*
+ * Sone - LockSoneAjaxPage.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.ajax;
+
+import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.util.json.JsonObject;
+
+/**
+ * Lets the user {@link Core#unlockSone(Sone) unlock} a {@link Sone}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class UnlockSoneAjaxPage extends JsonPage {
+
+ /**
+ * Creates a new “unlock Sone” AJAX handler.
+ *
+ * @param webInterface
+ * The Sone web interface
+ */
+ public UnlockSoneAjaxPage(WebInterface webInterface) {
+ super("ajax/unlockSone.ajax", webInterface);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected JsonObject createJsonObject(Request request) {
+ String soneId = request.getHttpRequest().getParam("sone");
+ Sone sone = webInterface.getCore().getLocalSone(soneId, false);
+ if (sone == null) {
+ return createErrorJsonObject("invalid-sone-id");
+ }
+ webInterface.getCore().unlockSone(sone);
+ return createSuccessJsonObject();
+ }
+
+}
Page.DeleteReply.Button.Yes=Yes, delete.
Page.DeleteReply.Button.No=No, do not delete.
+Page.LockSone.Title=Lock Sone - Sone
+
+Page.UnlockSone.Title=Unlock Sone - Sone
+
Page.FollowSone.Title=Follow Sone - Sone
Page.UnfollowSone.Title=Unfollow Sone - Sone
View.CreateSone.Text.Error.NoIdentity=You have not selected an identity.
View.Sone.Label.LastUpdate=Last update:
+View.Sone.Button.UnlockSone=unlock
+View.Sone.Button.LockSone=lock
View.Sone.Button.UnfollowSone=unfollow
View.Sone.Button.FollowSone=follow
View.Sone.Status.Modified=This Sone was modified and waits to be inserted.
font-weight: bold;
}
-#sone .sone form {
+#sone .sone form.follow, #sone .sone form.unfollow, #sone .sone form.lock, #sone .sone form.unlock {
display: inline;
border: solid 1px #ccc;
border-left: none;
bottom: -0.5ex
}
-#sone .sone form.hidden {
- display: none;
-}
-
-#sone .sone form.follow button, #sone .sone form.unfollow button {
+#sone .sone form.follow button, #sone .sone form.unfollow button, #sone .sone form.lock button, #sone .sone form.unlock button {
display: inline;
color: rgb(28, 131, 191);
background: none;
padding: 0px;
}
-#sone .sone form.follow button:hover, #sone .sone form.unfollow button:hover {
+#sone .sone form.follow button:hover, #sone .sone form.unfollow button:hover, #sone .sone form.lock button:hover, #sone .sone form.unlock button:hover {
display: inline;
color: rgb(255, 172, 0);
}
+#sone .sone.locked form.lock, #sone .sone.unlocked form.unlock {
+ display: none;
+}
+
+#sone .sone form.hidden {
+ display: none;
+}
+
#sone .sone .spacer {
display: inline;
}
</script>
<script language="javascript">
- /* convert all “follow”, “unfollow”, “block”, and “unblock” links to something nicer. */
+ /* convert all “follow”, “unfollow”, “lock”, and “unlock” links to something nicer. */
$(document).ready(function() {
$("#sone .follow").submit(function() {
var followElement = this;
});
return false;
});
+ $("#sone .lock").submit(function() {
+ var lockElement = this;
+ $.getJSON("ajax/lockSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() {
+ $(lockElement).addClass("hidden");
+ $(lockElement).parent().find(".unlock").removeClass("hidden");
+ });
+ return false;
+ });
+ $("#sone .unlock").submit(function() {
+ var unlockElement = this;
+ $.getJSON("ajax/unlockSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() {
+ $(unlockElement).addClass("hidden");
+ $(unlockElement).parent().find(".lock").removeClass("hidden");
+ });
+ return false;
+ });
});
</script>
<div class="profile-link"><a href="viewSone.html?sone=<% sone.id|html>" title="<% sone.requestUri|html>"><% sone.niceName|html></a></div>
<div class="short-request-uri"><% sone.requestUri|substring start=4 length=43|html></div>
<div class="hidden"><% sone.blacklisted></div>
+ <%if sone.local>
+ <form class="lock<%if sone.locked> hidden<%/if>" action="lockSone.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="sone" value="<% sone.id|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <button type="submit"><%= View.Sone.Button.LockSone|l10n|html></button>
+ </form>
+ <form class="unlock<%if !sone.locked> hidden<%/if>" action="unlockSone.html" method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="sone" value="<% sone.id|html>" />
+ <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+ <button type="submit"><%= View.Sone.Button.UnlockSone|l10n|html></button>
+ </form>
+ <%/if>
<%if ! sone.current>
<%ifnull ! currentSone>
<form class="unfollow<%if ! sone.friend> hidden<%/if>" action="unfollowSone.html" method="post">