import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.util.collection.Pagination;
import net.pterodactylus.util.template.Template;
/**
}
});
- template.set("posts", allPosts);
+ int page = request.getHttpRequest().getIntParam("page", 0);
+ Pagination<Post> postPagination = new Pagination<Post>(allPosts, 25).setPage(page);
+ List<Post> postsOnPage = postPagination.getItems();
+ template.set("posts", postsOnPage);
+ template.set("pagination", postPagination);
}
//
position: absolute;
}
+#sone .navigation {
+ text-align: center;
+}
+
+#sone .navigation .first a, #sone .navigation .previous a, #sone .navigation .next a, #sone .navigation .last a, #sone .navigation .first span, #sone .navigation .previous span, #sone .navigation .next span, #sone .navigation .last span {
+ display: block;
+ height: 1.5em;
+ padding: 0.5ex;
+ width: 3em;
+ border: solid 1px #ccc;
+ background-color: #f0f0ff;
+}
+
+#sone .navigation .first, #sone .navigation .previous {
+ float: left;
+}
+
+#sone .navigation .current-page, #sone .navigation .total-pages {
+ margin-top: 0.5ex;
+ display: inline;
+}
+
+#sone .navigation .total-pages:before {
+ content: '/ ';
+}
+
+#sone .navigation .next, #sone .navigation .last {
+ float: right;
+}
+
#sone h1 {
font-family: inherit;
font-size: 200%;
--- /dev/null
+<%if pagination.necessary>
+ <div class="navigation">
+ <div class="first"><%if ! pagination.first><a href="<% request|change name=page value=0>">«</a><%else><span>«</span><%/if></div>
+ <div class="previous"><%if ! pagination.first><a href="<% request|change name=page key=pagination.previousPage>">‹</a><%else><span>‹</span><%/if></div>
+ <div class="current-page"><% pagination.pageNumber></div>
+ <div class="total-pages"><% pagination.pageCount></div>
+ <div class="last"><%if ! pagination.last><a href="<% request|change name=page key=pagination.lastPage>">»</a><%else><span>»</span><%/if></div>
+ <div class="next"><%if ! pagination.last><a href="<% request|change name=page key=pagination.nextPage>">›</a><%else><span>›</span><%/if></div>
+ </div>
+<%/if>
<h1><%= Page.Index.PostList.Title|l10n|html></h1>
<div id="posts">
+ <%include include/pagination.html>
<%foreach posts post postLoop>
<%include include/viewPost.html>
<%foreachelse>
<div><%= Page.Index.PostList.Text.NoPostYet|l10n|html></div>
<%/foreach>
+ <%include include/pagination.html>
</div>
<%include include/tail.html>