configuration.getIntValue("Option/ConfigurationVersion").setValue(0);
configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal());
configuration.getIntValue("Option/PostsPerPage").setValue(options.getIntegerOption("PostsPerPage").getReal());
+ configuration.getIntValue("Option/ImagesPerPage").setValue(options.getIntegerOption("ImagesPerPage").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());
}));
options.addIntegerOption("PostsPerPage", new DefaultOption<Integer>(10, new IntegerRangeValidator(1, Integer.MAX_VALUE)));
+ options.addIntegerOption("ImagesPerPage", new DefaultOption<Integer>(9, new IntegerRangeValidator(1, Integer.MAX_VALUE)));
options.addIntegerOption("CharactersPerPost", new DefaultOption<Integer>(400, 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));
loadConfigurationValue("InsertionDelay");
loadConfigurationValue("PostsPerPage");
+ loadConfigurationValue("ImagesPerPage");
loadConfigurationValue("CharactersPerPost");
loadConfigurationValue("PostCutOffLength");
options.getBooleanOption("RequireFullAccess").set(configuration.getBooleanValue("Option/RequireFullAccess").getValue(null));
}
/**
+ * Returns the number of images to show per page.
+ *
+ * @return The number of images to show per page
+ */
+ public int getImagesPerPage() {
+ return options.getIntegerOption("ImagesPerPage").get();
+ }
+
+ /**
+ * Validates the number of images per page.
+ *
+ * @param imagesPerPage
+ * The number of images per page
+ * @return {@code true} if the number of images per page was valid,
+ * {@code false} otherwise
+ */
+ public boolean validateImagesPerPage(Integer imagesPerPage) {
+ return options.getIntegerOption("ImagesPerPage").validate(imagesPerPage);
+ }
+
+ /**
+ * Sets the number of images per page.
+ *
+ * @param imagesPerPage
+ * The number of images per page
+ * @return This preferences object
+ */
+ public Preferences setImagesPerPage(Integer imagesPerPage) {
+ options.getIntegerOption("ImagesPerPage").set(imagesPerPage);
+ return this;
+ }
+
+ /**
* Returns the number of characters per post, or <code>-1</code> if the
* posts should not be cut off.
*
} 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");
}
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());
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.ImagesPerPage.Description=The number of images 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). 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.
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.ImagesPerPage=Number of images to show on a page
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
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.ImagesPerPage", function(imagesPerPageText) {
+ registerInputTextareaSwap("#sone #options input[name=images-per-page]", imagesPerPageText, "images-per-page", true, true);
+ });
getTranslation("WebInterface.DefaultText.Option.CharactersPerPost", function(postsPerPageText) {
registerInputTextareaSwap("#sone #options input[name=characters-per-post]", postsPerPageText, "characters-per-post", true, true);
});
<%/if>
<p><input type="text" name="posts-per-page" value="<% posts-per-page|html>" /></p>
+ <p><%= Page.Options.Option.ImagesPerPage.Description|l10n|html></p>
+ <%if =images-per-page|in collection=fieldErrors>
+ <p class="warning"><%= Page.Options.Warnings.ValueNotChanged|l10n|html></p>
+ <%/if>
+ <p><input type="text" name="images-per-page" value="<% images-per-page|html>" /></p>
+
<p><%= Page.Options.Option.CharactersPerPost.Description|l10n|html></p>
<%if =characters-per-post|in collection=fieldErrors>
<p class="warning"><%= Page.Options.Warnings.ValueNotChanged|l10n|html></p>