X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FOptionsPage.java;h=c770da38f830285def0c6fae43d48124345a9bb1;hp=7b4a634587ed56cf17ada7a6382e939b02988bcd;hb=820f04de1741b7f3f5205a9520f1adfbd88e6d58;hpb=9f8b3c3202fd7b03768c2438c3e5d37faa9dfc5e diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index 7b4a634..c770da3 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -1,5 +1,5 @@ /* - * Sone - OptionsPage.java - Copyright © 2010 David Roden + * Sone - OptionsPage.java - Copyright © 2010–2012 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 @@ -22,6 +22,7 @@ import java.util.List; import net.pterodactylus.sone.core.Core.Preferences; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.data.Sone.ShowCustomAvatars; import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.number.Numbers; @@ -67,6 +68,14 @@ public class OptionsPage extends SoneTemplatePage { currentSone.getOptions().getBooleanOption("AutoFollow").set(autoFollow); boolean enableSoneInsertNotifications = request.getHttpRequest().isPartSet("enable-sone-insert-notifications"); currentSone.getOptions().getBooleanOption("EnableSoneInsertNotifications").set(enableSoneInsertNotifications); + boolean showNotificationNewSones = request.getHttpRequest().isPartSet("show-notification-new-sones"); + currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").set(showNotificationNewSones); + boolean showNotificationNewPosts = request.getHttpRequest().isPartSet("show-notification-new-posts"); + currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").set(showNotificationNewPosts); + boolean showNotificationNewReplies = request.getHttpRequest().isPartSet("show-notification-new-replies"); + currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").set(showNotificationNewReplies); + String showCustomAvatars = request.getHttpRequest().getPartAsStringFailsafe("show-custom-avatars", 32); + currentSone.getOptions(). getEnumOption("ShowCustomAvatars").set(ShowCustomAvatars.valueOf(showCustomAvatars)); webInterface.getCore().touchConfiguration(); } Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16)); @@ -81,6 +90,12 @@ public class OptionsPage extends SoneTemplatePage { } else { preferences.setPostsPerPage(postsPerPage); } + Integer imagesPerPage = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("images-per-page", 4), null); + if (!preferences.validateImagesPerPage(imagesPerPage)) { + fieldErrors.add("images-per-page"); + } else { + preferences.setImagesPerPage(imagesPerPage); + } Integer charactersPerPost = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("characters-per-post", 10), null); if (!preferences.validateCharactersPerPost(charactersPerPost)) { fieldErrors.add("characters-per-post"); @@ -117,10 +132,6 @@ public class OptionsPage extends SoneTemplatePage { Integer fcpFullAccessRequiredInteger = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("fcp-full-access-required", 1), preferences.getFcpFullAccessRequired().ordinal()); FullAccessRequired fcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequiredInteger]; preferences.setFcpFullAccessRequired(fcpFullAccessRequired); - boolean clearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("clear-on-next-restart", 5)); - preferences.setClearOnNextRestart(clearOnNextRestart); - boolean reallyClearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("really-clear-on-next-restart", 5)); - preferences.setReallyClearOnNextRestart(reallyClearOnNextRestart); webInterface.getCore().touchConfiguration(); if (fieldErrors.isEmpty()) { throw new RedirectException(getPath()); @@ -130,9 +141,14 @@ public class OptionsPage extends SoneTemplatePage { if (currentSone != null) { templateContext.set("auto-follow", currentSone.getOptions().getBooleanOption("AutoFollow").get()); templateContext.set("enable-sone-insert-notifications", currentSone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()); + templateContext.set("show-notification-new-sones", currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").get()); + templateContext.set("show-notification-new-posts", currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").get()); + templateContext.set("show-notification-new-replies", currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").get()); + templateContext.set("show-custom-avatars", currentSone.getOptions(). getEnumOption("ShowCustomAvatars").get().name()); } templateContext.set("insertion-delay", preferences.getInsertionDelay()); templateContext.set("posts-per-page", preferences.getPostsPerPage()); + templateContext.set("images-per-page", preferences.getImagesPerPage()); templateContext.set("characters-per-post", preferences.getCharactersPerPost()); templateContext.set("post-cut-off-length", preferences.getPostCutOffLength()); templateContext.set("require-full-access", preferences.isRequireFullAccess()); @@ -141,8 +157,6 @@ public class OptionsPage extends SoneTemplatePage { templateContext.set("trust-comment", preferences.getTrustComment()); templateContext.set("fcp-interface-active", preferences.isFcpInterfaceActive()); templateContext.set("fcp-full-access-required", preferences.getFcpFullAccessRequired().ordinal()); - templateContext.set("clear-on-next-restart", preferences.isClearOnNextRestart()); - templateContext.set("really-clear-on-next-restart", preferences.isReallyClearOnNextRestart()); } }