mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-13 10:55:58 +03:00
Mass renaming of things
Conflicts: core/client/views/settings.js core/server/models/user.js
This commit is contained in:
parent
d587a845d4
commit
d968495996
@ -19,11 +19,11 @@ fancifyPlugin = {
|
||||
getIndexOfNextCharacter = function (beginFrom) {
|
||||
var currIndex = beginFrom,
|
||||
nextChar;
|
||||
|
||||
|
||||
nextChar = originalContent.substr(currIndex, 1);
|
||||
while (_.contains(whiteSpace, nextChar) && currIndex !== originalContent.length) {
|
||||
currIndex += 1;
|
||||
nextChar = originalContent.substr(currIndex, 1);
|
||||
nextChar = originalContent.substr(currIndex, 1);
|
||||
}
|
||||
|
||||
return currIndex;
|
||||
@ -31,7 +31,7 @@ fancifyPlugin = {
|
||||
getAfterNextClosingTag = function (beginFrom) {
|
||||
return originalContent.indexOf('>', beginFrom) + 1;
|
||||
};
|
||||
|
||||
|
||||
// Skip any leading white space until we get a character
|
||||
firstCharIndex = getIndexOfNextCharacter(firstCharIndex);
|
||||
|
||||
@ -67,10 +67,10 @@ fancifyPlugin = {
|
||||
|
||||
if (_.isArray(posts)) {
|
||||
_.each(posts, function (post) {
|
||||
post.content = self.fancify(post.content);
|
||||
post.html = self.fancify(post.html);
|
||||
});
|
||||
} else if (posts.hasOwnProperty('content')) {
|
||||
posts.content = this.fancify(posts.content);
|
||||
} else if (posts.hasOwnProperty('html')) {
|
||||
posts.html = this.fancify(posts.html);
|
||||
}
|
||||
|
||||
return posts;
|
||||
@ -84,7 +84,7 @@ fancifyPlugin = {
|
||||
|
||||
},
|
||||
|
||||
// Registers the prePostsRender filter to alter the content.
|
||||
// Registers the prePostsRender filter to alter the html.
|
||||
activate: function (ghost) {
|
||||
ghost.registerFilter('prePostsRender', this.fancifyPosts);
|
||||
},
|
||||
|
@ -5,7 +5,7 @@
|
||||
{{! TODO: JavaScript toggle featured/unfeatured}}
|
||||
<span class="status">{{#if published}}Published{{else}}Written{{/if}}</span>
|
||||
<span class="normal">by</span>
|
||||
<span class="author">{{#if author.name}}{{author.name}}{{else}}{{author.email_address}}{{/if}}</span>
|
||||
<span class="author">{{#if author.name}}{{author.name}}{{else}}{{author.email}}{{/if}}</span>
|
||||
<section class="post-controls">
|
||||
<a class="post-edit" href="#"><span class="hidden">Edit Post</span></a>
|
||||
<a class="post-settings" href="#" data-toggle=".menu-drop-right"><span class="hidden">Post Settings</span></a>
|
||||
@ -31,5 +31,5 @@
|
||||
</section>
|
||||
</header>
|
||||
<section class="content-preview-content">
|
||||
<div class="wrapper"><h1>{{{title}}}</h1>{{{content}}}</div>
|
||||
<div class="wrapper"><h1>{{{title}}}</h1>{{{html}}}</div>
|
||||
</section>
|
@ -7,25 +7,25 @@
|
||||
<section class="content no-padding">
|
||||
<header class="user-profile-header">
|
||||
<figure class="cover-image">
|
||||
<img id="user-cover-picture" src="{{#if cover_picture}}{{cover_picture}}{{else}}/shared/img/default-user-cover-picture.jpg{{/if}}" title="{{full_name}} Cover Image"/>
|
||||
<button class="button-change-cover js-modal-cover-picture">Change Cover</button>
|
||||
<img id="user-cover" src="{{#if cover}}{{cover}}{{else}}/shared/img/default-user-cover-picture.jpg{{/if}}" title="{{name}} Cover Image"/>
|
||||
<button class="button-change-cover js-modal-cover">Change Cover</button>
|
||||
</figure>
|
||||
</header>
|
||||
<form class="user-details-container" novalidate="novalidate">
|
||||
<fieldset class="user-details-top">
|
||||
<figure class="user-avatar-image">
|
||||
<img id="user-profile-picture" src="{{#if profile_picture}}{{profile_picture}}{{else}}/shared/img/default-user-profile-picture.jpg{{/if}}" title="{{full_name}}"/>
|
||||
<button class="button-change-avatar js-modal-profile-picture">Edit Picture</button>
|
||||
<img id="user-image" src="{{#if image}}{{image}}{{else}}/shared/img/default-user-profile-picture.jpg{{/if}}" title="{{name}}"/>
|
||||
<button class="button-change-avatar js-modal-image">Edit Picture</button>
|
||||
</figure>
|
||||
<label>
|
||||
<input type="url" value="{{full_name}}" id="user-name" placeholder="Joe Bloggs" autocapitalize="off" autocorrect="off">
|
||||
<input type="url" value="{{name}}" id="user-name" placeholder="Joe Bloggs" autocapitalize="off" autocorrect="off">
|
||||
<p>Use your real name so people can recognise you.</p>
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset class="user-details-bottom">
|
||||
<div class="form-group">
|
||||
<label><strong>Email</strong></label>
|
||||
<input type="email" value="{{email_address}}" id="user-email" placeholder="Email Address" autocapitalize="off" autocorrect="off">
|
||||
<input type="email" value="{{email}}" id="user-email" placeholder="Email Address" autocapitalize="off" autocorrect="off">
|
||||
<p>Email will not be publicly displayed. <a class="highlight" href="#" >Learn more</a>.</p>
|
||||
</div>
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label><strong>Website</strong></label>
|
||||
<input type="text" value="{{url}}" id="user-website">
|
||||
<input type="text" value="{{website}}" id="user-website">
|
||||
<p>Have a website or blog other than this one? Link it.</p>
|
||||
</div>
|
||||
|
||||
|
@ -199,14 +199,14 @@
|
||||
},
|
||||
|
||||
savePost: function (data) {
|
||||
// TODO: The content_raw getter here isn't great, shouldn't rely on currentView.
|
||||
// TODO: The markdown getter here isn't great, shouldn't rely on currentView.
|
||||
_.each(this.model.blacklist, function (item) {
|
||||
this.model.unset(item);
|
||||
}, this);
|
||||
|
||||
var saved = this.model.save(_.extend({
|
||||
title: $('#entry-title').val(),
|
||||
content_raw: Ghost.currentView.editor.getValue()
|
||||
markdown: Ghost.currentView.editor.getValue()
|
||||
}, data));
|
||||
|
||||
// TODO: Take this out if #2489 gets merged in Backbone. Or patch Backbone
|
||||
@ -255,7 +255,7 @@
|
||||
this.addSubview(new PublishBar({el: "#publish-bar", model: this.model})).render();
|
||||
|
||||
this.$('#entry-title').val(this.model.get('title'));
|
||||
this.$('#entry-markdown').html(this.model.get('content_raw'));
|
||||
this.$('#entry-markdown').html(this.model.get('markdown'));
|
||||
|
||||
this.initMarkdown();
|
||||
this.renderPreview();
|
||||
|
@ -248,17 +248,17 @@
|
||||
events: {
|
||||
'click .button-save': 'saveUser',
|
||||
'click .button-change-password': 'changePassword',
|
||||
'click .js-modal-cover-picture': 'showCoverPicture',
|
||||
'click .js-modal-profile-picture': 'showProfilePicture'
|
||||
'click .js-modal-cover': 'showCover',
|
||||
'click .js-modal-image': 'showImage'
|
||||
},
|
||||
showCoverPicture: function () {
|
||||
showCover: function () {
|
||||
var user = this.model.toJSON();
|
||||
this.showUpload('#user-cover-picture', 'cover_picture', user.cover_picture);
|
||||
this.showUpload('#user-cover', 'cover', user.cover);
|
||||
},
|
||||
showProfilePicture: function (e) {
|
||||
showImage: function (e) {
|
||||
e.preventDefault();
|
||||
var user = this.model.toJSON();
|
||||
this.showUpload('#user-profile-picture', 'profile_picture', user.profile_picture);
|
||||
this.showUpload('#user-image', 'image', user.image);
|
||||
},
|
||||
showUpload: function (id, key, src) {
|
||||
var self = this, upload = new Ghost.Models.uploadModal({'id': id, 'key': key, 'src': src, 'accept': {
|
||||
@ -314,13 +314,13 @@
|
||||
} else {
|
||||
|
||||
this.model.save({
|
||||
'full_name': userName,
|
||||
'email_address': userEmail,
|
||||
'name': userName,
|
||||
'email': userEmail,
|
||||
'location': userLocation,
|
||||
'url': userWebsite,
|
||||
'website': userWebsite,
|
||||
'bio': userBio,
|
||||
'profile_picture': this.$('#user-profile-picture').attr('src'),
|
||||
'cover_picture': this.$('#user-cover-picture').attr('src')
|
||||
'image': this.$('#user-image').attr('src'),
|
||||
'cover': this.$('#user-cover').attr('src')
|
||||
}, {
|
||||
success: this.saveSuccess,
|
||||
error: this.saveError
|
||||
|
@ -118,8 +118,8 @@ function ghostLocals(req, res, next) {
|
||||
availableThemes: ghost.paths().availableThemes,
|
||||
availablePlugins: ghost.paths().availablePlugins,
|
||||
currentUser: {
|
||||
name: currentUser.attributes.full_name,
|
||||
profile: currentUser.attributes.profile_picture
|
||||
name: currentUser.attributes.name,
|
||||
profile: currentUser.attributes.image
|
||||
}
|
||||
});
|
||||
next();
|
||||
|
@ -167,8 +167,8 @@ adminControllers = {
|
||||
password = req.body.password;
|
||||
|
||||
api.users.add({
|
||||
full_name: name,
|
||||
email_address: email,
|
||||
name: name,
|
||||
email: email,
|
||||
password: password
|
||||
}).then(function (user) {
|
||||
|
||||
|
@ -6,15 +6,15 @@ module.exports = {
|
||||
"uuid": uuid.v4(),
|
||||
"title": "Welcome to Ghost",
|
||||
"slug": "welcome-to-ghost",
|
||||
"content_raw": "This short guide will teach you how to get Ghost up and running on your computer. It doesn't cover deploying it to a live server, just getting it running on your machine so that you can use it, and develop on top of it.\n\n## Setup Instructions\n\n### Compatibility Notes\n\nGhost uses SQLite which must be built natively on the operating system you intend to run Ghost on. We are working to improve this process, but in the meantime the following OS compatibility notes apply:\n\n* **Linux** - Ghost should install and run with no problems\n* **Mac** - you may require Xcode (free) and the CLI Tools which can be installed from Xcode to get Ghost installed\n* **Windows** - Ghost will and does install and run (really well actually) on Windows, but there are a set of pre-requisites which are tricky to install. Detailed instructions for this are coming very soon.\n\n### Pre-requisites\n\nGhost requires [node][1] 0.10.* or 0.11.* and npm. Download and install from [nodejs.org][1]\n\n### Installing\n\n1. Once you've downloaded one of the release packages, unzip it, and place the directory wherever you would like to run the code\n2. Fire up a terminal (or node command prompt in Windows) and change directory to the root of the Ghost application (where config.js and index.js are)\n3. run `npm install` to install the node dependencies (if you get errors to do with SQLite, please see the compatibility notes)\n4. To start ghost, run `npm start`\n5. Visit [http://localhost:2368/](http://localhost:2368/) in your web browser\n\n## Logging in For The First Time\n\nOnce you have the Ghost server up and running, you should be able to navigate to [http://localhost:2368/ghost](http://localhost:2368/ghost) from a web browser, where you will be prompted for a login.\n\n1. Click on the \"register new user\" link\n2. Enter your user details (careful here: There is no password reset yet!)\n3. Return to the login screen and use those details to log in.\n\n## Finding Your Way Around Ghost\n\nYou should now be logged in and up and running with the very first, very earliest, most historically significant, most prototypal version of the Ghost blogging platform. Click around the dashboard. You will find that most things work, but many things do not. We're still working on those. Keep downloading the new packages as we release them, and you should hopefully see big changes between each version as we go!\n\n [1]: http://nodejs.org/",
|
||||
"content": "<p>This short guide will teach you how to get Ghost up and running on your computer. It doesn't cover deploying it to a live server, just getting it running on your machine so that you can use it, and develop on top of it.</p>\n\n<h2 id=\"setupinstructions\">Setup Instructions</h2>\n\n<h3 id=\"compatibilitynotes\">Compatibility Notes</h3>\n\n<p>Ghost uses SQLite which must be built natively on the operating system you intend to run Ghost on. We are working to improve this process, but in the meantime the following OS compatibility notes apply:</p>\n\n<ul>\n<li><strong>Linux</strong> - Ghost should install and run with no problems</li>\n<li><strong>Mac</strong> - you may require Xcode (free) and the CLI Tools which can be installed from Xcode to get Ghost installed</li>\n<li><strong>Windows</strong> - Ghost will and does install and run (really well actually) on Windows, but there are a set of pre-requisites which are tricky to install. Detailed instructions for this are coming very soon.</li>\n</ul>\n\n<h3 id=\"prerequisites\">Pre-requisites</h3>\n\n<p>Ghost requires <a href=\"http://nodejs.org/\">node</a> 0.10.* or 0.11.* and npm. Download and install from <a href=\"http://nodejs.org/\">nodejs.org</a></p>\n\n<h3 id=\"installing\">Installing</h3>\n\n<ol>\n<li>Once you've downloaded one of the release packages, unzip it, and place the directory wherever you would like to run the code</li>\n<li>Fire up a terminal (or node command prompt in Windows) and change directory to the root of the Ghost application (where config.js and index.js are)</li>\n<li>run <code>npm install</code> to install the node dependencies (if you get errors to do with SQLite, please see the compatibility notes)</li>\n<li>To start ghost, run <code>npm start</code></li>\n<li>Visit <a href=\"http://localhost:2368/\">http://localhost:2368/</a> in your web browser</li>\n</ol>\n\n<h2 id=\"logginginforthefirsttime\">Logging in For The First Time</h2>\n\n<p>Once you have the Ghost server up and running, you should be able to navigate to <a href=\"http://localhost:2368/ghost\">http://localhost:2368/ghost</a> from a web browser, where you will be prompted for a login.</p>\n\n<ol>\n<li>Click on the \"register new user\" link</li>\n<li>Enter your user details (careful here: There is no password reset yet!)</li>\n<li>Return to the login screen and use those details to log in.</li>\n</ol>\n\n<h2 id=\"findingyourwayaroundghost\">Finding Your Way Around Ghost</h2>\n\n<p>You should now be logged in and up and running with the very first, very earliest, most historically significant, most prototypal version of the Ghost blogging platform. Click around the dashboard. You will find that most things work, but many things do not. We're still working on those. Keep downloading the new packages as we release them, and you should hopefully see big changes between each version as we go!</p>",
|
||||
"markdown": "This short guide will teach you how to get Ghost up and running on your computer. It doesn't cover deploying it to a live server, just getting it running on your machine so that you can use it, and develop on top of it.\n\n## Setup Instructions\n\n### Compatibility Notes\n\nGhost uses SQLite which must be built natively on the operating system you intend to run Ghost on. We are working to improve this process, but in the meantime the following OS compatibility notes apply:\n\n* **Linux** - Ghost should install and run with no problems\n* **Mac** - you may require Xcode (free) and the CLI Tools which can be installed from Xcode to get Ghost installed\n* **Windows** - Ghost will and does install and run (really well actually) on Windows, but there are a set of pre-requisites which are tricky to install. Detailed instructions for this are coming very soon.\n\n### Pre-requisites\n\nGhost requires [node][1] 0.10.* or 0.11.* and npm. Download and install from [nodejs.org][1]\n\n### Installing\n\n1. Once you've downloaded one of the release packages, unzip it, and place the directory wherever you would like to run the code\n2. Fire up a terminal (or node command prompt in Windows) and change directory to the root of the Ghost application (where config.js and index.js are)\n3. run `npm install` to install the node dependencies (if you get errors to do with SQLite, please see the compatibility notes)\n4. To start ghost, run `npm start`\n5. Visit [http://localhost:2368/](http://localhost:2368/) in your web browser\n\n## Logging in For The First Time\n\nOnce you have the Ghost server up and running, you should be able to navigate to [http://localhost:2368/ghost](http://localhost:2368/ghost) from a web browser, where you will be prompted for a login.\n\n1. Click on the \"register new user\" link\n2. Enter your user details (careful here: There is no password reset yet!)\n3. Return to the login screen and use those details to log in.\n\n## Finding Your Way Around Ghost\n\nYou should now be logged in and up and running with the very first, very earliest, most historically significant, most prototypal version of the Ghost blogging platform. Click around the dashboard. You will find that most things work, but many things do not. We're still working on those. Keep downloading the new packages as we release them, and you should hopefully see big changes between each version as we go!\n\n [1]: http://nodejs.org/",
|
||||
"html": "<p>This short guide will teach you how to get Ghost up and running on your computer. It doesn't cover deploying it to a live server, just getting it running on your machine so that you can use it, and develop on top of it.</p>\n\n<h2 id=\"setupinstructions\">Setup Instructions</h2>\n\n<h3 id=\"compatibilitynotes\">Compatibility Notes</h3>\n\n<p>Ghost uses SQLite which must be built natively on the operating system you intend to run Ghost on. We are working to improve this process, but in the meantime the following OS compatibility notes apply:</p>\n\n<ul>\n<li><strong>Linux</strong> - Ghost should install and run with no problems</li>\n<li><strong>Mac</strong> - you may require Xcode (free) and the CLI Tools which can be installed from Xcode to get Ghost installed</li>\n<li><strong>Windows</strong> - Ghost will and does install and run (really well actually) on Windows, but there are a set of pre-requisites which are tricky to install. Detailed instructions for this are coming very soon.</li>\n</ul>\n\n<h3 id=\"prerequisites\">Pre-requisites</h3>\n\n<p>Ghost requires <a href=\"http://nodejs.org/\">node</a> 0.10.* or 0.11.* and npm. Download and install from <a href=\"http://nodejs.org/\">nodejs.org</a></p>\n\n<h3 id=\"installing\">Installing</h3>\n\n<ol>\n<li>Once you've downloaded one of the release packages, unzip it, and place the directory wherever you would like to run the code</li>\n<li>Fire up a terminal (or node command prompt in Windows) and change directory to the root of the Ghost application (where config.js and index.js are)</li>\n<li>run <code>npm install</code> to install the node dependencies (if you get errors to do with SQLite, please see the compatibility notes)</li>\n<li>To start ghost, run <code>npm start</code></li>\n<li>Visit <a href=\"http://localhost:2368/\">http://localhost:2368/</a> in your web browser</li>\n</ol>\n\n<h2 id=\"logginginforthefirsttime\">Logging in For The First Time</h2>\n\n<p>Once you have the Ghost server up and running, you should be able to navigate to <a href=\"http://localhost:2368/ghost\">http://localhost:2368/ghost</a> from a web browser, where you will be prompted for a login.</p>\n\n<ol>\n<li>Click on the \"register new user\" link</li>\n<li>Enter your user details (careful here: There is no password reset yet!)</li>\n<li>Return to the login screen and use those details to log in.</li>\n</ol>\n\n<h2 id=\"findingyourwayaroundghost\">Finding Your Way Around Ghost</h2>\n\n<p>You should now be logged in and up and running with the very first, very earliest, most historically significant, most prototypal version of the Ghost blogging platform. Click around the dashboard. You will find that most things work, but many things do not. We're still working on those. Keep downloading the new packages as we release them, and you should hopefully see big changes between each version as we go!</p>",
|
||||
"image": null,
|
||||
"featured": false,
|
||||
"page": false,
|
||||
"status": "published",
|
||||
"language": "en_US",
|
||||
"meta_title": null,
|
||||
"meta_description": null,
|
||||
"meta_keywords": null,
|
||||
"featured": true,
|
||||
"image": null,
|
||||
"status": "published",
|
||||
"language": "en",
|
||||
"author_id": 1,
|
||||
"created_at": 1373578890610,
|
||||
"created_by": 1,
|
||||
|
@ -95,6 +95,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
migrateDownFromVersion: function (version) {
|
||||
console.log('version', version);
|
||||
var versions = [],
|
||||
minVersion = this.getVersionBefore(initialVersion),
|
||||
currVersion = version,
|
||||
|
@ -44,10 +44,10 @@ coreHelpers = function (ghost) {
|
||||
});
|
||||
|
||||
// ### Page URL Helper
|
||||
//
|
||||
//
|
||||
// *Usage example:*
|
||||
// `{{pageUrl 2}}`
|
||||
//
|
||||
//
|
||||
// Returns the URL for the page specified in the current object
|
||||
// context.
|
||||
//
|
||||
@ -87,7 +87,7 @@ coreHelpers = function (ghost) {
|
||||
// if the author could not be determined.
|
||||
//
|
||||
ghost.registerThemeHelper('author', function (context, options) {
|
||||
return this.author ? this.author.full_name : "";
|
||||
return this.author ? this.author.name : "";
|
||||
});
|
||||
|
||||
// ### Tags Helper
|
||||
@ -133,11 +133,11 @@ coreHelpers = function (ghost) {
|
||||
|
||||
if (truncateOptions.words || truncateOptions.characters) {
|
||||
return new hbs.handlebars.SafeString(
|
||||
downsize(this.content, truncateOptions)
|
||||
downsize(this.html, truncateOptions)
|
||||
);
|
||||
}
|
||||
|
||||
return new hbs.handlebars.SafeString(this.content);
|
||||
return new hbs.handlebars.SafeString(this.html);
|
||||
});
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ coreHelpers = function (ghost) {
|
||||
truncateOptions = _.pick(truncateOptions, ["words", "characters"]);
|
||||
|
||||
/*jslint regexp:true */
|
||||
excerpt = String(this.content).replace(/<\/?[^>]+>/gi, "");
|
||||
excerpt = String(this.html).replace(/<\/?[^>]+>/gi, "");
|
||||
/*jslint regexp:false */
|
||||
|
||||
if (!truncateOptions.words && !truncateOptions.characters) {
|
||||
|
@ -16,7 +16,7 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
isPost: function (jsonData) {
|
||||
return jsonData.hasOwnProperty("content") && jsonData.hasOwnProperty("content_raw")
|
||||
return jsonData.hasOwnProperty("html") && jsonData.hasOwnProperty("markdown")
|
||||
&& jsonData.hasOwnProperty("title") && jsonData.hasOwnProperty("slug");
|
||||
}
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ casper.test.begin("Ghost editor is correct", 10, function suite(test) {
|
||||
|
||||
casper.then(function createTestPost() {
|
||||
casper.sendKeys('#entry-title', testPost.title);
|
||||
casper.writeContentToCodeMirror(testPost.content);
|
||||
casper.writeContentToCodeMirror(testPost.html);
|
||||
});
|
||||
|
||||
// We must wait after sending keys to CodeMirror
|
||||
@ -50,7 +50,7 @@ casper.test.begin("Ghost editor is correct", 10, function suite(test) {
|
||||
}, testPost.title, 'Title is correct');
|
||||
|
||||
// TODO: make this work - spaces & newlines are problematic
|
||||
// test.assertTextExists(testPost.content, 'Post content exists');
|
||||
// test.assertTextExists(testPost.html, 'Post html exists');
|
||||
});
|
||||
|
||||
casper.run(function () {
|
||||
@ -149,7 +149,7 @@ casper.test.begin('Title Trimming', function suite(test) {
|
||||
test.assertEvalEquals(function () {
|
||||
|
||||
return $('#entry-title').val();
|
||||
|
||||
|
||||
}, trimmedTitle, 'Entry title should match expected value.');
|
||||
});
|
||||
|
||||
|
@ -42,7 +42,7 @@ var host = casper.cli.options.host || 'localhost',
|
||||
},
|
||||
testPost = {
|
||||
title: "Bacon ipsum dolor sit amet",
|
||||
content: "I am a test post.\n#I have some small content"
|
||||
html: "I am a test post.\n#I have some small content"
|
||||
};
|
||||
|
||||
casper.writeContentToCodeMirror = function (content) {
|
||||
|
@ -14,8 +14,8 @@ describe('Post Model', function () {
|
||||
UserModel = Models.User,
|
||||
userData = {
|
||||
password: 'testpass1',
|
||||
email_address: "test@test1.com",
|
||||
full_name: "Mr Biscuits"
|
||||
email: "test@test1.com",
|
||||
name: "Mr Biscuits"
|
||||
};
|
||||
|
||||
before(function (done) {
|
||||
@ -81,8 +81,8 @@ describe('Post Model', function () {
|
||||
|
||||
firstPost.author.should.be.a("object");
|
||||
firstPost.user.should.be.a("object");
|
||||
firstPost.author.full_name.should.equal("Mr Biscuits");
|
||||
firstPost.user.full_name.should.equal("Mr Biscuits");
|
||||
firstPost.author.name.should.equal("Mr Biscuits");
|
||||
firstPost.user.name.should.equal("Mr Biscuits");
|
||||
|
||||
done();
|
||||
}, done);
|
||||
@ -97,8 +97,8 @@ describe('Post Model', function () {
|
||||
|
||||
firstPost.author.should.be.a("object");
|
||||
firstPost.user.should.be.a("object");
|
||||
firstPost.author.full_name.should.equal("Mr Biscuits");
|
||||
firstPost.user.full_name.should.equal("Mr Biscuits");
|
||||
firstPost.author.name.should.equal("Mr Biscuits");
|
||||
firstPost.user.name.should.equal("Mr Biscuits");
|
||||
|
||||
done();
|
||||
}, done);
|
||||
@ -125,7 +125,7 @@ describe('Post Model', function () {
|
||||
var createdPostUpdatedDate,
|
||||
newPost = {
|
||||
title: 'Test Title 1',
|
||||
content_raw: 'Test Content 1'
|
||||
markdown: 'Test Content 1'
|
||||
};
|
||||
|
||||
PostModel.add(newPost).then(function (createdPost) {
|
||||
@ -135,9 +135,9 @@ 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('content_raw').should.equal(newPost.content_raw, "content_raw is correct");
|
||||
createdPost.has('content').should.equal(true);
|
||||
createdPost.get('content').should.equal('<p>' + newPost.content_raw + '</p>');
|
||||
createdPost.get('markdown').should.equal(newPost.markdown, "markdown is correct");
|
||||
createdPost.has('html').should.equal(true);
|
||||
createdPost.get('html').should.equal('<p>' + newPost.markdown + '</p>');
|
||||
createdPost.get('slug').should.equal('test-title-1');
|
||||
createdPost.get('created_at').should.be.below(new Date().getTime()).and.be.above(new Date(0).getTime());
|
||||
createdPost.get('created_by').should.equal(1);
|
||||
@ -169,7 +169,7 @@ describe('Post Model', function () {
|
||||
untrimmedUpdateTitle = ' test trimmed update title ',
|
||||
newPost = {
|
||||
title: untrimmedCreateTitle,
|
||||
content_raw: 'Test Content'
|
||||
markdown: 'Test Content'
|
||||
};
|
||||
|
||||
PostModel.add(newPost).then(function (createdPost) {
|
||||
@ -189,7 +189,7 @@ describe('Post Model', function () {
|
||||
it('can generate a non conflicting slug', function (done) {
|
||||
var newPost = {
|
||||
title: 'Test Title',
|
||||
content_raw: 'Test Content 1'
|
||||
markdown: 'Test Content 1'
|
||||
};
|
||||
|
||||
this.timeout(5000); // this is a patch to ensure it doesn't timeout.
|
||||
@ -199,7 +199,7 @@ describe('Post Model', function () {
|
||||
return function () {
|
||||
return PostModel.add({
|
||||
title: "Test Title",
|
||||
content_raw: "Test Content " + (i+1)
|
||||
markdown: "Test Content " + (i+1)
|
||||
});
|
||||
};
|
||||
})).then(function (createdPosts) {
|
||||
@ -217,7 +217,7 @@ describe('Post Model', function () {
|
||||
}
|
||||
|
||||
post.get('slug').should.equal('test-title-' + num);
|
||||
post.get('content_raw').should.equal('Test Content ' + num);
|
||||
post.get('markdown').should.equal('Test Content ' + num);
|
||||
});
|
||||
|
||||
done();
|
||||
@ -228,7 +228,7 @@ describe('Post Model', function () {
|
||||
it('can generate slugs without duplicate hyphens', function (done) {
|
||||
var newPost = {
|
||||
title: 'apprehensive titles have too many spaces ',
|
||||
content_raw: 'Test Content 1'
|
||||
markdown: 'Test Content 1'
|
||||
};
|
||||
|
||||
PostModel.add(newPost).then(function (createdPost) {
|
||||
|
@ -37,7 +37,7 @@ describe('Tag Model', function () {
|
||||
var PostModel = Models.Post;
|
||||
|
||||
it('can add a tag', function (done) {
|
||||
var newPost = {title: 'Test Title 1', content_raw: 'Test Content 1'},
|
||||
var newPost = {title: 'Test Title 1', markdown: 'Test Content 1'},
|
||||
newTag = {name: 'tag1'},
|
||||
createdPostID;
|
||||
|
||||
@ -63,7 +63,7 @@ describe('Tag Model', function () {
|
||||
// The majority of this test is ripped from above, which is obviously a Bad Thing.
|
||||
// Would be nice to find a way to seed data with relations for cases like this,
|
||||
// because there are more DB hits than needed
|
||||
var newPost = {title: 'Test Title 1', content_raw: 'Test Content 1'},
|
||||
var newPost = {title: 'Test Title 1', markdown: 'Test Content 1'},
|
||||
newTag = {name: 'tag1'},
|
||||
createdTagID,
|
||||
createdPostID;
|
||||
@ -97,7 +97,7 @@ describe('Tag Model', function () {
|
||||
|
||||
function seedTags(tagNames) {
|
||||
var createOperations = [
|
||||
PostModel.add({title: 'title', content_raw: 'content'})
|
||||
PostModel.add({title: 'title', markdown: 'content'})
|
||||
];
|
||||
|
||||
var tagModels = tagNames.map(function (tagName) { return TagModel.add({name: tagName}); });
|
||||
@ -210,7 +210,7 @@ describe('Tag Model', function () {
|
||||
|
||||
|
||||
it('can add a tag to a post on creation', function (done) {
|
||||
var newPost = {title: 'Test Title 1', content_raw: 'Test Content 1', tags: ['test_tag_1']};
|
||||
var newPost = {title: 'Test Title 1', markdown: 'Test Content 1', tags: ['test_tag_1']};
|
||||
|
||||
PostModel.add(newPost).then(function (createdPost) {
|
||||
return PostModel.read({id: createdPost.id}, { withRelated: ['tags']});
|
||||
|
@ -35,14 +35,14 @@ describe('User Model', function run() {
|
||||
it('can add first', function (done) {
|
||||
var userData = {
|
||||
password: 'testpass1',
|
||||
email_address: "test@test1.com"
|
||||
email: "test@test1.com"
|
||||
};
|
||||
|
||||
UserModel.add(userData).then(function (createdUser) {
|
||||
should.exist(createdUser);
|
||||
createdUser.has('uuid').should.equal(true);
|
||||
createdUser.attributes.password.should.not.equal(userData.password, "password was hashed");
|
||||
createdUser.attributes.email_address.should.eql(userData.email_address, "email address correct");
|
||||
createdUser.attributes.email.should.eql(userData.email, "email address correct");
|
||||
|
||||
done();
|
||||
}).then(null, done);
|
||||
@ -65,7 +65,7 @@ describe('User Model', function run() {
|
||||
it('can\'t add second', function (done) {
|
||||
var userData = {
|
||||
password: 'testpass3',
|
||||
email_address: "test3@test1.com"
|
||||
email: "test3@test1.com"
|
||||
};
|
||||
|
||||
return testUtils.insertDefaultUser().then(function () {
|
||||
@ -99,13 +99,13 @@ describe('User Model', function run() {
|
||||
|
||||
firstUser = results.models[0];
|
||||
|
||||
return UserModel.read({email_address: firstUser.attributes.email_address});
|
||||
return UserModel.read({email: firstUser.attributes.email});
|
||||
|
||||
}).then(function (found) {
|
||||
|
||||
should.exist(found);
|
||||
|
||||
found.attributes.full_name.should.equal(firstUser.attributes.full_name);
|
||||
found.attributes.name.should.equal(firstUser.attributes.name);
|
||||
|
||||
done();
|
||||
|
||||
@ -124,13 +124,13 @@ describe('User Model', function run() {
|
||||
|
||||
firstUser = results.models[0];
|
||||
|
||||
return UserModel.edit({id: firstUser.id, url: "some.newurl.com"});
|
||||
return UserModel.edit({id: firstUser.id, website: "some.newurl.com"});
|
||||
|
||||
}).then(function (edited) {
|
||||
|
||||
should.exist(edited);
|
||||
|
||||
edited.attributes.url.should.equal('some.newurl.com');
|
||||
edited.attributes.website.should.equal('some.newurl.com');
|
||||
|
||||
done();
|
||||
|
||||
|
@ -51,15 +51,15 @@ describe('permissions', function () {
|
||||
],
|
||||
currTestPermId = 1,
|
||||
// currTestUserId = 1,
|
||||
// createTestUser = function (email_address) {
|
||||
// if (!email_address) {
|
||||
// createTestUser = function (email) {
|
||||
// if (!email) {
|
||||
// currTestUserId += 1;
|
||||
// email_address = "test" + currTestPermId + "@test.com";
|
||||
// email = "test" + currTestPermId + "@test.com";
|
||||
// }
|
||||
|
||||
// var newUser = {
|
||||
// id: currTestUserId,
|
||||
// email_address: email_address,
|
||||
// email: email,
|
||||
// password: "testing123"
|
||||
// };
|
||||
|
||||
|
@ -28,19 +28,19 @@ describe('Core Helpers', function () {
|
||||
});
|
||||
|
||||
it('can render content', function () {
|
||||
var content = "Hello World",
|
||||
rendered = handlebars.helpers.content.call({content: content});
|
||||
var html = "Hello World",
|
||||
rendered = handlebars.helpers.content.call({html: html});
|
||||
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal(content);
|
||||
rendered.string.should.equal(html);
|
||||
});
|
||||
|
||||
it('can truncate content by word', function () {
|
||||
var content = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
it('can truncate html by word', function () {
|
||||
var html = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
rendered = (
|
||||
handlebars.helpers.content
|
||||
.call(
|
||||
{content: content},
|
||||
{html: html},
|
||||
{"hash":{"words": 2}}
|
||||
)
|
||||
);
|
||||
@ -49,12 +49,12 @@ describe('Core Helpers', function () {
|
||||
rendered.string.should.equal("<p>Hello <strong>World</strong></p>");
|
||||
});
|
||||
|
||||
it('can truncate content by character', function () {
|
||||
var content = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
it('can truncate html by character', function () {
|
||||
var html = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
rendered = (
|
||||
handlebars.helpers.content
|
||||
.call(
|
||||
{content: content},
|
||||
{html: html},
|
||||
{"hash":{"characters": 8}}
|
||||
)
|
||||
);
|
||||
@ -71,15 +71,15 @@ describe('Core Helpers', function () {
|
||||
});
|
||||
|
||||
it("Returns the full name of the author from the context",function() {
|
||||
var content = {"author":{"full_name":"abc123"}},
|
||||
result = handlebars.helpers.author.call(content);
|
||||
var data = {"author":{"name":"abc123"}},
|
||||
result = handlebars.helpers.author.call(data);
|
||||
|
||||
String(result).should.equal("abc123");
|
||||
});
|
||||
|
||||
it("Returns a blank string where author data is missing",function() {
|
||||
var content = {"author":null},
|
||||
result = handlebars.helpers.author.call(content);
|
||||
var data = {"author": null},
|
||||
result = handlebars.helpers.author.call(data);
|
||||
|
||||
String(result).should.equal("");
|
||||
});
|
||||
@ -93,33 +93,33 @@ describe('Core Helpers', function () {
|
||||
});
|
||||
|
||||
it('can render excerpt', function () {
|
||||
var content = "Hello World",
|
||||
rendered = handlebars.helpers.excerpt.call({content: content});
|
||||
var html = "Hello World",
|
||||
rendered = handlebars.helpers.excerpt.call({html: html});
|
||||
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal(content);
|
||||
rendered.string.should.equal(html);
|
||||
});
|
||||
|
||||
it('does not output HTML', function () {
|
||||
var content = '<p>There are <br />10<br> types<br/> of people in <img src="a">the world:'
|
||||
var html = '<p>There are <br />10<br> types<br/> of people in <img src="a">the world:'
|
||||
+ '<img src=b alt=\"c\"> those who <img src="@" onclick="javascript:alert(\'hello\');">'
|
||||
+ "understand trinary</p>, those who don't <div style='' class=~/'-,._?!|#>and"
|
||||
+ "< test > those<<< test >>> who mistake it <for> binary.",
|
||||
expected = "There are 10 types of people in the world: those who understand trinary, those who don't "
|
||||
+ "and those>> who mistake it <for> binary.",
|
||||
rendered = handlebars.helpers.excerpt.call({content: content});
|
||||
rendered = handlebars.helpers.excerpt.call({html: html});
|
||||
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal(expected);
|
||||
|
||||
});
|
||||
|
||||
it('can truncate content by word', function () {
|
||||
var content = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
it('can truncate html by word', function () {
|
||||
var html = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
expected = "Hello World",
|
||||
rendered = (
|
||||
handlebars.helpers.excerpt.call(
|
||||
{content: content},
|
||||
{html: html},
|
||||
{"hash": {"words": 2}}
|
||||
)
|
||||
);
|
||||
@ -128,12 +128,12 @@ describe('Core Helpers', function () {
|
||||
rendered.string.should.equal(expected);
|
||||
});
|
||||
|
||||
it('can truncate content by character', function () {
|
||||
var content = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
it('can truncate html by character', function () {
|
||||
var html = "<p>Hello <strong>World! It's me!</strong></p>",
|
||||
expected = "Hello Wo",
|
||||
rendered = (
|
||||
handlebars.helpers.excerpt.call(
|
||||
{content: content},
|
||||
{html: html},
|
||||
{"hash": {"characters": 8}}
|
||||
)
|
||||
);
|
||||
@ -213,7 +213,7 @@ describe('Core Helpers', function () {
|
||||
});
|
||||
|
||||
it('should return a the slug with a prefix slash if the context is a post', function () {
|
||||
var rendered = handlebars.helpers.url.call({content: 'content', content_raw: "ff", title: "title", slug: "slug"});
|
||||
var rendered = handlebars.helpers.url.call({html: 'content', markdown: "ff", title: "title", slug: "slug"});
|
||||
should.exist(rendered);
|
||||
rendered.should.equal('/slug');
|
||||
});
|
||||
@ -224,7 +224,7 @@ describe('Core Helpers', function () {
|
||||
}),
|
||||
|
||||
rendered = handlebars.helpers.url.call(
|
||||
{content: 'content', content_raw: "ff", title: "title", slug: "slug"},
|
||||
{html: 'content', markdown: "ff", title: "title", slug: "slug"},
|
||||
{hash: { absolute: 'true'}}
|
||||
);
|
||||
|
||||
@ -235,10 +235,10 @@ describe('Core Helpers', function () {
|
||||
});
|
||||
|
||||
it('should return empty string if not a post', function () {
|
||||
handlebars.helpers.url.call({content_raw: "ff", title: "title", slug: "slug"}).should.equal('');
|
||||
handlebars.helpers.url.call({content: 'content', title: "title", slug: "slug"}).should.equal('');
|
||||
handlebars.helpers.url.call({content: 'content', content_raw: "ff", slug: "slug"}).should.equal('');
|
||||
handlebars.helpers.url.call({content: 'content', content_raw: "ff", title: "title"}).should.equal('');
|
||||
handlebars.helpers.url.call({markdown: "ff", title: "title", slug: "slug"}).should.equal('');
|
||||
handlebars.helpers.url.call({html: 'content', title: "title", slug: "slug"}).should.equal('');
|
||||
handlebars.helpers.url.call({html: 'content', markdown: "ff", slug: "slug"}).should.equal('');
|
||||
handlebars.helpers.url.call({html: 'content', markdown: "ff", title: "title"}).should.equal('');
|
||||
});
|
||||
});
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user