val imagesPerPage = soneRequest.parameters["images-per-page"]?.toIntOrNull()
val insertionDelay = soneRequest.parameters["insertion-delay"]?.toIntOrNull()
val fcpFullAccessRequired = soneRequest.parameters["fcp-full-access-required"]?.toIntOrNull()
+ val maxAgeOfPostsToLoad = soneRequest.parameters["max-age-of-posts-to-load"]?.toIntOrNull()
if (cantSetOption { soneRequest.core.preferences.newPostsPerPage = postsPerPage }) fieldsWithErrors += "posts-per-page"
if (cantSetOption { soneRequest.core.preferences.newCharactersPerPost = charactersPerPost }) fieldsWithErrors += "characters-per-post"
if (cantSetOption { soneRequest.core.preferences.newImagesPerPage = imagesPerPage }) fieldsWithErrors += "images-per-page"
if (cantSetOption { soneRequest.core.preferences.newInsertionDelay = insertionDelay }) fieldsWithErrors += "insertion-delay"
fcpFullAccessRequired?.also { if (cantSetOption { soneRequest.core.preferences.newFcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequired] }) fieldsWithErrors += "fcp-full-access-required" }
+ if (cantSetOption { soneRequest.core.preferences.newMaxAgeOfPostsToLoad = maxAgeOfPostsToLoad }) fieldsWithErrors += "max-age-of-posts-to-load"
if (fieldsWithErrors.isEmpty()) {
soneRequest.core.touchConfiguration()
templateContext["post-cut-off-length"] = preferences.postCutOffLength
templateContext["posts-per-page"] = preferences.postsPerPage
templateContext["strict-filtering"] = preferences.strictFiltering
+ templateContext["max-age-of-posts-to-load"] = preferences.maxAgeOfPostsToLoad
}
}
Page.Options.Option.ImagesPerPage.Description=Anzahl der Bilder pro Seite.
Page.Options.Option.CharactersPerPost.Description=Die Anzahl der Zeichen, die eine Nachricht enthalten muss, damit sie gekürzt angezeigt wird (-1 für „nie kürzen“). Die Anzahl der tatsächlich angezeigten Zeichen wird in der nächsten Option konfiguriert.
Page.Options.Option.PostCutOffLength.Description=Die Anzahl der Zeichen, die von einer gekürzten Nachricht sichtbar sind (siehe Option hierüber). Wird ignoriert, wenn die Option hierüber deaktiviert ist, bzw. auf -1 steht.
+Page.Options.Option.MaxAgeOfPostsToLoad.Description=Die Anzahl der Tage, die eine Nachricht oder eine Antwort maximal alt sein darf. Wenn dieser Wert erhöht wird, erhöht sich auch der Speicherbedarf von Sone. Der geänderte Wert wird nur angewendet, wenn eine Sone neu geladen wird, oder nach einem Neustart von Sone.
Page.Options.Option.RequireFullAccess.Description=Zugriff auf Sone für alle Rechner, die keinen vollen Zugriff haben, unterbinden.
Page.Options.Section.FcpOptions.Title=FCP-Schnittstellenoptionen
Page.Options.Option.FcpInterfaceActive.Description=Die FCP-Schnittstelle aktivieren, um anderen Plugins und Programmen den Zugriff auf Ihr Sone-Plugin zu ermöglichen.
WebInterface.DefaultText.Option.ImagesPerPage=Anzahl der Bilder pro Seite
WebInterface.DefaultText.Option.CharactersPerPost=Anzahl der Zeichen, die eine Nachricht haben muss, damit er gekürzt wird
WebInterface.DefaultText.Option.PostCutOffLength=Anzahl der Zeichen, die von einer gekürzten Nachricht angezeigt werden
+WebInterface.DefaultText.Option.MaxAgeOfPostsToLoad=Anzahl der Tage, die Nachrichten oder Antworten maximal alt sein dürfen
WebInterface.Button.Comment=Antworten
WebInterface.Confirmation.DeletePostButton=Ja, löschen!
WebInterface.Confirmation.DeleteReplyButton=Ja, löschen!
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 too long (see option above). Ignored if “number of characters to display” is disabled (set to -1).
+Page.Options.Option.MaxAgeOfPostsToLoad.Description=The number of days a post or reply may be old at most. Increasing this will make Sone use more memory. Changes will be applied when a Sone is being loaded, or when Sone is restarted.
Page.Options.Option.RequireFullAccess.Description=Whether to deny access to Sone to any host that has not been granted full access.
Page.Options.Section.FcpOptions.Title=FCP Interface Settings
Page.Options.Option.FcpInterfaceActive.Description=Activate the FCP interface to allow other plugins and remote clients to access your Sone plugin.
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.MaxAgeOfPostsToLoad=Number of days a post or reply may be old at most
WebInterface.Button.Comment=Comment
WebInterface.Confirmation.DeletePostButton=Yes, delete!
WebInterface.Confirmation.DeleteReplyButton=Yes, delete!
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.MaxAgeOfPostsToLoad", function(maxAgeOfPostsToLoadText) {
+ registerInputTextareaSwap("#sone #options input[name=max-age-of-posts-to-load]", maxAgeOfPostsToLoadText, "max-age-of-posts-to-load", true, true);
+ });
});
</script>
<%/if>
<p><input type="text" name="post-cut-off-length" value="<% post-cut-off-length|html>" /></p>
+ <p><%= Page.Options.Option.MaxAgeOfPostsToLoad.Description|l10n|html></p>
+ <%if =max-age-of-posts-to-load|in collection=fieldErrors>
+ <p class="warning"><%= Page.Options.Warnings.ValueNotChanged|l10n|html></p>
+ <%/if>
+ <p><input type="text" name="max-age-of-posts-to-load" value="<% max-age-of-posts-to-load|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>
core.preferences.newPostCutOffLength = 51
core.preferences.newPostsPerPage = 10
core.preferences.newStrictFiltering = true
+ core.preferences.newMaxAgeOfPostsToLoad = 123
}
@Before
assertThat(templateContext["post-cut-off-length"], equalTo<Any>(51))
assertThat(templateContext["posts-per-page"], equalTo<Any>(10))
assertThat(templateContext["strict-filtering"], equalTo<Any>(true))
+ assertThat(templateContext["max-age-of-posts-to-load"], equalTo(123))
}
}
}
@Test
+ fun `max age of posts to load can be set`() {
+ verifyThatPreferencesCanBeSet("max-age-of-posts-to-load", "23", 23) { core.preferences.maxAgeOfPostsToLoad }
+ }
+
+ @Test
+ fun `max age of posts to load cannot be set to a negative value`() {
+ verifyThatWrongValueForPreferenceIsDetected("max-age-of-posts-to-load", "-23")
+ }
+
+ @Test
+ fun `max age of posts to load is set to default on invalid value`() {
+ verifyThatPreferencesCanBeSet("max-age-of-posts-to-load", "invalid", 365) { core.preferences.maxAgeOfPostsToLoad }
+ }
+
+ @Test
+ fun `max age of posts to load is set to default on empty value`() {
+ verifyThatPreferencesCanBeSet("max-age-of-posts-to-load", "", 365) { core.preferences.maxAgeOfPostsToLoad }
+ }
+
+ @Test
fun `page can be created by dependency injection`() {
assertThat(baseInjector.getInstance<OptionsPage>(), notNullValue())
}