From 154ebe9fb816972d081a328ff06c168c2a3912b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 21 Jun 2011 12:21:58 +0200 Subject: [PATCH] Add characters-per-post option to options page. --- src/main/java/net/pterodactylus/sone/web/OptionsPage.java | 7 +++++++ src/main/resources/i18n/sone.en.properties | 2 ++ src/main/resources/templates/options.html | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index 6785e81..4f76fda 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -78,6 +78,12 @@ public class OptionsPage extends SoneTemplatePage { } else { preferences.setPostsPerPage(postsPerPage); } + Integer charactersPerPost = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("characters-per-post", 10), null); + if (!preferences.validateCharactersPerPost(charactersPerPost)) { + fieldErrors.add("characters-per-post"); + } else { + preferences.setCharactersPerPost(charactersPerPost); + } boolean requireFullAccess = request.getHttpRequest().isPartSet("require-full-access"); preferences.setRequireFullAccess(requireFullAccess); Integer positiveTrust = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("positive-trust", 3)); @@ -119,6 +125,7 @@ public class OptionsPage extends SoneTemplatePage { } templateContext.set("insertion-delay", preferences.getInsertionDelay()); templateContext.set("posts-per-page", preferences.getPostsPerPage()); + templateContext.set("characters-per-post", preferences.getCharactersPerPost()); templateContext.set("require-full-access", preferences.isRequireFullAccess()); templateContext.set("positive-trust", preferences.getPositiveTrust()); templateContext.set("negative-trust", preferences.getNegativeTrust()); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index d3b4486..3af13db 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -38,6 +38,7 @@ Page.Options.Option.AutoFollow.Description=If a new Sone is discovered, follow i Page.Options.Section.RuntimeOptions.Title=Runtime Behaviour Page.Options.Option.InsertionDelay.Description=The number of seconds the Sone inserter waits after a modification of a Sone before it is being inserted. Page.Options.Option.PostsPerPage.Description=The number of posts to display on a page before pagination controls are being shown. +Page.Options.Option.CharactersPerPost.Description=The number of characters to display from a post before cutting it off and showing a link to expand it (-1 to disable). Page.Options.Option.RequireFullAccess.Description=Whether to deny access to Sone to any host that has not been granted full access. Page.Options.Section.TrustOptions.Title=Trust Settings Page.Options.Option.PositiveTrust.Description=The amount of positive trust you want to assign to other Sones by clicking the checkmark below a post or reply. @@ -284,6 +285,7 @@ WebInterface.DefaultText.BirthYear=Year WebInterface.DefaultText.FieldName=Field name WebInterface.DefaultText.Option.InsertionDelay=Time to wait after a Sone is modified before insert (in seconds) WebInterface.DefaultText.Option.PostsPerPage=Number of posts to show on a page +WebInterface.DefaultText.Option.CharactersPerPost=Number of characters per post after which to cut the post of f WebInterface.DefaultText.Option.PositiveTrust=The positive trust to assign WebInterface.DefaultText.Option.NegativeTrust=The negative trust to assign WebInterface.DefaultText.Option.TrustComment=The comment to set in the web of trust diff --git a/src/main/resources/templates/options.html b/src/main/resources/templates/options.html index 368c14e..c54088a 100644 --- a/src/main/resources/templates/options.html +++ b/src/main/resources/templates/options.html @@ -8,6 +8,9 @@ getTranslation("WebInterface.DefaultText.Option.PostsPerPage", function(postsPerPageText) { registerInputTextareaSwap("#sone #options input[name=posts-per-page]", postsPerPageText, "posts-per-page", true, true); }); + getTranslation("WebInterface.DefaultText.Option.CharactersPerPost", function(postsPerPageText) { + registerInputTextareaSwap("#sone #options input[name=posts-per-page]", postsPerPageText, "posts-per-page", true, true); + }); getTranslation("WebInterface.DefaultText.Option.PositiveTrust", function(positiveTrustText) { registerInputTextareaSwap("#sone #options input[name=positive-trust]", positiveTrustText, "positive-trust", true, true); }); @@ -54,6 +57,12 @@ <%/if>

+

<%= Page.Options.Option.CharactersPerPost.Description|l10n|html>

+ <%if =characters-per-post|in collection=fieldErrors> +

<%= Page.Options.Warnings.ValueNotChanged|l10n|html>

+ <%/if> +

+

checked="checked"<%/if> /> <%= Page.Options.Option.RequireFullAccess.Description|l10n|html>

-- 2.7.4