diff --git a/core/client/tpl/settings/general.hbs b/core/client/tpl/settings/general.hbs
index cc344f147f..9d95b01561 100644
--- a/core/client/tpl/settings/general.hbs
+++ b/core/client/tpl/settings/general.hbs
@@ -57,10 +57,15 @@
+
diff --git a/core/client/views/settings.js b/core/client/views/settings.js
index aed31a4ca1..9b6ec81ed0 100644
--- a/core/client/views/settings.js
+++ b/core/client/views/settings.js
@@ -164,7 +164,8 @@
email: this.$('#email-address').val(),
logo: this.$('#logo').attr("src"),
icon: this.$('#icon').attr("src"),
- activeTheme: this.$('#activeTheme').val()
+ activeTheme: this.$('#activeTheme').val(),
+ postsPerPage: this.$('#postsPerPage').val()
}, {
success: this.saveSuccess,
error: this.saveError
diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js
index e4b0deecaa..461dc8699d 100644
--- a/core/server/controllers/frontend.js
+++ b/core/server/controllers/frontend.js
@@ -14,14 +14,24 @@ var Ghost = require('../../ghost'),
frontendControllers = {
'homepage': function (req, res) {
// Parse the page number
- var pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1;
+ var pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1,
+ postsPerPage = parseInt(ghost.settings().postsPerPage, 10),
+ options = {};
// No negative pages
- if (pageParam < 1) {
+ if (isNaN(pageParam) || pageParam < 1) {
+ //redirect to 404 page?
return res.redirect("/page/1/");
}
+ options.page = pageParam;
+
+ // No negative posts per page, must be number
+ if (!isNaN(postsPerPage) && postsPerPage > 0) {
+ options.limit = postsPerPage;
+ }
+
+ api.posts.browse(options).then(function (page) {
- api.posts.browse({page: pageParam}).then(function (page) {
var maxPage = page.pages;
// A bit of a hack for situations with no content.
diff --git a/core/server/data/default-settings.json b/core/server/data/default-settings.json
index 0800b357e3..d0dd67abc9 100644
--- a/core/server/data/default-settings.json
+++ b/core/server/data/default-settings.json
@@ -43,5 +43,11 @@
"key": "icon",
"value": "",
"type": "blog"
+ },
+ {
+ "key": "postsPerPage",
+ "value": "6",
+ "type": "blog"
}
+
]