Merge pull request #879 from JohnONolan/cleanup

This commit is contained in:
Hannah Wolfe 2013-09-26 15:14:29 +01:00
commit 3098e9577b
42 changed files with 506 additions and 506 deletions

View File

@ -1,13 +1,13 @@
var path = require('path'),
when = require('when'),
semver = require("semver"),
fs = require("fs"),
path = require("path"),
_ = require('underscore'),
spawn = require("child_process").spawn,
var path = require('path'),
when = require('when'),
semver = require('semver'),
fs = require('fs'),
path = require('path'),
_ = require('underscore'),
spawn = require("child_process").spawn,
buildDirectory = path.resolve(process.cwd(), '.build'),
distDirectory = path.resolve(process.cwd(), '.dist'),
configLoader = require('./core/config-loader.js'),
distDirectory = path.resolve(process.cwd(), '.dist'),
configLoader = require('./core/config-loader.js'),
buildGlob = [
'**',
@ -94,7 +94,7 @@ var path = require('path'),
// Start our server in development
express: {
options: {
script: "index.js"
script: 'index.js'
},
dev: {
@ -136,9 +136,9 @@ var path = require('path'),
},
files: {
src: [
"*.js",
"core/*.js",
"core/server/**/*.js"
'*.js',
'core/*.js',
'core/server/**/*.js'
]
}
},
@ -156,11 +156,11 @@ var path = require('path'),
unparam: true
},
files: {
src: "core/client/**/*.js"
src: 'core/client/**/*.js'
},
exclude: [
"core/client/assets/**/*.js",
"core/client/tpl/**/*.js"
'core/client/assets/**/*.js',
'core/client/tpl/**/*.js'
]
},
shared: {
@ -180,19 +180,19 @@ var path = require('path'),
},
files: {
src: [
"core/shared/**/*.js"
'core/shared/**/*.js'
]
},
exclude: [
"core/shared/vendor/**/*.js"
'core/shared/vendor/**/*.js'
]
}
},
mochacli: {
options: {
ui: "bdd",
reporter: "spec"
ui: 'bdd',
reporter: 'spec'
},
all: {
@ -245,14 +245,14 @@ var path = require('path'),
handlebars: {
core: {
options: {
namespace: "JST",
namespace: 'JST',
processName: function (filename) {
filename = filename.replace('core/client/tpl/', '');
return filename.replace('.hbs', '');
}
},
files: {
"core/client/tpl/hbs-tpl.js": "core/client/tpl/**/*.hbs"
'core/client/tpl/hbs-tpl.js': 'core/client/tpl/**/*.hbs'
}
}
},
@ -260,19 +260,19 @@ var path = require('path'),
groc: {
docs: {
options: {
"out": "./docs/",
"glob": [
"README.md",
"config.example.js",
"index.js",
"core/*.js",
"core/server/**/*.js",
"core/shared/**/*.js",
"core/client/**/*.js"
'out': './docs/',
'glob': [
'README.md',
'config.example.js',
'index.js',
'core/*.js',
'core/server/**/*.js',
'core/shared/**/*.js',
'core/client/**/*.js'
],
"except": [
"!core/**/vendor/**/*.js",
"!core/client/tpl/**/*.js"
'except': [
'!core/**/vendor/**/*.js',
'!core/client/tpl/**/*.js'
]
}
}
@ -280,7 +280,7 @@ var path = require('path'),
clean: {
build: {
src: ["<%= paths.buildBuild %>/**"]
src: ['<%= paths.buildBuild %>/**']
}
},
@ -289,21 +289,21 @@ var path = require('path'),
files: [{
expand: true,
src: buildGlob,
dest: "<%= paths.nightlyBuild %>/<%= pkg.version %>/"
dest: '<%= paths.nightlyBuild %>/<%= pkg.version %>/'
}]
},
weekly: {
files: [{
expand: true,
src: buildGlob,
dest: "<%= paths.weeklyBuild %>/<%= pkg.version %>/"
dest: '<%= paths.weeklyBuild %>/<%= pkg.version %>/'
}]
},
build: {
files: [{
expand: true,
src: buildGlob,
dest: "<%= paths.buildBuild %>/"
dest: '<%= paths.buildBuild %>/'
}]
}
},
@ -311,27 +311,27 @@ var path = require('path'),
compress: {
nightly: {
options: {
archive: "<%= paths.nightlyDist %>/Ghost-Nightly-<%= pkg.version %>.zip"
archive: '<%= paths.nightlyDist %>/Ghost-Nightly-<%= pkg.version %>.zip'
},
expand: true,
cwd: "<%= paths.nightlyBuild %>/<%= pkg.version %>/",
src: ["**"]
cwd: '<%= paths.nightlyBuild %>/<%= pkg.version %>/',
src: ['**']
},
weekly: {
options: {
archive: "<%= paths.weeklyDist %>/Ghost-Weekly-<%= pkg.version %>.zip"
archive: '<%= paths.weeklyDist %>/Ghost-Weekly-<%= pkg.version %>.zip'
},
expand: true,
cwd: "<%= paths.weeklyBuild %>/<%= pkg.version %>/",
src: ["**"]
cwd: '<%= paths.weeklyBuild %>/<%= pkg.version %>/',
src: ['**']
},
build: {
options: {
archive: "<%= paths.buildDist %>/Ghost-Build.zip"
archive: '<%= paths.buildDist %>/Ghost-Build.zip'
},
expand: true,
cwd: "<%= paths.buildBuild %>/",
src: ["**"]
cwd: '<%= paths.buildBuild %>/',
src: ['**']
}
},
@ -340,113 +340,113 @@ var path = require('path'),
tagName: '%VERSION%',
commitMessage: '<%= buildType %> Release %VERSION%',
tagMessage: '<%= buildType %> Release %VERSION%',
pushTo: "origin build"
pushTo: 'origin build'
}
},
concat: {
dev: {
files: {
"core/built/scripts/vendor.js": [
"core/shared/vendor/jquery/jquery.js",
"core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js",
"core/client/assets/lib/jquery-utils.js",
"core/client/assets/lib/uploader.js",
"core/shared/vendor/underscore.js",
"core/shared/vendor/backbone/backbone.js",
"core/shared/vendor/handlebars/handlebars-runtime.js",
"core/shared/vendor/moment.js",
'core/built/scripts/vendor.js': [
'core/shared/vendor/jquery/jquery.js',
'core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js',
'core/client/assets/lib/jquery-utils.js',
'core/client/assets/lib/uploader.js',
'core/shared/vendor/underscore.js',
'core/shared/vendor/backbone/backbone.js',
'core/shared/vendor/handlebars/handlebars-runtime.js',
'core/shared/vendor/moment.js',
"core/client/assets/vendor/icheck/jquery.icheck.min.js",
'core/client/assets/vendor/icheck/jquery.icheck.min.js',
"core/shared/vendor/jquery/jquery.ui.widget.js",
"core/shared/vendor/jquery/jquery.iframe-transport.js",
"core/shared/vendor/jquery/jquery.fileupload.js",
'core/shared/vendor/jquery/jquery.ui.widget.js',
'core/shared/vendor/jquery/jquery.iframe-transport.js',
'core/shared/vendor/jquery/jquery.fileupload.js',
"core/client/assets/vendor/codemirror/codemirror.js",
"core/client/assets/vendor/codemirror/addon/mode/overlay.js",
"core/client/assets/vendor/codemirror/mode/markdown/markdown.js",
"core/client/assets/vendor/codemirror/mode/gfm/gfm.js",
"core/client/assets/vendor/showdown/showdown.js",
"core/client/assets/vendor/showdown/extensions/ghostdown.js",
"core/shared/vendor/showdown/extensions/github.js",
"core/client/assets/vendor/shortcuts.js",
"core/client/assets/vendor/validator-client.js",
"core/client/assets/vendor/countable.js",
"core/client/assets/vendor/to-title-case.js",
"core/client/assets/vendor/packery.pkgd.min.js",
"core/client/assets/vendor/fastclick.js"
'core/client/assets/vendor/codemirror/codemirror.js',
'core/client/assets/vendor/codemirror/addon/mode/overlay.js',
'core/client/assets/vendor/codemirror/mode/markdown/markdown.js',
'core/client/assets/vendor/codemirror/mode/gfm/gfm.js',
'core/client/assets/vendor/showdown/showdown.js',
'core/client/assets/vendor/showdown/extensions/ghostdown.js',
'core/shared/vendor/showdown/extensions/github.js',
'core/client/assets/vendor/shortcuts.js',
'core/client/assets/vendor/validator-client.js',
'core/client/assets/vendor/countable.js',
'core/client/assets/vendor/to-title-case.js',
'core/client/assets/vendor/packery.pkgd.min.js',
'core/client/assets/vendor/fastclick.js'
],
"core/built/scripts/helpers.js": [
"core/client/init.js",
'core/built/scripts/helpers.js': [
'core/client/init.js',
"core/client/mobile-interactions.js",
"core/client/toggle.js",
"core/client/markdown-actions.js",
"core/client/helpers/index.js"
'core/client/mobile-interactions.js',
'core/client/toggle.js',
'core/client/markdown-actions.js',
'core/client/helpers/index.js'
],
"core/built/scripts/templates.js": [
"core/client/tpl/hbs-tpl.js"
'core/built/scripts/templates.js': [
'core/client/tpl/hbs-tpl.js'
],
"core/built/scripts/models.js": [
"core/client/models/**/*.js"
'core/built/scripts/models.js': [
'core/client/models/**/*.js'
],
"core/built/scripts/views.js": [
"core/client/views/**/*.js",
"core/client/router.js"
'core/built/scripts/views.js': [
'core/client/views/**/*.js',
'core/client/router.js'
]
}
},
prod: {
files: {
"core/built/scripts/ghost.js": [
"core/shared/vendor/jquery/jquery.js",
"core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js",
"core/client/assets/lib/jquery-utils.js",
"core/client/assets/lib/uploader.js",
"core/shared/vendor/underscore.js",
"core/shared/vendor/backbone/backbone.js",
"core/shared/vendor/handlebars/handlebars-runtime.js",
"core/shared/vendor/moment.js",
'core/built/scripts/ghost.js': [
'core/shared/vendor/jquery/jquery.js',
'core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js',
'core/client/assets/lib/jquery-utils.js',
'core/client/assets/lib/uploader.js',
'core/shared/vendor/underscore.js',
'core/shared/vendor/backbone/backbone.js',
'core/shared/vendor/handlebars/handlebars-runtime.js',
'core/shared/vendor/moment.js',
"core/client/assets/vendor/icheck/jquery.icheck.min.js",
'core/client/assets/vendor/icheck/jquery.icheck.min.js',
"core/shared/vendor/jquery/jquery.ui.widget.js",
"core/shared/vendor/jquery/jquery.iframe-transport.js",
"core/shared/vendor/jquery/jquery.fileupload.js",
'core/shared/vendor/jquery/jquery.ui.widget.js',
'core/shared/vendor/jquery/jquery.iframe-transport.js',
'core/shared/vendor/jquery/jquery.fileupload.js',
"core/client/assets/vendor/codemirror/codemirror.js",
"core/client/assets/vendor/codemirror/addon/mode/overlay.js",
"core/client/assets/vendor/codemirror/mode/markdown/markdown.js",
"core/client/assets/vendor/codemirror/mode/gfm/gfm.js",
"core/client/assets/vendor/showdown/showdown.js",
"core/client/assets/vendor/showdown/extensions/ghostdown.js",
"core/shared/vendor/showdown/extensions/github.js",
"core/client/assets/vendor/shortcuts.js",
"core/client/assets/vendor/validator-client.js",
"core/client/assets/vendor/countable.js",
"core/client/assets/vendor/to-title-case.js",
"core/client/assets/vendor/packery.pkgd.min.js",
"core/client/assets/vendor/fastclick.js",
'core/client/assets/vendor/codemirror/codemirror.js',
'core/client/assets/vendor/codemirror/addon/mode/overlay.js',
'core/client/assets/vendor/codemirror/mode/markdown/markdown.js',
'core/client/assets/vendor/codemirror/mode/gfm/gfm.js',
'core/client/assets/vendor/showdown/showdown.js',
'core/client/assets/vendor/showdown/extensions/ghostdown.js',
'core/shared/vendor/showdown/extensions/github.js',
'core/client/assets/vendor/shortcuts.js',
'core/client/assets/vendor/validator-client.js',
'core/client/assets/vendor/countable.js',
'core/client/assets/vendor/to-title-case.js',
'core/client/assets/vendor/packery.pkgd.min.js',
'core/client/assets/vendor/fastclick.js',
"core/client/init.js",
'core/client/init.js',
"core/client/mobile-interactions.js",
"core/client/toggle.js",
"core/client/markdown-actions.js",
"core/client/helpers/index.js",
'core/client/mobile-interactions.js',
'core/client/toggle.js',
'core/client/markdown-actions.js',
'core/client/helpers/index.js',
"core/client/tpl/hbs-tpl.js",
'core/client/tpl/hbs-tpl.js',
"core/client/models/**/*.js",
'core/client/models/**/*.js',
"core/client/views/**/*.js",
'core/client/views/**/*.js',
"core/client/router.js"
'core/client/router.js'
]
}
}
@ -455,7 +455,7 @@ var path = require('path'),
uglify: {
prod: {
files: {
"core/built/scripts/ghost.min.js": "core/built/scripts/ghost.js"
'core/built/scripts/ghost.min.js': 'core/built/scripts/ghost.js'
}
}
}
@ -526,17 +526,17 @@ var path = require('path'),
depth = depth || 0;
if (!depth) {
grunt.log.writeln("git " + args.join(" "));
grunt.log.writeln('git ' + args.join(' '));
}
var buffer = [];
spawn("git", args, {
spawn('git', args, {
// We can reasonably assume the gruntfile will be in the root of the repo.
cwd : __dirname,
stdio : ["ignore", "pipe", process.stderr]
stdio : ['ignore', 'pipe', process.stderr]
}).on("exit", function (code) {
}).on('exit', function (code) {
// Process exited correctly but we got no output.
// Spawn again, but make sure we don't spiral out of control.
@ -552,7 +552,7 @@ var path = require('path'),
}
if (code === 0) {
return callback(buffer.join(""));
return callback(buffer.join(''));
}
// We failed. Git returned a non-standard exit code.
@ -560,7 +560,7 @@ var path = require('path'),
done(false);
// Push returned data into the buffer
}).stdout.on("data", buffer.push.bind(buffer));
}).stdout.on('data', buffer.push.bind(buffer));
}
// Crazy function for getting around inconsistencies in tagging
@ -575,14 +575,14 @@ var path = require('path'),
// into sort directly. Could be something to think about
// in future.
if (semver.rcompare(a, "0.2.0") < 0 ||
semver.rcompare(b, "0.2.0") < 0) {
if (semver.rcompare(a, '0.2.0') < 0 ||
semver.rcompare(b, '0.2.0') < 0) {
return semver.rcompare(a, b);
}
a = a.split("-");
b = b.split("-");
a = a.split('-');
b = b.split('-');
if (semver.rcompare(a[0], b[0]) !== 0) {
return semver.rcompare(a[0], b[0]);
@ -597,7 +597,7 @@ var path = require('path'),
// Gets tags in master branch, sorts them with semver,
function getTags(callback) {
git(["show-ref", "--tags"], function (results) {
git(['show-ref', '--tags'], function (results) {
results = results
.split(/\n+/)
.filter(function (tag) {
@ -605,8 +605,8 @@ var path = require('path'),
})
.map(function (tag) {
return {
"tag": tag.split(/tags\//).pop().trim(),
"ref": tag.split(/\s+/).shift().trim()
'tag': tag.split(/tags\//).pop().trim(),
'ref': tag.split(/\s+/).shift().trim()
};
})
.sort(sortTags);
@ -620,11 +620,11 @@ var path = require('path'),
var commits = [],
commitRegex =
new RegExp(
"\\n*[|\\*\\s]*commit\\s+([a-f0-9]+)" +
"\\n[|\\*\\s]*Author:\\s+([^<\\n]+)<([^>\\n]+)>" +
"\\n[|\\*\\s]*Date:\\s+([^\\n]+)" +
"\\n+[|\\*\\s]*[ ]{4}([^\\n]+)",
"ig"
'\\n*[|\\*\\s]*commit\\s+([a-f0-9]+)' +
'\\n[|\\*\\s]*Author:\\s+([^<\\n]+)<([^>\\n]+)>' +
'\\n[|\\*\\s]*Date:\\s+([^\\n]+)' +
'\\n+[|\\*\\s]*[ ]{4}([^\\n]+)',
'ig'
);
// Using String.prototype.replace as a kind of poor-man's substitute
@ -641,16 +641,16 @@ var path = require('path'),
date =
date.replace(
/^(\w+)\s(\w+)\s(\d+)\s([\d\:]+)\s(\d+)\s([\+\-\d]+)$/,
"$1, $2 $3 $5 $4 $6"
'$1, $2 $3 $5 $4 $6'
);
commits.push({
"hash": hash,
"author": author,
"email": email,
"date": date,
"parsedDate": new Date(Date.parse(date)),
"message": message
'hash': hash,
'author': author,
'email': email,
'date': date,
'parsedDate': new Date(Date.parse(date)),
'message': message
});
return null;
@ -662,8 +662,8 @@ var path = require('path'),
// Gets git log for specified range.
function getLog(to, from, callback) {
var range = from && to ? from + ".." + to : "",
args = [ "log", "master", "--no-color", "--no-merges", "--graph" ];
var range = from && to ? from + '..' + to : '',
args = [ 'log', 'master', '--no-color', '--no-merges', '--graph' ];
if (range) {
args.push(range);
@ -676,12 +676,12 @@ var path = require('path'),
// Run the job
getTags(function (tags) {
var logPath = path.join(__dirname, "CHANGELOG.md"),
var logPath = path.join(__dirname, 'CHANGELOG.md'),
log = fs.createWriteStream(logPath),
commitCache = {};
function processTag(tag, callback) {
var buffer = "",
var buffer = '',
peek = tag[1];
tag = tag[0];
@ -699,7 +699,7 @@ var path = require('path'),
return callback("");
}
buffer += "## Release " + tag.tag + "\n";
buffer += '## Release ' + tag.tag + '\n';
commits = commits
.filter(function (commit) {
@ -707,12 +707,12 @@ var path = require('path'),
// Get rid of jenkins' release tagging commits
// Remove commits we've already spat out
return (
commit.author !== "TryGhost-Jenkins" &&
commit.author !== 'TryGhost-Jenkins' &&
!commitCache[commit.hash]
);
})
.map(function (commit) {
buffer += "\n* " + commit.message + " (_" + commit.author + "_)";
buffer += '\n* ' + commit.message + ' (_' + commit.author + '_)';
commitCache[commit.hash] = true;
});
@ -720,12 +720,12 @@ var path = require('path'),
buffer += "\nNo changes were made in this build.\n";
}
callback(buffer + "\n");
callback(buffer + '\n');
});
}
// Get two weeks' worth of tags
tags.unshift({"tag": "HEAD"});
tags.unshift({'tag': 'HEAD'});
tags =
tags
@ -737,17 +737,17 @@ var path = require('path'),
];
});
log.write("# Ghost Changelog\n\n");
log.write("_Showing " + tags.length + " releases._\n");
log.write('# Ghost Changelog\n\n');
log.write('_Showing ' + tags.length + ' releases._\n');
when.reduce(tags,
function (prev, tag, idx) {
return when.promise(function (resolve) {
processTag(tag, function (releaseData) {
resolve(prev + "\n" + releaseData);
resolve(prev + '\n' + releaseData);
});
});
}, "")
}, '')
.then(function (reducedChangelog) {
log.write(reducedChangelog);
log.close();
@ -765,75 +765,75 @@ var path = require('path'),
* - Zip files in build folder to dist-folder/#{version} directory
*/
grunt.registerTask("nightly", [
"setCurrentBuildType:Nightly",
"shell:bourbon",
"sass:admin",
"handlebars",
"concat",
"uglify",
"bump:build",
"updateCurrentPackageInfo",
"changelog",
"copy:nightly",
"compress:nightly"
'setCurrentBuildType:Nightly',
'shell:bourbon',
'sass:admin',
'handlebars',
'concat',
'uglify',
'bump:build',
'updateCurrentPackageInfo',
'changelog',
'copy:nightly',
'compress:nightly'
]);
grunt.registerTask("weekly", [
"setCurrentBuildType:Weekly",
"shell:bourbon",
"sass:admin",
"handlebars",
"concat",
"uglify",
"bump:build",
"updateCurrentPackageInfo",
"changelog",
"copy:weekly",
"compress:weekly"
'setCurrentBuildType:Weekly',
'shell:bourbon',
'sass:admin',
'handlebars',
'concat',
'uglify',
'bump:build',
'updateCurrentPackageInfo',
'changelog',
'copy:weekly',
'compress:weekly'
]);
grunt.registerTask("build", [
"shell:bourbon",
"sass:admin",
"handlebars",
"concat",
"uglify",
"changelog",
"clean:build",
"copy:build",
"compress:build"
grunt.registerTask('build', [
'shell:bourbon',
'sass:admin',
'handlebars',
'concat',
'uglify',
'changelog',
'clean:build',
'copy:build',
'compress:build'
]);
// Dev Mode; watch files and restart server on changes
grunt.registerTask("dev", [
"default",
"express:dev",
"open",
"watch"
grunt.registerTask('dev', [
'default',
'express:dev',
'open',
'watch'
]);
// Prepare the project for development
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
grunt.registerTask("init", ["shell:bourbon", "default"]);
grunt.registerTask('init', ['shell:bourbon', 'default']);
// Run unit tests
grunt.registerTask("test-unit", ['setTestEnv', 'loadConfig', "mochacli:all"]);
grunt.registerTask('test-unit', ['setTestEnv', 'loadConfig', 'mochacli:all']);
// Run casperjs tests only
grunt.registerTask('test-functional', ['setTestEnv', 'express:test', 'spawn-casperjs']);
// Run tests and lint code
grunt.registerTask("validate", ["jslint", "test-unit", "test-functional"]);
grunt.registerTask('validate', ['jslint', 'test-unit', 'test-functional']);
// Generate Docs
grunt.registerTask("docs", ["groc"]);
grunt.registerTask('docs', ['groc']);
// TODO: Production build task that minifies with uglify:prod
grunt.registerTask("prod", ['sass:admin', 'handlebars', 'concat', "uglify"]);
grunt.registerTask('prod', ['sass:admin', 'handlebars', 'concat', 'uglify']);
// When you just say "grunt"
grunt.registerTask("default", ['sass:admin', 'handlebars', 'concat']);
// When you just say 'grunt'
grunt.registerTask('default', ['sass:admin', 'handlebars', 'concat']);
};
module.exports = configureGrunt;

View File

@ -1,9 +1,9 @@
/*globals Handlebars, moment
*/
(function () {
"use strict";
'use strict';
Handlebars.registerHelper('date', function (context, block) {
var f = block.hash.format || "MMM Do, YYYY",
var f = block.hash.format || 'MMM Do, YYYY',
timeago = block.hash.timeago,
date;
if (timeago) {

View File

@ -1,6 +1,6 @@
/*globals window, $, _, Backbone, Validator */
(function () {
"use strict";
'use strict';
var Ghost = {
Layout : {},

View File

@ -2,7 +2,7 @@
/*global $, window, CodeMirror, Showdown, moment */
(function () {
"use strict";
'use strict';
var Markdown = {
init : function (options, elem) {
var self = this;
@ -17,59 +17,59 @@
replace: function () {
var text = this.elem.getSelection(), pass = true, md, cursor, line, word, letterCount, converter;
switch (this.style) {
case "h1":
case 'h1':
cursor = this.elem.getCursor();
line = this.elem.getLine(cursor.line);
this.elem.setLine(cursor.line, "# " + line);
this.elem.setLine(cursor.line, '# ' + line);
this.elem.setCursor(cursor.line, cursor.ch + 2);
pass = false;
break;
case "h2":
case 'h2':
cursor = this.elem.getCursor();
line = this.elem.getLine(cursor.line);
this.elem.setLine(cursor.line, "## " + line);
this.elem.setLine(cursor.line, '## ' + line);
this.elem.setCursor(cursor.line, cursor.ch + 3);
pass = false;
break;
case "h3":
case 'h3':
cursor = this.elem.getCursor();
line = this.elem.getLine(cursor.line);
this.elem.setLine(cursor.line, "### " + line);
this.elem.setLine(cursor.line, '### ' + line);
this.elem.setCursor(cursor.line, cursor.ch + 4);
pass = false;
break;
case "h4":
case 'h4':
cursor = this.elem.getCursor();
line = this.elem.getLine(cursor.line);
this.elem.setLine(cursor.line, "#### " + line);
this.elem.setLine(cursor.line, '#### ' + line);
this.elem.setCursor(cursor.line, cursor.ch + 5);
pass = false;
break;
case "h5":
case 'h5':
cursor = this.elem.getCursor();
line = this.elem.getLine(cursor.line);
this.elem.setLine(cursor.line, "##### " + line);
this.elem.setLine(cursor.line, '##### ' + line);
this.elem.setCursor(cursor.line, cursor.ch + 6);
pass = false;
break;
case "h6":
case 'h6':
cursor = this.elem.getCursor();
line = this.elem.getLine(cursor.line);
this.elem.setLine(cursor.line, "###### " + line);
this.elem.setLine(cursor.line, '###### ' + line);
this.elem.setCursor(cursor.line, cursor.ch + 7);
pass = false;
break;
case "link":
case 'link':
md = this.options.syntax.link.replace('$1', text);
this.elem.replaceSelection(md, "end");
this.elem.replaceSelection(md, 'end');
cursor = this.elem.getCursor();
this.elem.setSelection({line: cursor.line, ch: cursor.ch - 8}, {line: cursor.line, ch: cursor.ch - 1});
pass = false;
break;
case "image":
case 'image':
cursor = this.elem.getCursor();
md = this.options.syntax.image.replace('$1', text);
if (this.elem.getLine(cursor.line) !== "") {
if (this.elem.getLine(cursor.line) !== '') {
md = "\n\n" + md;
}
this.elem.replaceSelection(md, "end");
@ -77,16 +77,16 @@
this.elem.setSelection({line: cursor.line, ch: cursor.ch - 8}, {line: cursor.line, ch: cursor.ch - 1});
pass = false;
break;
case "uppercase":
case 'uppercase':
md = text.toLocaleUpperCase();
break;
case "lowercase":
case 'lowercase':
md = text.toLocaleLowerCase();
break;
case "titlecase":
case 'titlecase':
md = text.toTitleCase();
break;
case "selectword":
case 'selectword':
cursor = this.elem.getCursor();
word = this.elem.getTokenAt(cursor);
if (!/\w$/g.test(word.string)) {
@ -95,7 +95,7 @@
this.elem.setSelection({line: cursor.line, ch: word.start}, {line: cursor.line, ch: word.end});
}
break;
case "copyHTML":
case 'copyHTML':
converter = new Showdown.converter();
if (text) {
md = converter.makeHtml(text);
@ -106,14 +106,14 @@
$(".modal-copyToHTML-content").text(md).selectText();
pass = false;
break;
case "list":
md = text.replace(/^(\s*)(\w\W*)/gm, "$1* $2");
this.elem.replaceSelection(md, "end");
case 'list':
md = text.replace(/^(\s*)(\w\W*)/gm, '$1* $2');
this.elem.replaceSelection(md, 'end');
pass = false;
break;
case "currentDate":
md = moment(new Date()).format("D MMMM YYYY");
this.elem.replaceSelection(md, "end");
case 'currentDate':
md = moment(new Date()).format('D MMMM YYYY');
this.elem.replaceSelection(md, 'end');
pass = false;
break;
default:
@ -122,7 +122,7 @@
}
}
if (pass && md) {
this.elem.replaceSelection(md, "end");
this.elem.replaceSelection(md, 'end');
if (!text) {
letterCount = md.length;
cursor = this.elem.getCursor();

View File

@ -3,49 +3,49 @@
/*global window, document, $, FastClick */
(function () {
"use strict";
'use strict';
FastClick.attach(document.body);
// ### Show content preview when swiping left on content list
$(".manage").on("click", ".content-list ol li", function (event) {
$('.manage').on('click', '.content-list ol li', function (event) {
if (window.matchMedia('(max-width: 800px)').matches) {
event.preventDefault();
event.stopPropagation();
$(".content-list").animate({right: "100%", left: "-100%", 'margin-right': "15px"}, 300);
$(".content-preview").animate({right: "0", left: "0", 'margin-left': "0"}, 300);
$('.content-list').animate({right: '100%', left: '-100%', 'margin-right': '15px'}, 300);
$('.content-preview').animate({right: '0', left: '0', 'margin-left': '0'}, 300);
}
});
// ### Hide content preview
$(".manage").on("click", ".content-preview .button-back", function (event) {
$('.manage').on('click', '.content-preview .button-back', function (event) {
if (window.matchMedia('(max-width: 800px)').matches) {
event.preventDefault();
event.stopPropagation();
$(".content-list").animate({right: "0", left: "0", 'margin-right': "0"}, 300);
$(".content-preview").animate({right: "-100%", left: "100%", 'margin-left': "15px"}, 300);
$('.content-list').animate({right: '0', left: '0', 'margin-right': '0'}, 300);
$('.content-preview').animate({right: '-100%', left: '100%', 'margin-left': '15px'}, 300);
}
});
// ### Show settings options page when swiping left on settings menu link
$(".settings").on("click", ".settings-menu li", function (event) {
$('.settings').on('click', '.settings-menu li', function (event) {
if (window.matchMedia('(max-width: 800px)').matches) {
event.preventDefault();
event.stopPropagation();
$(".settings-sidebar").animate({right: "100%", left: "-102%", 'margin-right': "15px"}, 300);
$(".settings-content").animate({right: "0", left: "0", 'margin-left': "0"}, 300);
$(".settings-content .button-back, .settings-content .button-save").css("display", "inline-block");
$('.settings-sidebar').animate({right: '100%', left: '-102%', 'margin-right': '15px'}, 300);
$('.settings-content').animate({right: '0', left: '0', 'margin-left': '0'}, 300);
$('.settings-content .button-back, .settings-content .button-save').css('display', 'inline-block');
}
});
// ### Hide settings options page
$(".settings").on("click", ".settings-content .button-back", function (event) {
$('.settings').on('click', '.settings-content .button-back', function (event) {
if (window.matchMedia('(max-width: 800px)').matches) {
event.preventDefault();
event.stopPropagation();
$(".settings-sidebar").animate({right: "0", left: "0", 'margin-right': "0"}, 300);
$(".settings-content").animate({right: "-100%", left: "100%", 'margin-left': "15"}, 300);
$(".settings-content .button-back, .settings-content .button-save").css("display", "none");
$('.settings-sidebar').animate({right: '0', left: '0', 'margin-right': '0'}, 300);
$('.settings-content').animate({right: '-100%', left: '100%', 'margin-left': '15'}, 300);
$('.settings-content .button-back, .settings-content .button-save').css('display', 'none');
}
});

View File

@ -1,6 +1,6 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
'use strict';
Ghost.Models.Post = Backbone.Model.extend({
@ -12,8 +12,8 @@
parse: function (resp) {
if (resp.status) {
resp.published = !!(resp.status === "published");
resp.draft = !!(resp.status === "draft");
resp.published = !!(resp.status === 'published');
resp.draft = !!(resp.status === 'draft');
}
if (resp.tags) {
// TODO: parse tags into it's own collection on the model (this.tags)

View File

@ -1,10 +1,10 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
'use strict';
//id:0 is used to issue PUT requests
Ghost.Models.Settings = Backbone.Model.extend({
url: Ghost.settings.apiRoot + '/settings/?type=blog,theme',
id: "0"
id: '0'
});
}());

View File

@ -1,6 +1,6 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
'use strict';
Ghost.Collections.Tags = Backbone.Collection.extend({
url: Ghost.settings.apiRoot + '/tags/'

View File

@ -1,6 +1,6 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
'use strict';
Ghost.Models.Themes = Backbone.Model.extend({
url: Ghost.settings.apiRoot + '/themes'

View File

@ -1,11 +1,11 @@
/*global Ghost, Backbone */
(function () {
"use strict";
'use strict';
Ghost.Models.uploadModal = Backbone.Model.extend({
options: {
close: true,
type: "action",
type: 'action',
style: ["wide"],
animation: 'fade',
afterRender: function () {

View File

@ -1,6 +1,6 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
'use strict';
Ghost.Models.User = Backbone.Model.extend({
url: Ghost.settings.apiRoot + '/users/me/'

View File

@ -1,15 +1,15 @@
/*global window, document, Ghost, $, _, Backbone */
(function () {
"use strict";
'use strict';
Ghost.Models.Widget = Backbone.Model.extend({
defaults: {
title: "",
name: "",
author: "",
applicationID: "",
size: "",
title: '',
name: '',
author: '',
applicationID: '',
size: '',
content: {
template: '',
data: {
@ -17,9 +17,9 @@
count: 0,
sub: {
value: 0,
dir: "", // "up" or "down"
item: "",
period: ""
dir: '', // "up" or "down"
item: '',
period: ''
}
}
}
@ -28,8 +28,8 @@
settingsPane: false,
enabled: false,
options: [{
title: "ERROR",
value: "Widget options not set"
title: 'ERROR',
value: 'Widget options not set'
}]
}
}

View File

@ -2,7 +2,7 @@
/*global document, $, Ghost */
(function () {
"use strict";
'use strict';
Ghost.temporary.hideToggles = function () {
$('[data-toggle]').each(function () {
@ -11,7 +11,7 @@
});
// Toggle active classes on menu headers
$("[data-toggle].active").removeClass("active");
$('[data-toggle].active').removeClass('active');
};
Ghost.temporary.initToggles = function ($el) {

View File

@ -1,4 +1,4 @@
var fs = require('fs'),
var fs = require('fs'),
when = require('when');
function writeConfigFile() {

View File

@ -2,28 +2,28 @@
// Defines core methods required to build the application
// Module dependencies
var config = require('../config'),
when = require('when'),
express = require('express'),
errors = require('./server/errorHandling'),
fs = require('fs'),
path = require('path'),
hbs = require('express-hbs'),
nodefn = require('when/node/function'),
_ = require('underscore'),
Polyglot = require('node-polyglot'),
Mailer = require('./server/mail'),
models = require('./server/models'),
plugins = require('./server/plugins'),
var config = require('../config'),
when = require('when'),
express = require('express'),
errors = require('./server/errorHandling'),
fs = require('fs'),
path = require('path'),
hbs = require('express-hbs'),
nodefn = require('when/node/function'),
_ = require('underscore'),
Polyglot = require('node-polyglot'),
Mailer = require('./server/mail'),
models = require('./server/models'),
plugins = require('./server/plugins'),
requireTree = require('./server/require-tree'),
permissions = require('./server/permissions'),
uuid = require('node-uuid'),
uuid = require('node-uuid'),
// Variables
appRoot = path.resolve(__dirname, '../'),
themePath = path.resolve(appRoot + '/content/themes'),
pluginPath = path.resolve(appRoot + '/content/plugins'),
themeDirectories = requireTree(themePath),
appRoot = path.resolve(__dirname, '../'),
themePath = path.resolve(appRoot + '/content/themes'),
pluginPath = path.resolve(appRoot + '/content/plugins'),
themeDirectories = requireTree(themePath),
pluginDirectories = requireTree(pluginPath),
Ghost,
@ -111,7 +111,7 @@ Ghost = function () {
'appRoot': appRoot,
'themePath': themePath,
'pluginPath': pluginPath,
'activeTheme': path.join(themePath, !instance.settingsCache ? "" : instance.settingsCache.activeTheme.value),
'activeTheme': path.join(themePath, !instance.settingsCache ? '' : instance.settingsCache.activeTheme.value),
'adminViews': path.join(appRoot, '/core/server/views/'),
'helperTemplates': path.join(appRoot, '/core/server/helpers/tpl/'),
'lang': path.join(appRoot, '/core/shared/lang/'),
@ -261,7 +261,7 @@ Ghost.prototype.loadTemplate = function (name) {
var self = this,
templateFileName = name + '.hbs',
// Check for theme specific version first
templatePath = path.join(this.paths().activeTheme, "partials", templateFileName),
templatePath = path.join(this.paths().activeTheme, 'partials', templateFileName),
deferred = when.defer();
// Can't use nodefn here because exists just returns one parameter, true or false

View File

@ -1,18 +1,18 @@
// Module dependencies
var express = require('express'),
when = require('when'),
_ = require('underscore'),
colors = require("colors"),
semver = require("semver"),
slashes = require("connect-slashes"),
errors = require('./server/errorHandling'),
admin = require('./server/controllers/admin'),
frontend = require('./server/controllers/frontend'),
api = require('./server/api'),
path = require('path'),
hbs = require('express-hbs'),
Ghost = require('./ghost'),
helpers = require('./server/helpers'),
var express = require('express'),
when = require('when'),
_ = require('underscore'),
colors = require('colors'),
semver = require('semver'),
slashes = require('connect-slashes'),
errors = require('./server/errorHandling'),
admin = require('./server/controllers/admin'),
frontend = require('./server/controllers/frontend'),
api = require('./server/api'),
path = require('path'),
hbs = require('express-hbs'),
Ghost = require('./ghost'),
helpers = require('./server/helpers'),
packageInfo = require('../package.json'),
// Variables
@ -129,8 +129,8 @@ function ghostLocals(req, res, next) {
// Disable any caching until it can be done properly
function disableCachedResult(req, res, next) {
res.set({
"Cache-Control": "no-cache, must-revalidate",
"Expires": "Sat, 26 Jul 1997 05:00:00 GMT"
'Cache-Control': 'no-cache, must-revalidate',
'Expires': 'Sat, 26 Jul 1997 05:00:00 GMT'
});
next();
@ -229,7 +229,7 @@ when.all([ghost.init(), helpers.loadCoreHelpers(ghost)]).then(function () {
var oneYear = 31536000000;
// Logging configuration
if (server.get('env') !== "development") {
if (server.get('env') !== 'development') {
server.use(express.logger());
} else {
server.use(express.logger('dev'));
@ -244,7 +244,7 @@ when.all([ghost.init(), helpers.loadCoreHelpers(ghost)]).then(function () {
server.use('/shared', express['static'](path.join(__dirname, '/shared')));
server.use('/content/images', express['static'](path.join(__dirname, '/../content/images')));
// Serve our built scripts; can't use /scripts here because themes already are
server.use("/built/scripts", express['static'](path.join(__dirname, '/built/scripts'), {
server.use('/built/scripts', express['static'](path.join(__dirname, '/built/scripts'), {
// Put a maxAge of one year on built scripts
maxAge: oneYear
}));

View File

@ -1,14 +1,14 @@
// # Ghost Data API
// Provides access to the data model
var Ghost = require('../ghost'),
_ = require('underscore'),
when = require('when'),
errors = require('./errorHandling'),
permissions = require('./permissions'),
canThis = permissions.canThis,
var Ghost = require('../ghost'),
_ = require('underscore'),
when = require('when'),
errors = require('./errorHandling'),
permissions = require('./permissions'),
canThis = permissions.canThis,
ghost = new Ghost(),
ghost = new Ghost(),
dataProvider = ghost.dataProvider,
posts,
users,
@ -221,7 +221,7 @@ settingsCollection = function (settings) {
settingsFilter = function (settings, filter) {
return _.object(_.filter(_.pairs(settings), function (setting) {
if (filter) {
return _.some(filter.split(","), function (f) {
return _.some(filter.split(','), function (f) {
return setting[1].type === f;
});
}

View File

@ -1,17 +1,17 @@
var Ghost = require('../../ghost'),
dataExport = require('../data/export'),
dataImport = require('../data/import'),
_ = require('underscore'),
fs = require('fs-extra'),
path = require('path'),
when = require('when'),
nodefn = require('when/node/function'),
api = require('../api'),
moment = require('moment'),
errors = require('../errorHandling'),
var Ghost = require('../../ghost'),
dataExport = require('../data/export'),
dataImport = require('../data/import'),
_ = require('underscore'),
fs = require('fs-extra'),
path = require('path'),
when = require('when'),
nodefn = require('when/node/function'),
api = require('../api'),
moment = require('moment'),
errors = require('../errorHandling'),
ghost = new Ghost(),
dataProvider = ghost.dataProvider,
ghost = new Ghost(),
dataProvider = ghost.dataProvider,
adminNavbar,
adminControllers,
loginSecurity = [];
@ -73,8 +73,8 @@ adminControllers = {
'uploader': function (req, res) {
var currentDate = moment(),
month = currentDate.format("MMM"),
year = currentDate.format("YYYY"),
month = currentDate.format('MMM'),
year = currentDate.format('YYYY'),
tmp_path = req.files.uploadimage.path,
dir = path.join('content/images', year, month),
ext = path.extname(req.files.uploadimage.name).toLowerCase(),
@ -106,7 +106,7 @@ adminControllers = {
}
// TODO: is it better to use file type eg. image/png?
if (ext === ".jpg" || ext === ".jpeg" || ext === ".png" || ext === ".gif") {
if (ext === '.jpg' || ext === '.jpeg' || ext === '.png' || ext === '.gif') {
getUniqueFileName(dir, basename, ext, null, function (filename) {
renameFile(filename);
});
@ -269,8 +269,8 @@ adminControllers = {
// TODO: Centralise list/enumeration of settings panes, so we don't
// run into trouble in future.
var allowedSections = ["", "general", "user"],
section = req.url.replace(/(^\/ghost\/settings[\/]*|\/$)/ig, "");
var allowedSections = ['', 'general', 'user'],
section = req.url.replace(/(^\/ghost\/settings[\/]*|\/$)/ig, '');
if (allowedSections.indexOf(section) < 0) {
return next();
@ -312,7 +312,7 @@ adminControllers = {
};
return api.notifications.add(notification).then(function () {
res.redirect("/ghost/debug/");
res.redirect('/ghost/debug/');
});
});
},
@ -327,16 +327,16 @@ adminControllers = {
};
return api.notifications.add(notification).then(function () {
res.redirect("/ghost/debug/");
res.redirect('/ghost/debug/');
});
}
// Get the current version for importing
api.settings.read({ key: "databaseVersion" })
api.settings.read({ key: 'databaseVersion' })
.then(function (setting) {
return when(setting.value);
}, function () {
return when("001");
return when('001');
})
.then(function (databaseVersion) {
// Read the file contents

View File

@ -4,14 +4,14 @@
/*global require, module */
var Ghost = require('../../ghost'),
api = require('../api'),
RSS = require('rss'),
_ = require('underscore'),
var Ghost = require('../../ghost'),
api = require('../api'),
RSS = require('rss'),
_ = require('underscore'),
errors = require('../errorHandling'),
when = require('when'),
when = require('when'),
ghost = new Ghost(),
ghost = new Ghost(),
frontendControllers;
frontendControllers = {
@ -24,7 +24,7 @@ frontendControllers = {
// No negative pages
if (isNaN(pageParam) || pageParam < 1) {
//redirect to 404 page?
return res.redirect("/");
return res.redirect('/');
}
options.page = pageParam;
@ -94,7 +94,7 @@ frontendControllers = {
// No negative pages
if (isNaN(pageParam) || pageParam < 1) {
return res.redirect("/rss/");
return res.redirect('/rss/');
}
if (pageParam === 1 && req.route.path === '/rss/:page/') {
@ -112,7 +112,7 @@ frontendControllers = {
// If page is greater than number of pages we have, redirect to last page
if (pageParam > maxPage) {
return res.redirect("/rss/" + maxPage + "/");
return res.redirect('/rss/' + maxPage + '/');
}
ghost.doFilter('prePostsRender', page.posts, function (posts) {

View File

@ -1,8 +1,8 @@
var when = require('when'),
_ = require('underscore'),
var when = require('when'),
_ = require('underscore'),
migration = require('../migration'),
client = require('../../models/base').client,
knex = require('../../models/base').Knex,
client = require('../../models/base').client,
knex = require('../../models/base').Knex,
exporter;
@ -15,7 +15,7 @@ function getTablesFromSqlite3() {
}
function getTablesFromMySQL() {
return knex.Raw("show tables").then(function (response) {
return knex.Raw('show tables').then(function (response) {
return _.flatten(_.map(response, function (entry) {
return _.values(entry);
}));

View File

@ -1,10 +1,10 @@
var sequence = require('when/sequence'),
_ = require('underscore'),
Post = require('../../models/post').Post,
Tag = require('../../models/tag').Tag,
Role = require('../../models/role').Role,
var sequence = require('when/sequence'),
_ = require('underscore'),
Post = require('../../models/post').Post,
Tag = require('../../models/tag').Tag,
Role = require('../../models/role').Role,
Permission = require('../../models/permission').Permission,
uuid = require('node-uuid');
uuid = require('node-uuid');
var fixtures = {
posts: [

View File

@ -1,19 +1,19 @@
var when = require("when"),
_ = require("underscore"),
var when = require('when'),
_ = require('underscore'),
models = require('../../models'),
errors = require('../../errorHandling'),
Importer000;
Importer000 = function () {
_.bindAll(this, "basicImport");
_.bindAll(this, 'basicImport');
this.version = "000";
this.version = '000';
this.importFrom = {
"000": this.basicImport,
"001": this.tempImport,
"002": this.tempImport
'000': this.basicImport,
'001': this.tempImport,
'002': this.tempImport
};
};

View File

@ -4,7 +4,7 @@ module.exports = function (version, data) {
var importer;
try {
importer = require("./" + version);
importer = require('./' + version);
} catch (ignore) {
// Zero effs given
}

View File

@ -131,22 +131,22 @@ up = function () {
down = function () {
return when.all([
knex.Schema.dropTableIfExists("posts"),
knex.Schema.dropTableIfExists("users"),
knex.Schema.dropTableIfExists("roles"),
knex.Schema.dropTableIfExists("settings"),
knex.Schema.dropTableIfExists("permissions"),
knex.Schema.dropTableIfExists("tags")
knex.Schema.dropTableIfExists('posts'),
knex.Schema.dropTableIfExists('users'),
knex.Schema.dropTableIfExists('roles'),
knex.Schema.dropTableIfExists('settings'),
knex.Schema.dropTableIfExists('permissions'),
knex.Schema.dropTableIfExists('tags')
]).then(function () {
// Drop the relation tables after the model tables
return when.all([
knex.Schema.dropTableIfExists("roles_users"),
knex.Schema.dropTableIfExists("permissions_users"),
knex.Schema.dropTableIfExists("permissions_roles"),
knex.Schema.dropTableIfExists("posts_tags")
knex.Schema.dropTableIfExists('roles_users'),
knex.Schema.dropTableIfExists('permissions_users'),
knex.Schema.dropTableIfExists('permissions_roles'),
knex.Schema.dropTableIfExists('posts_tags')
]);
});
};
exports.up = up;
exports.up = up;
exports.down = down;

View File

@ -1,15 +1,15 @@
var _ = require('underscore'),
when = require('when'),
series = require('when/sequence'),
errors = require('../../errorHandling'),
knex = require('../../models/base').Knex,
var _ = require('underscore'),
when = require('when'),
series = require('when/sequence'),
errors = require('../../errorHandling'),
knex = require('../../models/base').Knex,
defaultSettings = require('../default-settings'),
Settings = require('../../models/settings').Settings,
fixtures = require('../fixtures'),
Settings = require('../../models/settings').Settings,
fixtures = require('../fixtures'),
initialVersion = '000',
initialVersion = '000',
defaultDatabaseVersion;
// Default Database Version

View File

@ -1,16 +1,16 @@
/*jslint regexp: true */
var _ = require('underscore'),
colors = require("colors"),
fs = require('fs'),
path = require('path'),
var _ = require('underscore'),
colors = require('colors'),
fs = require('fs'),
path = require('path'),
errors,
// Paths for views
appRoot = path.resolve(__dirname, '../'),
themePath = path.resolve(appRoot + '/content/themes'),
adminTemplatePath = path.resolve(appRoot + '/server/views/'),
appRoot = path.resolve(__dirname, '../'),
themePath = path.resolve(appRoot + '/content/themes'),
adminTemplatePath = path.resolve(appRoot + '/server/views/'),
defaultErrorTemplatePath = path.resolve(adminTemplatePath + '/user-error.hbs'),
userErrorTemplatePath = path.resolve(themePath + '/error.hbs'),
userErrorTemplatePath = path.resolve(themePath + '/error.hbs'),
userErrorTemplateExists;
/**
@ -31,14 +31,14 @@ errors = {
logError: function (err, context, help) {
var stack = err ? err.stack : null;
err = err.message || err || "Unknown";
err = err.message || err || 'Unknown';
// TODO: Logging framework hookup
// Eventually we'll have better logging which will know about envs
if ((process.env.NODE_ENV === 'development' ||
process.env.NODE_ENV === 'staging' ||
process.env.NODE_ENV === 'production')) {
console.error("\nERROR:".red, err.red);
console.error('\nERROR:'.red, err.red);
if (context) {
console.error(context);
@ -49,10 +49,10 @@ errors = {
}
// add a new line
console.error("");
console.error('');
if (stack) {
console.error(stack, "\n");
console.error(stack, '\n');
}
}
},
@ -84,7 +84,7 @@ errors = {
renderErrorPage: function (code, err, req, res, next) {
function parseStack(stack) {
if (typeof stack !== "string") {
if (typeof stack !== 'string') {
return stack;
}
@ -102,8 +102,8 @@ errors = {
}
return {
"function": parts[1],
"at": parts[2]
'function': parts[1],
'at': parts[2]
};
})
.filter(function (line) {
@ -116,12 +116,12 @@ errors = {
function renderErrorInt(errorView) {
var stack = null;
if (process.env.NODE_ENV !== "production" && err.stack) {
if (process.env.NODE_ENV !== 'production' && err.stack) {
stack = parseStack(err.stack);
}
// TODO: Attach node-polyglot
res.render((errorView || "error"), {
res.render((errorView || 'error'), {
message: err.message || err,
code: code,
stack: stack
@ -177,13 +177,13 @@ errors = {
// Ensure our 'this' context in the functions
_.bindAll(
errors,
"throwError",
"logError",
"logAndThrowError",
"logErrorWithRedirect",
"renderErrorPage",
"render404Page",
"render500Page"
'throwError',
'logError',
'logAndThrowError',
'logErrorWithRedirect',
'renderErrorPage',
'render404Page',
'render500Page'
);
module.exports = errors;

View File

@ -1,18 +1,18 @@
var _ = require('underscore'),
moment = require('moment'),
downsize = require('downsize'),
when = require('when'),
hbs = require('express-hbs'),
var _ = require('underscore'),
moment = require('moment'),
downsize = require('downsize'),
when = require('when'),
hbs = require('express-hbs'),
packageInfo = require('../../../package.json'),
errors = require('../errorHandling'),
models = require('../models'),
errors = require('../errorHandling'),
models = require('../models'),
coreHelpers;
coreHelpers = function (ghost) {
var paginationHelper,
scriptTemplate = _.template("<script src='/built/scripts/<%= name %>?v=<%= version %>'></script>"),
isProduction = process.env.NODE_ENV === "production",
isProduction = process.env.NODE_ENV === 'production',
version = encodeURIComponent(packageInfo.version);
/**
@ -34,7 +34,7 @@ coreHelpers = function (ghost) {
}
}
var f = options.hash.format || "MMM Do, YYYY",
var f = options.hash.format || 'MMM Do, YYYY',
timeago = options.hash.timeago,
date;
@ -76,7 +76,7 @@ coreHelpers = function (ghost) {
}
if (models.isPost(this)) {
output += "/" + this.slug + '/';
output += '/' + this.slug + '/';
}
return output;
@ -91,7 +91,7 @@ coreHelpers = function (ghost) {
// if the author could not be determined.
//
ghost.registerThemeHelper('author', function (context, options) {
return this.author ? this.author.name : "";
return this.author ? this.author.name : '';
});
// ### Tags Helper
@ -106,10 +106,10 @@ coreHelpers = function (ghost) {
// Note that the standard {{#each tags}} implementation is unaffected by this helper
// and can be used for more complex templates.
ghost.registerThemeHelper('tags', function (options) {
var separator = ", ",
var separator = ', ',
tagNames;
if (typeof options.hash.separator === "string") {
if (typeof options.hash.separator === 'string') {
separator = options.hash.separator;
}
@ -133,7 +133,7 @@ coreHelpers = function (ghost) {
//
ghost.registerThemeHelper('content', function (options) {
var truncateOptions = (options || {}).hash || {};
truncateOptions = _.pick(truncateOptions, ["words", "characters"]);
truncateOptions = _.pick(truncateOptions, ['words', 'characters']);
if (truncateOptions.words || truncateOptions.characters) {
return new hbs.handlebars.SafeString(
@ -162,10 +162,10 @@ coreHelpers = function (ghost) {
var truncateOptions = (options || {}).hash || {},
excerpt;
truncateOptions = _.pick(truncateOptions, ["words", "characters"]);
truncateOptions = _.pick(truncateOptions, ['words', 'characters']);
/*jslint regexp:true */
excerpt = String(this.html).replace(/<\/?[^>]+>/gi, "");
excerpt = String(this.html).replace(/<\/?[^>]+>/gi, '');
/*jslint regexp:false */
if (!truncateOptions.words && !truncateOptions.characters) {
@ -198,7 +198,7 @@ coreHelpers = function (ghost) {
var classes = ['post'];
if (this.tags) {
classes = classes.concat(this.tags.map(function (tag) { return "tag-" + tag.name; }));
classes = classes.concat(this.tags.map(function (tag) { return 'tag-' + tag.name; }));
}
return ghost.doFilter('post_class', classes, function (classes) {
@ -216,7 +216,7 @@ coreHelpers = function (ghost) {
head.push('<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss/">');
return ghost.doFilter('ghost_head', head, function (head) {
var headString = _.reduce(head, function (memo, item) { return memo + "\n" + item; }, '');
var headString = _.reduce(head, function (memo, item) { return memo + '\n' + item; }, '');
return new hbs.handlebars.SafeString(headString.trim());
});
});
@ -295,7 +295,7 @@ coreHelpers = function (ghost) {
j = 0,
columns = options.hash.columns,
key,
ret = "",
ret = '',
data;
if (options.data) {
@ -359,18 +359,18 @@ coreHelpers = function (ghost) {
});
// A helper for inserting the javascript tags with version hashes
ghost.registerThemeHelper("ghostScriptTags", function () {
ghost.registerThemeHelper('ghostScriptTags', function () {
var scriptFiles = [];
if (isProduction) {
scriptFiles.push("ghost.min.js");
} else {
scriptFiles = [
"vendor.js",
"helpers.js",
"templates.js",
"models.js",
"views.js"
'vendor.js',
'helpers.js',
'templates.js',
'models.js',
'views.js'
];
}
@ -381,7 +381,7 @@ coreHelpers = function (ghost) {
});
});
return scriptFiles.join("");
return scriptFiles.join('');
});
// ## Template driven helpers

View File

@ -1,8 +1,8 @@
var cp = require('child_process'),
url = require('url'),
_ = require('underscore'),
when = require('when'),
nodefn = require('when/node/function'),
var cp = require('child_process'),
url = require('url'),
_ = require('underscore'),
when = require('when'),
nodefn = require('when/node/function'),
nodemailer = require('nodemailer');
function GhostMailer(opts) {

View File

@ -1,10 +1,10 @@
var GhostBookshelf,
Bookshelf = require('bookshelf'),
when = require('when'),
moment = require('moment'),
_ = require('underscore'),
uuid = require('node-uuid'),
config = require('../../../config'),
when = require('when'),
moment = require('moment'),
_ = require('underscore'),
uuid = require('node-uuid'),
config = require('../../../config'),
Validator = require('validator').Validator;
// Initializes Bookshelf as its own instance, so we can modify the Models and not mess up
@ -70,7 +70,7 @@ GhostBookshelf.Model = GhostBookshelf.Model.extend({
}
_.each(relations, function (relation, key) {
if (key.substring(0, 7) !== "_pivot_") {
if (key.substring(0, 7) !== '_pivot_') {
attrs[key] = relation.toJSON ? relation.toJSON() : relation;
}
});
@ -126,7 +126,7 @@ GhostBookshelf.Model = GhostBookshelf.Model.extend({
//if slug is empty after trimming use "post"
if (!slug) {
slug = "post";
slug = 'post';
}
// Test for duplicate slugs.
return checkIfSlugExists(slug);

View File

@ -16,7 +16,7 @@ module.exports = {
});
},
isPost: function (jsonData) {
return jsonData.hasOwnProperty("html") && jsonData.hasOwnProperty("markdown")
&& jsonData.hasOwnProperty("title") && jsonData.hasOwnProperty("slug");
return jsonData.hasOwnProperty('html') && jsonData.hasOwnProperty('markdown')
&& jsonData.hasOwnProperty('title') && jsonData.hasOwnProperty('slug');
}
};

View File

@ -1,6 +1,6 @@
var GhostBookshelf = require('./base'),
User = require('./user').User,
Role = require('./role').Role,
User = require('./user').User,
Role = require('./role').Role,
Permission,
Permissions;

View File

@ -173,7 +173,7 @@ Post = GhostBookshelf.Model.extend({
// Extends base model findAll to eager-fetch author and user relationships.
findAll: function (options) {
options = options || {};
options.withRelated = [ "author", "user", "tags" ];
options.withRelated = [ 'author', 'user', 'tags' ];
return GhostBookshelf.Model.findAll.call(this, options);
},
@ -181,7 +181,7 @@ Post = GhostBookshelf.Model.extend({
// Extends base model findOne to eager-fetch author and user relationships.
findOne: function (args, options) {
options = options || {};
options.withRelated = [ "author", "user", "tags" ];
options.withRelated = [ 'author', 'user', 'tags' ];
return GhostBookshelf.Model.findOne.call(this, args, options);
},
@ -235,7 +235,7 @@ Post = GhostBookshelf.Model.extend({
postCollection.query('where', opts.where);
}
opts.withRelated = [ "author", "user", "tags" ];
opts.withRelated = [ 'author', 'user', 'tags' ];
// Set the limit & offset for the query, fetching
// with the opts (to specify any eager relations, etc.)

View File

@ -1,5 +1,5 @@
var User = require('./user').User,
Permission = require('./permission').Permission,
var User = require('./user').User,
Permission = require('./permission').Permission,
GhostBookshelf = require('./base'),
Role,
Roles;

View File

@ -1,10 +1,10 @@
var Settings,
GhostBookshelf = require('./base'),
validator = GhostBookshelf.validator,
uuid = require('node-uuid'),
_ = require('underscore'),
errors = require('../errorHandling'),
when = require('when'),
validator = GhostBookshelf.validator,
uuid = require('node-uuid'),
_ = require('underscore'),
errors = require('../errorHandling'),
when = require('when'),
defaultSettings;
// For neatness, the defaults file is split into categories.

View File

@ -1,6 +1,6 @@
var Tag,
Tags,
Posts = require('./post').Posts,
Posts = require('./post').Posts,
GhostBookshelf = require('./base');
Tag = GhostBookshelf.Model.extend({

View File

@ -1,20 +1,20 @@
var User,
Users,
_ = require('underscore'),
uuid = require('node-uuid'),
when = require('when'),
errors = require('../errorHandling'),
nodefn = require('when/node/function'),
bcrypt = require('bcrypt-nodejs'),
Posts = require('./post').Posts,
_ = require('underscore'),
uuid = require('node-uuid'),
when = require('when'),
errors = require('../errorHandling'),
nodefn = require('when/node/function'),
bcrypt = require('bcrypt-nodejs'),
Posts = require('./post').Posts,
GhostBookshelf = require('./base'),
Role = require('./role').Role,
Permission = require('./permission').Permission;
Role = require('./role').Role,
Permission = require('./permission').Permission;
function validatePasswordLength(password) {
try {
GhostBookshelf.validator.check(password, "Your password is not long enough. It must be at least 8 characters long.").len(8);
GhostBookshelf.validator.check(password, "Your must be at least 8 characters long.").len(8);
} catch (error) {
return when.reject(error);
}
@ -33,10 +33,10 @@ User = GhostBookshelf.Model.extend({
],
validate: function () {
GhostBookshelf.validator.check(this.get('email'), "Please check your email address. It does not seem to be valid.").isEmail();
GhostBookshelf.validator.check(this.get('bio'), "Your bio is too long. Please keep it to 200 chars.").len(0, 200);
GhostBookshelf.validator.check(this.get('email'), "Please enter a valid email address. That one looks a bit dodgy.").isEmail();
GhostBookshelf.validator.check(this.get('bio'), "We're not writing a novel here! I'm afraid your bio has to stay under 200 characters.").len(0, 200);
if (this.get('website') && this.get('website').length > 0) {
GhostBookshelf.validator.check(this.get('website'), "Your website is not a valid URL.").isUrl();
GhostBookshelf.validator.check(this.get('website'), "Looks like your website is not actually a website. Try again?").isUrl();
}
return true;
},

View File

@ -1,11 +1,11 @@
// canThis(someUser).edit.posts([id]|[[ids]])
// canThis(someUser).edit.post(somePost|somePostId)
var _ = require('underscore'),
when = require('when'),
Models = require('../models'),
objectTypeModelMap = require('./objectTypeModelMap'),
UserProvider = Models.User,
var _ = require('underscore'),
when = require('when'),
Models = require('../models'),
objectTypeModelMap = require('./objectTypeModelMap'),
UserProvider = Models.User,
PermissionsProvider = Models.Permission,
init,
refresh,

View File

@ -1,7 +1,7 @@
module.exports = {
'post': require('../models/post').Post,
'role': require('../models/role').Role,
'user': require('../models/user').User,
'post': require('../models/post').Post,
'role': require('../models/role').Role,
'user': require('../models/user').User,
'permission': require('../models/permission').Permission,
'setting': require('../models/settings').Settings
'setting': require('../models/settings').Settings
};

View File

@ -1,17 +1,17 @@
var _ = require("underscore"),
when = require('when'),
var _ = require('underscore'),
when = require('when'),
ghostApi,
loader = require("./loader"),
GhostPlugin = require("./GhostPlugin");
loader = require('./loader'),
GhostPlugin = require('./GhostPlugin');
function getInstalledPlugins() {
if (!ghostApi) {
ghostApi = require('../api');
}
return ghostApi.settings.read("installedPlugins").then(function (installed) {
installed.value = installed.value || "[]";
return ghostApi.settings.read('installedPlugins').then(function (installed) {
installed.value = installed.value || '[]';
try {
installed = JSON.parse(installed.value);
@ -27,7 +27,7 @@ function saveInstalledPlugins(installedPlugins) {
return getInstalledPlugins().then(function (currentInstalledPlugins) {
var updatedPluginsInstalled = _.uniq(installedPlugins.concat(currentInstalledPlugins));
return ghostApi.settings.edit("installedPlugins", updatedPluginsInstalled);
return ghostApi.settings.edit('installedPlugins', updatedPluginsInstalled);
});
}

View File

@ -1,7 +1,7 @@
var path = require("path"),
_ = require("underscore"),
when = require("when"),
var path = require('path'),
_ = require('underscore'),
when = require('when'),
ghostInstance,
loader;
@ -10,7 +10,7 @@ function getGhostInstance() {
return ghostInstance;
}
var Ghost = require("../../ghost");
var Ghost = require('../../ghost');
ghostInstance = new Ghost();

View File

@ -1,7 +1,7 @@
var when = require('when'),
keys = require('when/keys'),
fs = require('fs'),
path = require('path'),
var when = require('when'),
keys = require('when/keys'),
fs = require('fs'),
path = require('path'),
extend = function (obj, source) {
var key;
for (key in source) {

View File

@ -2,7 +2,7 @@
// Orchestrates the loading of Ghost
var configLoader = require('./core/config-loader.js'),
error = require('./core/server/errorHandling');
error = require('./core/server/errorHandling');
// If no env is set, default to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';