mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
🔥 remove posts.markdown field (#8497)
closes #8479 - removes `markdown` field from schema - removes `legacyMarkdown` converter - updates tests to work with `mobiledoc` field instead of `markdown` and adapt for mobiledoc HTML output where necessary
This commit is contained in:
parent
fff3d6d8a8
commit
85496f409a
@ -4,7 +4,6 @@ module.exports = {
|
||||
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
|
||||
title: {type: 'string', maxlength: 2000, nullable: false},
|
||||
slug: {type: 'string', maxlength: 191, nullable: false, unique: true},
|
||||
markdown: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
|
||||
mobiledoc: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
|
||||
html: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
|
||||
amp: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
|
||||
|
@ -5,7 +5,6 @@ var _ = require('lodash'),
|
||||
Promise = require('bluebird'),
|
||||
sequence = require('../utils/sequence'),
|
||||
errors = require('../errors'),
|
||||
legacyConverter = require('../utils/markdown-converter'),
|
||||
htmlToText = require('html-to-text'),
|
||||
ghostBookshelf = require('./base'),
|
||||
events = require('../events'),
|
||||
@ -235,9 +234,6 @@ Post = ghostBookshelf.Model.extend({
|
||||
|
||||
if (mobiledoc) {
|
||||
this.set('html', utils.mobiledocConverter.render(JSON.parse(mobiledoc)));
|
||||
} else {
|
||||
// legacy markdown mode
|
||||
this.set('html', legacyConverter.render(_.toString(this.get('markdown'))));
|
||||
}
|
||||
|
||||
if (this.hasChanged('html') || !this.get('plaintext')) {
|
||||
@ -524,7 +520,7 @@ Post = ghostBookshelf.Model.extend({
|
||||
return this.isPublicContext() ? 'page:false' : 'page:false+status:published';
|
||||
}
|
||||
}, {
|
||||
allowedFormats: ['markdown', 'mobiledoc', 'html', 'plaintext', 'amp'],
|
||||
allowedFormats: ['mobiledoc', 'html', 'plaintext', 'amp'],
|
||||
|
||||
orderDefaultOptions: function orderDefaultOptions() {
|
||||
return {
|
||||
|
@ -5,6 +5,7 @@ var should = require('should'),
|
||||
ObjectId = require('bson-objectid'),
|
||||
config = require('../../../../../core/server/config'),
|
||||
ghost = testUtils.startGhost,
|
||||
markdownToMobiledoc = testUtils.DataGenerator.markdownToMobiledoc,
|
||||
request;
|
||||
|
||||
describe('Post API', function () {
|
||||
@ -525,7 +526,7 @@ describe('Post API', function () {
|
||||
// ## Add
|
||||
describe('Add', function () {
|
||||
it('create and ensure dates are correct', function (done) {
|
||||
var newPost = {posts: [{status: 'published', published_at: '2016-05-30T07:00:00.000Z'}]};
|
||||
var newPost = {posts: [{status: 'published', published_at: '2016-05-30T07:00:00.000Z', mobiledoc: markdownToMobiledoc()}]};
|
||||
|
||||
request.post(testUtils.API.getApiQuery('posts'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
@ -576,7 +577,7 @@ describe('Post API', function () {
|
||||
newTagName = 'My Tag',
|
||||
publishedState = 'published',
|
||||
newTag = {id: null, name: newTagName},
|
||||
newPost = {posts: [{status: 'draft', title: newTitle, markdown: 'my post', tags: [newTag]}]};
|
||||
newPost = {posts: [{status: 'draft', title: newTitle, mobiledoc: markdownToMobiledoc('my post'), tags: [newTag]}]};
|
||||
|
||||
request.post(testUtils.API.getApiQuery('posts/?include=tags'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
@ -711,7 +712,7 @@ describe('Post API', function () {
|
||||
var newTitle = 'My Post',
|
||||
newTagName = 'My Tag',
|
||||
newTag = {id: null, name: newTagName},
|
||||
newPost = {posts: [{status: 'draft', title: newTitle, markdown: 'my post', tags: [newTag]}]};
|
||||
newPost = {posts: [{status: 'draft', title: newTitle, mobiledoc: markdownToMobiledoc('my post'), tags: [newTag]}]};
|
||||
|
||||
request.post(testUtils.API.getApiQuery('posts/?include=tags'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
@ -756,7 +757,7 @@ describe('Post API', function () {
|
||||
newTagName = 'My Tag',
|
||||
draftState = 'draft',
|
||||
newTag = {id: null, name: newTagName},
|
||||
newPost = {posts: [{status: 'published', title: newTitle, markdown: 'my post', tags: [newTag]}]};
|
||||
newPost = {posts: [{status: 'published', title: newTitle, mobiledoc: markdownToMobiledoc('my post'), tags: [newTag]}]};
|
||||
|
||||
request.post(testUtils.API.getApiQuery('posts/?include=tags'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
@ -1092,7 +1093,7 @@ describe('Post API', function () {
|
||||
it('can delete a new draft', function (done) {
|
||||
var newTitle = 'My Post',
|
||||
publishedState = 'draft',
|
||||
newPost = {posts: [{status: publishedState, title: newTitle, markdown: 'my post'}]};
|
||||
newPost = {posts: [{status: publishedState, title: newTitle, mobiledoc: markdownToMobiledoc('my post')}]};
|
||||
|
||||
request.post(testUtils.API.getApiQuery('posts/'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
|
@ -14,7 +14,8 @@ var should = require('should'),
|
||||
configUtils = require('../../utils/configUtils'),
|
||||
DataGenerator = testUtils.DataGenerator,
|
||||
context = testUtils.context.owner,
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox = sinon.sandbox.create(),
|
||||
markdownToMobiledoc = testUtils.DataGenerator.markdownToMobiledoc;
|
||||
|
||||
/**
|
||||
* IMPORTANT:
|
||||
@ -62,10 +63,9 @@ describe('Post Model', function () {
|
||||
firstPost.published_by.name.should.equal(DataGenerator.Content.users[0].name);
|
||||
firstPost.tags[0].name.should.equal(DataGenerator.Content.tags[0].name);
|
||||
|
||||
// @TODO change / update this for mobiledoc in
|
||||
if (options.formats) {
|
||||
if (options.formats.indexOf('markdown') !== -1) {
|
||||
firstPost.markdown.should.match(/HTML Ipsum Presents/);
|
||||
if (options.formats.indexOf('mobiledoc') !== -1) {
|
||||
firstPost.mobiledoc.should.match(/HTML Ipsum Presents/);
|
||||
}
|
||||
|
||||
if (options.formats.indexOf('html') !== -1) {
|
||||
@ -82,7 +82,7 @@ describe('Post Model', function () {
|
||||
} else {
|
||||
firstPost.html.should.match(/HTML Ipsum Presents/);
|
||||
should.equal(firstPost.plaintext, undefined);
|
||||
should.equal(firstPost.markdown, undefined);
|
||||
should.equal(firstPost.mobiledoc, undefined);
|
||||
should.equal(firstPost.amp, undefined);
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ describe('Post Model', function () {
|
||||
|
||||
it('can findAll, use formats option', function (done) {
|
||||
var options = {
|
||||
formats: ['markdown', 'plaintext'],
|
||||
formats: ['mobiledoc', 'plaintext'],
|
||||
include: ['author', 'fields', 'tags', 'created_by', 'updated_by', 'published_by']
|
||||
};
|
||||
|
||||
@ -182,7 +182,7 @@ describe('Post Model', function () {
|
||||
});
|
||||
|
||||
it('returns computed fields when columns are asked for explicitly', function (done) {
|
||||
PostModel.findPage({columns: ['id', 'slug', 'url', 'markdown']}).then(function (results) {
|
||||
PostModel.findPage({columns: ['id', 'slug', 'url', 'mobiledoc']}).then(function (results) {
|
||||
should.exist(results);
|
||||
|
||||
var post = _.find(results.posts, {slug: testUtils.DataGenerator.Content.posts[0].slug});
|
||||
@ -457,21 +457,6 @@ describe('Post Model', function () {
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('can change markdown to number', function (done) {
|
||||
var postId = testUtils.DataGenerator.Content.posts[0].id;
|
||||
|
||||
PostModel.findOne({id: postId}).then(function (results) {
|
||||
should.exist(results);
|
||||
var post = results.toJSON();
|
||||
post.title.should.not.equal('123');
|
||||
return PostModel.edit({markdown: 123}, _.extend({}, context, {id: postId}));
|
||||
}).then(function (edited) {
|
||||
should.exist(edited);
|
||||
edited.attributes.markdown.should.equal('123');
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('converts html to plaintext', function (done) {
|
||||
var postId = testUtils.DataGenerator.Content.posts[0].id;
|
||||
|
||||
@ -966,7 +951,7 @@ describe('Post Model', function () {
|
||||
createdPost.has('uuid').should.equal(true);
|
||||
createdPost.get('status').should.equal('draft');
|
||||
createdPost.get('title').should.equal(newPost.title, 'title is correct');
|
||||
createdPost.get('markdown').should.equal(newPost.markdown, 'markdown is correct');
|
||||
createdPost.get('mobiledoc').should.equal(newPost.mobiledoc, 'mobiledoc is correct');
|
||||
createdPost.has('html').should.equal(true);
|
||||
createdPost.get('html').should.equal(newPostDB.html);
|
||||
createdPost.has('plaintext').should.equal(true);
|
||||
@ -1023,17 +1008,6 @@ describe('Post Model', function () {
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('can add, with markdown being a number', function (done) {
|
||||
var newPost = testUtils.DataGenerator.forModel.posts[2];
|
||||
|
||||
newPost.markdown = 123;
|
||||
|
||||
PostModel.add(newPost, context).then(function (createdPost) {
|
||||
should.exist(createdPost);
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('can add, with previous published_at date', function (done) {
|
||||
var previousPublishedAtDate = new Date(2013, 8, 21, 12);
|
||||
|
||||
@ -1041,7 +1015,7 @@ describe('Post Model', function () {
|
||||
status: 'published',
|
||||
published_at: previousPublishedAtDate,
|
||||
title: 'published_at test',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).then(function (newPost) {
|
||||
should.exist(newPost);
|
||||
new Date(newPost.get('published_at')).getTime().should.equal(previousPublishedAtDate.getTime());
|
||||
@ -1058,7 +1032,7 @@ describe('Post Model', function () {
|
||||
PostModel.add({
|
||||
status: 'draft',
|
||||
title: 'draft 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).then(function (newPost) {
|
||||
should.exist(newPost);
|
||||
should.not.exist(newPost.get('published_at'));
|
||||
@ -1075,7 +1049,7 @@ describe('Post Model', function () {
|
||||
status: 'draft',
|
||||
published_at: moment().toDate(),
|
||||
title: 'draft 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).then(function (newPost) {
|
||||
should.exist(newPost);
|
||||
should.exist(newPost.get('published_at'));
|
||||
@ -1091,7 +1065,7 @@ describe('Post Model', function () {
|
||||
PostModel.add({
|
||||
status: 'scheduled',
|
||||
title: 'scheduled 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).catch(function (err) {
|
||||
should.exist(err);
|
||||
(err instanceof errors.ValidationError).should.eql(true);
|
||||
@ -1105,7 +1079,7 @@ describe('Post Model', function () {
|
||||
status: 'scheduled',
|
||||
published_at: moment().subtract(1, 'minute'),
|
||||
title: 'scheduled 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).catch(function (err) {
|
||||
should.exist(err);
|
||||
(err instanceof errors.ValidationError).should.eql(true);
|
||||
@ -1119,7 +1093,7 @@ describe('Post Model', function () {
|
||||
status: 'scheduled',
|
||||
published_at: moment().add(1, 'minute'),
|
||||
title: 'scheduled 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).catch(function (err) {
|
||||
(err instanceof errors.ValidationError).should.eql(true);
|
||||
Object.keys(eventsTriggered).length.should.eql(0);
|
||||
@ -1132,7 +1106,7 @@ describe('Post Model', function () {
|
||||
status: 'scheduled',
|
||||
published_at: moment().add(10, 'minute'),
|
||||
title: 'scheduled 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).then(function (post) {
|
||||
should.exist(post);
|
||||
|
||||
@ -1150,7 +1124,7 @@ describe('Post Model', function () {
|
||||
page: 1,
|
||||
published_at: moment().add(10, 'minute'),
|
||||
title: 'scheduled 1',
|
||||
markdown: 'This is some content'
|
||||
mobiledoc: markdownToMobiledoc('This is some content')
|
||||
}, context).then(function (post) {
|
||||
should.exist(post);
|
||||
|
||||
@ -1164,7 +1138,7 @@ describe('Post Model', function () {
|
||||
|
||||
it('can add default title, if it\'s missing', function (done) {
|
||||
PostModel.add({
|
||||
markdown: 'Content'
|
||||
mobiledoc: markdownToMobiledoc('Content')
|
||||
}, context).then(function (newPost) {
|
||||
should.exist(newPost);
|
||||
newPost.get('title').should.equal('(Untitled)');
|
||||
@ -1178,7 +1152,7 @@ describe('Post Model', function () {
|
||||
untrimmedUpdateTitle = ' test trimmed update title ',
|
||||
newPost = {
|
||||
title: untrimmedCreateTitle,
|
||||
markdown: 'Test Content'
|
||||
mobiledoc: markdownToMobiledoc('Test content')
|
||||
};
|
||||
|
||||
PostModel.add(newPost, context).then(function (createdPost) {
|
||||
@ -1207,7 +1181,7 @@ describe('Post Model', function () {
|
||||
return function () {
|
||||
return PostModel.add({
|
||||
title: 'Test Title',
|
||||
markdown: 'Test Content ' + (i + 1)
|
||||
mobiledoc: markdownToMobiledoc('Test Content ' + (i + 1))
|
||||
}, context);
|
||||
};
|
||||
})).then(function (createdPosts) {
|
||||
@ -1225,7 +1199,7 @@ describe('Post Model', function () {
|
||||
}
|
||||
|
||||
post.get('slug').should.equal('test-title-' + num);
|
||||
post.get('markdown').should.equal('Test Content ' + num);
|
||||
JSON.parse(post.get('mobiledoc')).cards[0][1].markdown.should.equal('Test Content ' + num);
|
||||
|
||||
Object.keys(eventsTriggered).length.should.eql(1);
|
||||
should.exist(eventsTriggered['post.added']);
|
||||
@ -1239,7 +1213,7 @@ describe('Post Model', function () {
|
||||
it('can generate slugs without duplicate hyphens', function (done) {
|
||||
var newPost = {
|
||||
title: 'apprehensive titles have too many spaces—and m-dashes — – and also n-dashes ',
|
||||
markdown: 'Test Content 1'
|
||||
mobiledoc: markdownToMobiledoc('Test Content 1')
|
||||
};
|
||||
|
||||
PostModel.add(newPost, context).then(function (createdPost) {
|
||||
@ -1255,7 +1229,7 @@ describe('Post Model', function () {
|
||||
it('can generate a safe slug when a reserved keyword is used', function (done) {
|
||||
var newPost = {
|
||||
title: 'rss',
|
||||
markdown: 'Test Content 1'
|
||||
mobiledoc: markdownToMobiledoc('Test Content 1')
|
||||
};
|
||||
|
||||
PostModel.add(newPost, context).then(function (createdPost) {
|
||||
@ -1271,7 +1245,7 @@ describe('Post Model', function () {
|
||||
it('can generate slugs without non-ascii characters', function (done) {
|
||||
var newPost = {
|
||||
title: 'भुते धडकी भरवणारा आहेत',
|
||||
markdown: 'Test Content 1'
|
||||
mobiledoc: markdownToMobiledoc('Test Content 1')
|
||||
};
|
||||
|
||||
PostModel.add(newPost, context).then(function (createdPost) {
|
||||
@ -1283,11 +1257,11 @@ describe('Post Model', function () {
|
||||
it('detects duplicate slugs before saving', function (done) {
|
||||
var firstPost = {
|
||||
title: 'First post',
|
||||
markdown: 'First content 1'
|
||||
mobiledoc: markdownToMobiledoc('First content 1')
|
||||
},
|
||||
secondPost = {
|
||||
title: 'Second post',
|
||||
markdown: 'Second content 1'
|
||||
mobiledoc: markdownToMobiledoc('Second content 1')
|
||||
};
|
||||
|
||||
// Create the first post
|
||||
|
@ -29,7 +29,7 @@ describe('Scheduling: Post Scheduling', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
scope.client = models.Client.forge(testUtils.DataGenerator.forKnex.createClient({slug: 'ghost-scheduler'}));
|
||||
scope.post = models.Post.forge(testUtils.DataGenerator.forKnex.createPost({id: 1337, markdown: 'something'}));
|
||||
scope.post = models.Post.forge(testUtils.DataGenerator.forKnex.createPost({id: 1337, mobiledoc: testUtils.DataGenerator.markdownToMobiledoc('something')}));
|
||||
|
||||
scope.adapter = new SchedulingDefault();
|
||||
|
||||
|
@ -8,6 +8,7 @@ var should = require('should'),
|
||||
configUtils = require('../../../utils/configUtils'),
|
||||
themes = require('../../../../server/themes'),
|
||||
settingsCache = require('../../../../server/settings/cache'),
|
||||
markdownToMobiledoc = require('../../../utils/fixtures/data-generator').markdownToMobiledoc,
|
||||
sandbox = sinon.sandbox.create();
|
||||
|
||||
describe('Frontend Controller', function () {
|
||||
@ -66,7 +67,7 @@ describe('Frontend Controller', function () {
|
||||
id: 1,
|
||||
title: 'Test static page',
|
||||
slug: 'test-static-page',
|
||||
markdown: 'Test static page content',
|
||||
mobiledoc: markdownToMobiledoc('Test static page content'),
|
||||
page: 1,
|
||||
published_at: new Date('2013/12/30').getTime(),
|
||||
author: {
|
||||
@ -83,7 +84,7 @@ describe('Frontend Controller', function () {
|
||||
id: 2,
|
||||
title: 'Test normal post',
|
||||
slug: 'test-normal-post',
|
||||
markdown: 'The test normal post content',
|
||||
mobiledoc: markdownToMobiledoc('The test normal post content'),
|
||||
page: 0,
|
||||
published_at: new Date('2014/1/2').getTime(),
|
||||
author: {
|
||||
@ -99,7 +100,7 @@ describe('Frontend Controller', function () {
|
||||
id: 3,
|
||||
title: 'About',
|
||||
slug: 'about',
|
||||
markdown: 'This is the about page content',
|
||||
mobiledoc: markdownToMobiledoc('This is the about page content'),
|
||||
page: 1,
|
||||
published_at: new Date('2014/1/30').getTime(),
|
||||
author: {
|
||||
@ -689,7 +690,7 @@ describe('Frontend Controller', function () {
|
||||
id: 1,
|
||||
title: 'Test static page',
|
||||
slug: 'test-static-page',
|
||||
markdown: 'Test static page content',
|
||||
mobiledoc: markdownToMobiledoc('Test static page content'),
|
||||
page: 1,
|
||||
author: {
|
||||
id: 1,
|
||||
@ -706,7 +707,7 @@ describe('Frontend Controller', function () {
|
||||
id: 2,
|
||||
title: 'Test normal post',
|
||||
slug: 'test-normal-post',
|
||||
markdown: 'The test normal post content',
|
||||
mobiledoc: markdownToMobiledoc('The test normal post content'),
|
||||
page: 0,
|
||||
author: {
|
||||
id: 1,
|
||||
@ -722,7 +723,7 @@ describe('Frontend Controller', function () {
|
||||
id: 3,
|
||||
title: 'Getting started',
|
||||
slug: 'about',
|
||||
markdown: 'This is a blog post',
|
||||
mobiledoc: markdownToMobiledoc('This is a blog post'),
|
||||
page: 0,
|
||||
published_at: new Date('2014/1/30').getTime(),
|
||||
author: {
|
||||
|
@ -1,12 +1,13 @@
|
||||
var should = require('should'),
|
||||
getAmpUrl = require('../../../server/data/meta/amp_url');
|
||||
getAmpUrl = require('../../../server/data/meta/amp_url'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc;
|
||||
|
||||
describe('getAmpUrl', function () {
|
||||
it('should return amp url for post only', function () {
|
||||
var ampUrl = getAmpUrl({
|
||||
url: '/this-is-a-test-post/',
|
||||
html: '<h1>Test 123</h1>',
|
||||
markdown: '# Test 123',
|
||||
markdown: markdownToMobiledoc('# Test 123'),
|
||||
title: 'This is a test post',
|
||||
slug: 'this-is-a-test-post',
|
||||
secure: true,
|
||||
|
@ -1,12 +1,13 @@
|
||||
var should = require('should'), // jshint ignore:line
|
||||
getCanonicalUrl = require('../../../server/data/meta/canonical_url');
|
||||
getCanonicalUrl = require('../../../server/data/meta/canonical_url'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc;
|
||||
|
||||
describe('getCanonicalUrl', function () {
|
||||
it('should return absolute canonical url for post', function () {
|
||||
var canonicalUrl = getCanonicalUrl({
|
||||
url: '/this-is-a-test-post/',
|
||||
html: '<h1>Test 123</h1>',
|
||||
markdown: '# Test 123',
|
||||
mobiledoc: markdownToMobiledoc('# Test 123'),
|
||||
title: 'This is a test post',
|
||||
slug: 'this-is-a-test-post',
|
||||
secure: true
|
||||
@ -20,7 +21,7 @@ describe('getCanonicalUrl', function () {
|
||||
var canonicalUrl = getCanonicalUrl({
|
||||
url: '/this-is-a-test-post/amp/',
|
||||
html: '<h1>Test 123</h1>',
|
||||
markdown: '# Test 123',
|
||||
mobiledoc: markdownToMobiledoc('# Test 123'),
|
||||
title: 'This is a test post',
|
||||
slug: 'this-is-a-test-post',
|
||||
secure: true
|
||||
|
@ -1,5 +1,6 @@
|
||||
var should = require('should'),
|
||||
getSchema = require('../../../server/data/meta/schema');
|
||||
getSchema = require('../../../server/data/meta/schema'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc;
|
||||
|
||||
describe('getSchema', function () {
|
||||
it('should return post schema if context starts with post', function (done) {
|
||||
@ -142,7 +143,7 @@ describe('getSchema', function () {
|
||||
post: {
|
||||
title: 'Post Title',
|
||||
slug: 'my-amp-post-slug',
|
||||
markdown: 'some markdown',
|
||||
mobiledoc: markdownToMobiledoc('some markdown'),
|
||||
html: 'some html',
|
||||
author: {
|
||||
name: 'Post Author',
|
||||
|
@ -1,11 +1,12 @@
|
||||
var should = require('should'), // jshint ignore:line
|
||||
getUrl = require('../../../server/data/meta/url');
|
||||
getUrl = require('../../../server/data/meta/url'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc;
|
||||
|
||||
describe('getUrl', function () {
|
||||
it('should return url for a post', function () {
|
||||
var url = getUrl({
|
||||
html: '<p>Welcome to my post.</p>',
|
||||
markdown: 'Welcome to my post.',
|
||||
mobiledoc: markdownToMobiledoc('Welcome to my post.'),
|
||||
title: 'Welcome Post',
|
||||
slug: 'welcome-post',
|
||||
url: '/post/welcome-post/'
|
||||
@ -16,7 +17,7 @@ describe('getUrl', function () {
|
||||
it('should return absolute url for a post', function () {
|
||||
var url = getUrl({
|
||||
html: '<p>Welcome to my post.</p>',
|
||||
markdown: 'Welcome to my post.',
|
||||
mobiledoc: markdownToMobiledoc('Welcome to my post.'),
|
||||
title: 'Welcome Post',
|
||||
slug: 'welcome-post',
|
||||
url: '/post/welcome-post/'
|
||||
|
@ -19,7 +19,7 @@ var should = require('should'), // jshint ignore:line
|
||||
// both of which are required for migrations to work properly.
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
var currentSchemaHash = '0d3a45d3db7f7ae6effb654621ca8ab5',
|
||||
var currentSchemaHash = 'd10bff0a4dbccbd5e5d66c9ed596301b',
|
||||
currentFixturesHash = 'ec48af84f206fa377214ed4311ba6dfd';
|
||||
|
||||
// If this test is failing, then it is likely a change has been made that requires a DB version bump,
|
||||
|
@ -167,7 +167,7 @@ describe('RSS', function () {
|
||||
// item tags
|
||||
xmlData.should.match(/<title><!\[CDATA\[Short and Sweet\]\]>/);
|
||||
xmlData.should.match(/<description><!\[CDATA\[test stuff/);
|
||||
xmlData.should.match(/<content:encoded><!\[CDATA\[<h2 id="testing">testing<\/h2>\n/);
|
||||
xmlData.should.match(/<content:encoded><!\[CDATA\[<div class="kg-card-markdown"><h2 id="testing">testing<\/h2>\n/);
|
||||
xmlData.should.match(/<img src="http:\/\/placekitten.com\/500\/200"/);
|
||||
xmlData.should.match(/<media:content url="http:\/\/placekitten.com\/500\/200" medium="image"\/>/);
|
||||
xmlData.should.match(/<category><!\[CDATA\[public\]\]/);
|
||||
@ -197,7 +197,7 @@ describe('RSS', function () {
|
||||
// special/optional tags
|
||||
xmlData.should.match(/<title><!\[CDATA\[Short and Sweet\]\]>/);
|
||||
xmlData.should.match(/<description><!\[CDATA\[test stuff/);
|
||||
xmlData.should.match(/<content:encoded><!\[CDATA\[<h2 id="testing">testing<\/h2>\n/);
|
||||
xmlData.should.match(/<content:encoded><!\[CDATA\[<div class="kg-card-markdown"><h2 id="testing">testing<\/h2>\n/);
|
||||
xmlData.should.match(/<img src="http:\/\/placekitten.com\/500\/200"/);
|
||||
xmlData.should.match(/<media:content url="http:\/\/placekitten.com\/500\/200" medium="image"\/>/);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
var should = require('should'), // jshint ignore:line
|
||||
sinon = require('sinon'),
|
||||
Promise = require('bluebird'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc,
|
||||
// Stuff we are testing
|
||||
helpers = require('../../../server/helpers'),
|
||||
api = require('../../../server/api'),
|
||||
@ -33,7 +34,7 @@ describe('{{next_post}} helper', function () {
|
||||
helpers.prev_post.call({
|
||||
html: 'content',
|
||||
status: 'published',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'post2',
|
||||
slug: 'current',
|
||||
created_at: new Date(0),
|
||||
@ -68,7 +69,7 @@ describe('{{next_post}} helper', function () {
|
||||
|
||||
helpers.prev_post.call({
|
||||
html: 'content',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'post2',
|
||||
slug: 'current',
|
||||
created_at: new Date(0),
|
||||
@ -127,7 +128,7 @@ describe('{{next_post}} helper', function () {
|
||||
helpers.prev_post.call({
|
||||
html: 'content',
|
||||
status: 'published',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'post2',
|
||||
slug: 'current',
|
||||
created_at: new Date(0),
|
||||
|
@ -1,6 +1,7 @@
|
||||
var should = require('should'), // jshint ignore:line
|
||||
sinon = require('sinon'),
|
||||
Promise = require('bluebird'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc,
|
||||
|
||||
// Stuff we are testing
|
||||
helpers = require('../../../server/helpers'),
|
||||
@ -34,7 +35,7 @@ describe('{{prev_post}} helper', function () {
|
||||
helpers.prev_post.call({
|
||||
html: 'content',
|
||||
status: 'published',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'post2',
|
||||
slug: 'current',
|
||||
created_at: new Date(0),
|
||||
@ -71,7 +72,7 @@ describe('{{prev_post}} helper', function () {
|
||||
helpers.prev_post.call({
|
||||
html: 'content',
|
||||
status: 'published',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'post2',
|
||||
slug: 'current',
|
||||
created_at: new Date(0),
|
||||
@ -134,7 +135,7 @@ describe('{{prev_post}} helper', function () {
|
||||
helpers.prev_post.call({
|
||||
html: 'content',
|
||||
status: 'draft',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'post2',
|
||||
slug: 'current',
|
||||
created_at: new Date(0),
|
||||
|
@ -2,6 +2,7 @@ var should = require('should'), // jshint ignore:line
|
||||
sinon = require('sinon'),
|
||||
Promise = require('bluebird'),
|
||||
configUtils = require('../../utils/configUtils'),
|
||||
markdownToMobiledoc = require('../../utils/fixtures/data-generator').markdownToMobiledoc,
|
||||
|
||||
// Stuff we are testing
|
||||
helpers = require('../../../server/helpers'),
|
||||
@ -34,7 +35,7 @@ describe('{{url}} helper', function () {
|
||||
it('should return the slug with a prefix slash if the context is a post', function () {
|
||||
rendered = helpers.url.call({
|
||||
html: 'content',
|
||||
markdown: 'ff',
|
||||
mobiledoc: markdownToMobiledoc('ff'),
|
||||
title: 'title',
|
||||
slug: 'slug',
|
||||
created_at: new Date(0),
|
||||
@ -47,7 +48,7 @@ describe('{{url}} helper', function () {
|
||||
|
||||
it('should output an absolute URL if the option is present', function () {
|
||||
rendered = helpers.url.call(
|
||||
{html: 'content', markdown: 'ff', title: 'title', slug: 'slug', url: '/slug/', created_at: new Date(0)},
|
||||
{html: 'content', mobiledoc: markdownToMobiledoc('ff'), title: 'title', slug: 'slug', url: '/slug/', created_at: new Date(0)},
|
||||
{hash: {absolute: 'true'}}
|
||||
);
|
||||
|
||||
@ -58,7 +59,7 @@ describe('{{url}} helper', function () {
|
||||
it('should output an absolute URL with https if the option is present and secure', function () {
|
||||
rendered = helpers.url.call(
|
||||
{
|
||||
html: 'content', markdown: 'ff', title: 'title', slug: 'slug',
|
||||
html: 'content', mobiledoc: markdownToMobiledoc('ff'), title: 'title', slug: 'slug',
|
||||
url: '/slug/', created_at: new Date(0), secure: true
|
||||
},
|
||||
{hash: {absolute: 'true'}}
|
||||
@ -71,7 +72,7 @@ describe('{{url}} helper', function () {
|
||||
it('should output an absolute URL with https if secure', function () {
|
||||
rendered = helpers.url.call(
|
||||
{
|
||||
html: 'content', markdown: 'ff', title: 'title', slug: 'slug',
|
||||
html: 'content', mobiledoc: markdownToMobiledoc('ff'), title: 'title', slug: 'slug',
|
||||
url: '/slug/', created_at: new Date(0), secure: true
|
||||
},
|
||||
{hash: {absolute: 'true'}}
|
||||
@ -94,7 +95,7 @@ describe('{{url}} helper', function () {
|
||||
});
|
||||
|
||||
it('should return / if not a post or tag', function () {
|
||||
rendered = helpers.url.call({markdown: 'ff', title: 'title', slug: 'slug'});
|
||||
rendered = helpers.url.call({mobiledoc: markdownToMobiledoc('ff'), title: 'title', slug: 'slug'});
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('/');
|
||||
|
||||
@ -102,11 +103,11 @@ describe('{{url}} helper', function () {
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('/');
|
||||
|
||||
rendered = helpers.url.call({html: 'content', markdown: 'ff', slug: 'slug'});
|
||||
rendered = helpers.url.call({html: 'content', mobiledoc: markdownToMobiledoc('ff'), slug: 'slug'});
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('/');
|
||||
|
||||
rendered = helpers.url.call({html: 'content', markdown: 'ff', title: 'title'});
|
||||
rendered = helpers.url.call({html: 'content', mobiledoc: markdownToMobiledoc('ff'), title: 'title'});
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('/');
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ var _ = require('lodash'),
|
||||
// Post API
|
||||
post: _(schema.posts).keys()
|
||||
// does not return all formats by default
|
||||
.without('markdown', 'mobiledoc', 'amp', 'plaintext')
|
||||
.without('mobiledoc', 'amp', 'plaintext')
|
||||
// swaps author_id to author, and always returns a computed 'url' property
|
||||
.without('author_id').concat('author', 'url')
|
||||
.value(),
|
||||
|
File diff suppressed because one or more lines are too long
@ -4,6 +4,7 @@
|
||||
var _ = require('lodash'),
|
||||
ObjectId = require('bson-objectid'),
|
||||
db = require('../../../../server/data/db'),
|
||||
markdownToMobiledoc = require('../../../utils/fixtures/data-generator').markdownToMobiledoc,
|
||||
data = {};
|
||||
|
||||
// Password = Sl1m3rson
|
||||
@ -83,7 +84,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'First Post',
|
||||
slug: 'first-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[0].id]
|
||||
@ -92,7 +93,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Second Post',
|
||||
slug: 'second-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[1].id,
|
||||
tags: [data.tags[1].id, data.tags[2].id, data.tags[3].id, data.tags[5].id]
|
||||
@ -101,7 +102,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Third Post',
|
||||
slug: 'third-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[1].id]
|
||||
@ -110,7 +111,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Fourth Post',
|
||||
slug: 'fourth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[2].id]
|
||||
@ -119,7 +120,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Fifth Post',
|
||||
slug: 'fifth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: true,
|
||||
author_id: data.users[1].id,
|
||||
tags: [data.tags[5].id]
|
||||
@ -128,7 +129,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Sixth Post',
|
||||
slug: 'sixth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[1].id,
|
||||
feature_image: 'some/image/path.jpg',
|
||||
@ -138,7 +139,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Seventh Post',
|
||||
slug: 'seventh-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
feature_image: 'some/image/path.jpg',
|
||||
@ -148,7 +149,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Eighth Post',
|
||||
slug: 'eighth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: true,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[0].id, data.tags[2].id, data.tags[3].id]
|
||||
@ -157,7 +158,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Ninth Post',
|
||||
slug: 'ninth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[1].id, data.tags[3].id]
|
||||
@ -166,7 +167,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Tenth Post',
|
||||
slug: 'tenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[2].id]
|
||||
@ -175,7 +176,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Eleventh Post',
|
||||
slug: 'eleventh-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
feature_image: 'some/image/path.jpg',
|
||||
@ -185,7 +186,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Twelfth Post',
|
||||
slug: 'twelfth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[3].id]
|
||||
@ -194,7 +195,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Thirteenth Post',
|
||||
slug: 'thirteenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: []
|
||||
@ -203,7 +204,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Fourteenth Post',
|
||||
slug: 'fourteenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: true,
|
||||
author_id: data.users[0].id,
|
||||
tags: [data.tags[3].id]
|
||||
@ -212,7 +213,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Fifteenth Post',
|
||||
slug: 'fifteenth-post',
|
||||
markdown: 'Hello World! I am a featured page',
|
||||
mobiledoc: markdownToMobiledoc('Hello World! I am a featured page'),
|
||||
featured: true,
|
||||
page: 1,
|
||||
author_id: data.users[0].id,
|
||||
@ -222,7 +223,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Sixteenth Post',
|
||||
slug: 'sixteenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: []
|
||||
@ -231,7 +232,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Seventeenth Post',
|
||||
slug: 'seventeenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: []
|
||||
@ -240,7 +241,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Eighteenth Post',
|
||||
slug: 'eighteenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: []
|
||||
@ -249,7 +250,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Nineteenth Post',
|
||||
slug: 'nineteenth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
status: 'draft',
|
||||
author_id: data.users[0].id,
|
||||
@ -259,7 +260,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'Twentieth Post',
|
||||
slug: 'twentieth-post',
|
||||
markdown: 'Hello World!',
|
||||
mobiledoc: markdownToMobiledoc('Hello World!'),
|
||||
featured: false,
|
||||
author_id: data.users[0].id,
|
||||
tags: []
|
||||
@ -268,7 +269,7 @@ data.posts = [
|
||||
id: ObjectId.generate(),
|
||||
title: 'About Page',
|
||||
slug: 'about',
|
||||
markdown: 'About Me!',
|
||||
mobiledoc: markdownToMobiledoc('About Me!'),
|
||||
featured: false,
|
||||
page: 1,
|
||||
author_id: data.users[0].id,
|
||||
|
Loading…
Reference in New Issue
Block a user