X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FOptionsPage.java;h=1847b9cc151dc5d37a8076a44a1bbfc509b41f2b;hp=fda6afd0a9c6e1c5df20de79991c7c4a490abd0c;hb=c9e306ac8e3ada846e87a0cc256a20fc148f381c;hpb=1bc78b582ac59f2438002997f5780db4dcee0a2a diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index fda6afd..1847b9c 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -22,11 +22,13 @@ 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.Page.Request.Method; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; /** * This page lets the user edit the options of the Sone plugin. @@ -55,7 +57,7 @@ public class OptionsPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); Preferences preferences = webInterface.getCore().getPreferences(); Sone currentSone = webInterface.getCurrentSone(request.getToadletContext(), false); @@ -66,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)); @@ -86,6 +96,12 @@ public class OptionsPage extends SoneTemplatePage { } else { preferences.setCharactersPerPost(charactersPerPost); } + Integer postCutOffLength = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("post-cut-off-length", 10), null); + if (!preferences.validatePostCutOffLength(postCutOffLength)) { + fieldErrors.add("post-cut-off-length"); + } else { + preferences.setPostCutOffLength(postCutOffLength); + } boolean requireFullAccess = request.getHttpRequest().isPartSet("require-full-access"); preferences.setRequireFullAccess(requireFullAccess); Integer positiveTrust = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("positive-trust", 3)); @@ -123,10 +139,15 @@ 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("characters-per-post", preferences.getCharactersPerPost()); + templateContext.set("post-cut-off-length", preferences.getPostCutOffLength()); templateContext.set("require-full-access", preferences.isRequireFullAccess()); templateContext.set("positive-trust", preferences.getPositiveTrust()); templateContext.set("negative-trust", preferences.getNegativeTrust());