projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
128580d
)
Store preferences in template context instead of core
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 8 Feb 2017 06:14:21 +0000
(07:14 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 8 Feb 2017 06:14:21 +0000
(07:14 +0100)
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
patch
|
blob
|
history
src/main/resources/templates/imageBrowser.html
patch
|
blob
|
history
src/main/resources/templates/include/viewPost.html
patch
|
blob
|
history
src/main/resources/templates/include/viewReply.html
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/SoneTemplatePageTest.kt
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
index
2b16dba
..
bece45d
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
@@
-201,7
+201,7
@@
public class SoneTemplatePage extends FreenetTemplatePage {
protected final void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
Sone currentSone = getCurrentSoneWithoutCreatingSession(request.getToadletContext());
protected final void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
Sone currentSone = getCurrentSoneWithoutCreatingSession(request.getToadletContext());
- templateContext.set("
core", webInterface.getCore
());
+ templateContext.set("
preferences", webInterface.getCore().getPreferences
());
templateContext.set("currentSone", currentSone);
templateContext.set("localSones", webInterface.getCore().getLocalSones());
templateContext.set("request", request);
templateContext.set("currentSone", currentSone);
templateContext.set("localSones", webInterface.getCore().getLocalSones());
templateContext.set("request", request);
diff --git
a/src/main/resources/templates/imageBrowser.html
b/src/main/resources/templates/imageBrowser.html
index
7e4c824
..
b8b9cb2
100644
(file)
--- a/
src/main/resources/templates/imageBrowser.html
+++ b/
src/main/resources/templates/imageBrowser.html
@@
-376,7
+376,7
@@
</div>
<%/if>
</div>
<%/if>
- <%foreach album.images image|paginate pageSize=
core.
preferences.imagesPerPage page=page>
+ <%foreach album.images image|paginate pageSize=preferences.imagesPerPage page=page>
<%first>
<h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2>
<%include include/pagination.html pageParameter=="page">
<%first>
<h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2>
<%include include/pagination.html pageParameter=="page">
@@
-599,7
+599,7
@@
<%elseif galleryRequested>
<%elseif galleryRequested>
- <%foreach albums album|paginate pageSize=
core.
preferences.imagesPerPage pageParameter=request.page pagination=albumPagination>
+ <%foreach albums album|paginate pageSize=preferences.imagesPerPage pageParameter=request.page pagination=albumPagination>
<%first>
<h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2>
<%include include/pagination.html pagination=albumPagination pageParameter=="page">
<%first>
<h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2>
<%include include/pagination.html pagination=albumPagination pageParameter=="page">
diff --git
a/src/main/resources/templates/include/viewPost.html
b/src/main/resources/templates/include/viewPost.html
index
12d37db
..
ed6e5cc
100644
(file)
--- a/
src/main/resources/templates/include/viewPost.html
+++ b/
src/main/resources/templates/include/viewPost.html
@@
-29,7
+29,7
@@
<% post.text|html|store key==originalText text==true>
<% post.text|parse sone=post.sone|store key==parsedText>
<% parsedText|render|store key==renderedText text==true>
<% post.text|html|store key==originalText text==true>
<% post.text|parse sone=post.sone|store key==parsedText>
<% parsedText|render|store key==renderedText text==true>
- <% parsedText|shorten length=
core.preferences.charactersPerPost cut-off-length=core.
preferences.postCutOffLength|render|store key==shortText text==true>
+ <% parsedText|shorten length=
preferences.charactersPerPost cut-off-length=
preferences.postCutOffLength|render|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=renderedText> hidden<%/if>"><% renderedText></div>
<div class="post-text short-text<%if raw> hidden<%/if><%if shortText|match key=renderedText> hidden<%/if>"><% shortText></div>
<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=renderedText> hidden<%/if>"><% renderedText></div>
<div class="post-text short-text<%if raw> hidden<%/if><%if shortText|match key=renderedText> hidden<%/if>"><% shortText></div>
diff --git
a/src/main/resources/templates/include/viewReply.html
b/src/main/resources/templates/include/viewReply.html
index
211c1d3
..
32fb73d
100644
(file)
--- a/
src/main/resources/templates/include/viewReply.html
+++ b/
src/main/resources/templates/include/viewReply.html
@@
-17,7
+17,7
@@
<% reply.text|html|store key==originalText text==true>
<% reply.text|parse sone=reply.sone|store key==parsedText>
<% parsedText|render|store key==renderedText text==true>
<% reply.text|html|store key==originalText text==true>
<% reply.text|parse sone=reply.sone|store key==parsedText>
<% parsedText|render|store key==renderedText text==true>
- <% parsedText|shorten length=
core.preferences.charactersPerPost cut-off-length=core.
preferences.postCutOffLength|render|store key==shortText text==true>
+ <% parsedText|shorten length=
preferences.charactersPerPost cut-off-length=
preferences.postCutOffLength|render|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=renderedText> hidden<%/if>"><% renderedText></div>
<div class="reply-text short-text<%if raw> hidden<%/if><%if shortText|match key=renderedText> hidden<%/if>"><% shortText></div>
<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=renderedText> hidden<%/if>"><% renderedText></div>
<div class="reply-text short-text<%if raw> hidden<%/if><%if shortText|match key=renderedText> hidden<%/if>"><% shortText></div>
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/SoneTemplatePageTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/SoneTemplatePageTest.kt
index
b4a6a55
..
06d4c19
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/SoneTemplatePageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/SoneTemplatePageTest.kt
@@
-24,7
+24,7
@@
import org.mockito.Mockito.verify
*/
class SoneTemplatePageTest : WebPageTest() {
*/
class SoneTemplatePageTest : WebPageTest() {
- // @get:JvmName("getPage1")
+ private val preferences by lazy { core.preferences!! }
private val page = object : SoneTemplatePage("path.html", template, webInterface, true) {}
@Test
private val page = object : SoneTemplatePage("path.html", template, webInterface, true) {}
@Test
@@
-107,8
+107,8
@@
class SoneTemplatePageTest : WebPageTest() {
}
@Test
}
@Test
- fun `
core is
set in template context`() {
-
verifyVariableIsSet("core", core
)
+ fun `
preferences are
set in template context`() {
+
verifyVariableIsSet("preferences", preferences
)
}
@Test
}
@Test