diff --git a/core/client/assets/sass/modules/global.scss b/core/client/assets/sass/modules/global.scss
index 418812d9da..d3c9ad6fa3 100644
--- a/core/client/assets/sass/modules/global.scss
+++ b/core/client/assets/sass/modules/global.scss
@@ -856,7 +856,7 @@ nav {
}
.post-setting {
- min-width: 260px;
+ min-width: 300px;
border-bottom: 1px solid #35393b;
&:first-child {
diff --git a/core/client/router.js b/core/client/router.js
index b6e0fce352..bd69855f50 100644
--- a/core/client/router.js
+++ b/core/client/router.js
@@ -31,7 +31,7 @@
blog: function () {
var posts = new Ghost.Collections.Posts();
NProgress.start();
- posts.fetch({ data: { status: 'all', orderBy: ['updated_at', 'DESC'] } }).then(function () {
+ posts.fetch({ data: { status: 'all', orderBy: ['updated_at', 'DESC'], where: { page: 'all' } } }).then(function () {
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
NProgress.done();
});
diff --git a/core/client/tpl/list-item.hbs b/core/client/tpl/list-item.hbs
index b09c9b1a3c..293e38c53c 100644
--- a/core/client/tpl/list-item.hbs
+++ b/core/client/tpl/list-item.hbs
@@ -1,4 +1,4 @@
-
+
{{{title}}}
+ {{#if page}}
+ | Static Page
+ {{/if}}
{{!1,934}}
-
\ No newline at end of file
+
diff --git a/core/client/tpl/preview.hbs b/core/client/tpl/preview.hbs
index 878618248e..c1e71da962 100644
--- a/core/client/tpl/preview.hbs
+++ b/core/client/tpl/preview.hbs
@@ -27,6 +27,14 @@
+
+
+
+
+
+
+
+
Delete This Post
diff --git a/core/client/views/blog.js b/core/client/views/blog.js
index 17546c21db..d5697b307c 100644
--- a/core/client/views/blog.js
+++ b/core/client/views/blog.js
@@ -93,6 +93,7 @@
data: {
status: 'all',
page: (self.collection.currentPage + 1),
+ where: { page: 'all' },
orderBy: ['updated_at', 'DESC']
}
}).then(function onSuccess(response) {
@@ -135,6 +136,7 @@
initialize: function () {
this.listenTo(Backbone, 'blog:activeItem', this.checkActive);
+ this.listenTo(this.model, 'change:page', this.render);
this.listenTo(this.model, 'destroy', this.removeItem);
},
diff --git a/core/client/views/post-settings.js b/core/client/views/post-settings.js
index d17a7dcf45..6d93d1b854 100644
--- a/core/client/views/post-settings.js
+++ b/core/client/views/post-settings.js
@@ -11,6 +11,7 @@
'blur .post-setting-slug' : 'editSlug',
'click .post-setting-slug' : 'selectSlug',
'blur .post-setting-date' : 'editDate',
+ 'click .post-setting-static-page' : 'toggleStaticPage',
'click .delete' : 'deletePost'
},
@@ -19,6 +20,7 @@
this.listenTo(this.model, 'change:id', this.render);
this.listenTo(this.model, 'change:status', this.render);
this.listenTo(this.model, 'change:published_at', this.render);
+ this.listenTo(this.model, 'change:page', this.render);
}
},
@@ -29,12 +31,18 @@
$('.post-setting-slug').val(slug);
+ // Update page status test if already a page.
+ if (this.model && this.model.get('page')) {
+ $('.post-setting-static-page').prop('checked', this.model.get('page'));
+ }
+
// Insert the published date, and make it editable if it exists.
if (this.model && this.model.get('published_at')) {
pubDate = moment(pubDate).format('DD MMM YY');
}
if (this.model && this.model.get('id')) {
+ this.$('.post-setting-page').removeClass('hidden');
this.$('.delete').removeClass('hidden');
}
@@ -141,6 +149,32 @@
},
+ toggleStaticPage: function (e) {
+ e.preventDefault();
+ var pageEl = $(e.currentTarget),
+ page = this.model ? !this.model.get('page') : false;
+
+ this.model.save({
+ page: page
+ }, {
+ success : function (model, response, options) {
+ pageEl.prop('checked', page);
+ Ghost.notifications.addItem({
+ type: 'success',
+ message: "Successfully converted " + (page ? "to static page" : "to post") + '.',
+ status: 'passive'
+ });
+ },
+ error : function (model, xhr) {
+ Ghost.notifications.addItem({
+ type: 'error',
+ message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
+ status: 'passive'
+ });
+ }
+ });
+ },
+
deletePost: function (e) {
e.preventDefault();
var self = this;
diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js
index 1f5ecdbf61..7ee6b4615d 100644
--- a/core/server/helpers/index.js
+++ b/core/server/helpers/index.js
@@ -219,7 +219,8 @@ coreHelpers = function (ghost) {
ghost.registerThemeHelper('body_class', function (options) {
var classes = [],
- tags = this.post && this.post.tags ? this.post.tags : this.tags || [];
+ tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
+ page = this.post && this.post.page ? this.post.page : this.page || false;
if (_.isString(this.path) && this.path.match(/\/page/)) {
classes.push('archive-template');
@@ -233,6 +234,10 @@ coreHelpers = function (ghost) {
classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; }));
}
+ if (page) {
+ classes.push('page');
+ }
+
return ghost.doFilter('body_class', classes, function (classes) {
var classString = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(classString.trim());
@@ -242,7 +247,8 @@ coreHelpers = function (ghost) {
ghost.registerThemeHelper('post_class', function (options) {
var classes = ['post'],
tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
- featured = this.post && this.post.featured ? this.post.featured : this.featured || false;
+ featured = this.post && this.post.featured ? this.post.featured : this.featured || false,
+ page = this.post && this.post.page ? this.post.page : this.page || false;
if (tags) {
classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; }));
@@ -252,6 +258,10 @@ coreHelpers = function (ghost) {
classes.push('featured');
}
+ if (page) {
+ classes.push('page');
+ }
+
return ghost.doFilter('post_class', classes, function (classes) {
var classString = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(classString.trim());
diff --git a/core/server/models/post.js b/core/server/models/post.js
index 20003fc972..72589ddfde 100644
--- a/core/server/models/post.js
+++ b/core/server/models/post.js
@@ -20,7 +20,7 @@ Post = ghostBookshelf.Model.extend({
permittedAttributes: [
'id', 'uuid', 'title', 'slug', 'markdown', 'html', 'meta_title', 'meta_description',
'featured', 'image', 'status', 'language', 'author_id', 'created_at', 'created_by', 'updated_at', 'updated_by',
- 'published_at', 'published_by'
+ 'page', 'published_at', 'published_by'
],
defaults: function () {
@@ -225,13 +225,17 @@ Post = ghostBookshelf.Model.extend({
opts = _.extend({
page: 1,
limit: 15,
- where: {},
+ where: { page: false },
status: 'published',
orderBy: ['published_at', 'DESC']
}, opts);
postCollection = Posts.forge();
+ if (opts.where && opts.where.page === 'all') {
+ delete opts.where.page;
+ }
+
// Unless `all` is passed as an option, filter on
// the status provided.
if (opts.status !== 'all') {
diff --git a/core/server/views/editor.hbs b/core/server/views/editor.hbs
index fe54aa4122..1f505f86fd 100644
--- a/core/server/views/editor.hbs
+++ b/core/server/views/editor.hbs
@@ -60,6 +60,14 @@
+
+
+
+
+
+
+
+
Delete This Post
diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js
index 0174928ca1..59115b8b2c 100644
--- a/core/test/unit/server_helpers_index_spec.js
+++ b/core/test/unit/server_helpers_index_spec.js
@@ -184,6 +184,16 @@ describe('Core Helpers', function () {
rendered2.string.should.equal('post-template');
rendered3.string.should.equal('archive-template');
});
+
+ it('can render class for static page', function () {
+ var rendered = handlebars.helpers.body_class.call(
+ {post: {page: true}},
+ {path: '/'}
+ );
+
+ should.exist(rendered);
+ rendered.string.should.equal('home-template page');
+ });
});
describe('post_class Helper', function () {