configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal());
configuration.getIntValue("Option/PostsPerPage").setValue(options.getIntegerOption("PostsPerPage").getReal());
configuration.getIntValue("Option/CharactersPerPost").setValue(options.getIntegerOption("CharactersPerPost").getReal());
+ configuration.getIntValue("Option/PostCutOffLength").setValue(options.getIntegerOption("PostCutOffLength").getReal());
configuration.getBooleanValue("Option/RequireFullAccess").setValue(options.getBooleanOption("RequireFullAccess").getReal());
configuration.getIntValue("Option/PositiveTrust").setValue(options.getIntegerOption("PositiveTrust").getReal());
configuration.getIntValue("Option/NegativeTrust").setValue(options.getIntegerOption("NegativeTrust").getReal());
}));
options.addIntegerOption("PostsPerPage", new DefaultOption<Integer>(10, new IntegerRangeValidator(1, Integer.MAX_VALUE)));
options.addIntegerOption("CharactersPerPost", new DefaultOption<Integer>(200, new OrValidator<Integer>(new IntegerRangeValidator(50, Integer.MAX_VALUE), new EqualityValidator<Integer>(-1))));
+ options.addIntegerOption("PostCutOffLength", new DefaultOption<Integer>(200, new OrValidator<Integer>(new IntegerRangeValidator(50, Integer.MAX_VALUE), new EqualityValidator<Integer>(-1))));
options.addBooleanOption("RequireFullAccess", new DefaultOption<Boolean>(false));
options.addIntegerOption("PositiveTrust", new DefaultOption<Integer>(75, new IntegerRangeValidator(0, 100)));
options.addIntegerOption("NegativeTrust", new DefaultOption<Integer>(-25, new IntegerRangeValidator(-100, 100)));
loadConfigurationValue("InsertionDelay");
loadConfigurationValue("PostsPerPage");
loadConfigurationValue("CharactersPerPost");
+ loadConfigurationValue("PostCutOffLength");
options.getBooleanOption("RequireFullAccess").set(configuration.getBooleanValue("Option/RequireFullAccess").getValue(null));
loadConfigurationValue("PositiveTrust");
loadConfigurationValue("NegativeTrust");
}
/**
+ * Returns the number of characters the shortened post should have.
+ *
+ * @return The number of characters of the snippet
+ */
+ public int getPostCutOffLength() {
+ return options.getIntegerOption("PostCutOffLength").get();
+ }
+
+ /**
+ * Validates the number of characters after which to cut off the post.
+ *
+ * @param postCutOffLength
+ * The number of characters of the snippet
+ * @return {@code true} if the number of characters of the snippet is
+ * valid, {@code false} otherwise
+ */
+ public boolean validatePostCutOffLength(Integer postCutOffLength) {
+ return options.getIntegerOption("PostCutOffLength").validate(postCutOffLength);
+ }
+
+ /**
+ * Sets the number of characters the shortened post should have.
+ *
+ * @param postCutOffLength
+ * The number of characters of the snippet
+ * @return This preferences
+ */
+ public Preferences setPostCutOffLength(Integer postCutOffLength) {
+ options.getIntegerOption("PostCutOffLength").set(postCutOffLength);
+ return this;
+ }
+
+ /**
* Returns whether Sone requires full access to be even visible.
*
* @return {@code true} if Sone requires full access, {@code false}
} 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));
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());
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.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). The actual length of the snippet is determined by the option below.
+Page.Options.Option.PostCutOffLength.Description=The number of characters that are displayed if a post is deemed to long (see option above).
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.
WebInterface.DefaultText.EditImage.Title=Image title
WebInterface.DefaultText.EditImage.Description=Image description
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 off
+WebInterface.DefaultText.Option.CharactersPerPost=Number of characters a post must have to be shortened
+WebInterface.DefaultText.Option.PostCutOffLength=Number of characters for the snippet of the shortened post
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
<%/if>
<% post.text|html|store key=originalText text=true>
<% post.text|parse sone=post.sone|store key=parsedText text=true>
- <% post.text|parse sone=post.sone length=core.preferences.charactersPerPost|store key=shortText text=true>
+ <% post.text|parse sone=post.sone length=core.preferences.charactersPerPost cut-off-length=core.preferences.postCutOffLength|store key=shortText text=true>
<div class="post-text raw-text<%if !raw> hidden<%/if>"><% originalText></div>
<div class="post-text text<%if raw> hidden<%/if><%if !shortText|match key=parsedText> hidden<%/if>"><% parsedText></div>
<div class="post-text short-text<%if raw> hidden<%/if><%if shortText|match key=parsedText> hidden<%/if>"><% shortText></div>
<div class="author profile-link"><a href="viewSone.html?sone=<% reply.sone.id|html>"><% reply.sone.niceName|html></a></div>
<% reply.text|html|store key=originalText text=true>
<% reply.text|parse sone=reply.sone|store key=parsedText text=true>
- <% reply.text|parse sone=reply.sone length=core.preferences.charactersPerPost|store key=shortText text=true>
+ <% reply.text|parse sone=reply.sone length=core.preferences.charactersPerPost cut-off-length=core.preferences.postCutOffLength|store key=shortText text=true>
<div class="reply-text raw-text<%if !raw> hidden<%/if>"><% originalText></div>
<div class="reply-text text<%if raw> hidden<%/if><%if !shortText|match key=parsedText> hidden<%/if>"><% parsedText></div>
<div class="reply-text short-text<%if raw> hidden<%/if><%if shortText|match key=parsedText> hidden<%/if>"><% shortText></div>
getTranslation("WebInterface.DefaultText.Option.CharactersPerPost", function(postsPerPageText) {
registerInputTextareaSwap("#sone #options input[name=characters-per-post]", postsPerPageText, "characters-per-post", true, true);
});
+ getTranslation("WebInterface.DefaultText.Option.PostCutOffLength", function(postCutOffLengthText) {
+ registerInputTextareaSwap("#sone #options input[name=post-cut-off-length]", postCutOffLengthText, "post-cut-off-length", true, true);
+ });
getTranslation("WebInterface.DefaultText.Option.PositiveTrust", function(positiveTrustText) {
registerInputTextareaSwap("#sone #options input[name=positive-trust]", positiveTrustText, "positive-trust", true, true);
});
<%/if>
<p><input type="text" name="characters-per-post" value="<% characters-per-post|html>" /></p>
+ <p><%= Page.Options.Option.PostCutOffLength.Description|l10n|html></p>
+ <%if =post-cut-off-length|in collection=fieldErrors>
+ <p class="warning"><%= Page.Options.Warnings.ValueNotChanged|l10n|html></p>
+ <%/if>
+ <p><input type="text" name="post-cut-off-length" value="<% post-cut-off-length|html>" /></p>
+
<p>
<input type="checkbox" name="require-full-access"<%if require-full-access> checked="checked"<%/if> />
<%= Page.Options.Option.RequireFullAccess.Description|l10n|html></p>