mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Merge branch 'migrations-003' into new-version
Conflicts: .gitignore config.example.js core/server/models/post.js package.json
This commit is contained in:
commit
70824a247f
10 changed files with 82 additions and 18 deletions
|
@ -25,7 +25,7 @@
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
},
|
||||||
"defaultLang": {
|
"defaultLang": {
|
||||||
"default": "en",
|
"default": "en_US",
|
||||||
"validations": {
|
"validations": {
|
||||||
"notNull": true
|
"notNull": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ module.exports = {
|
||||||
"meta_title": null,
|
"meta_title": null,
|
||||||
"meta_description": null,
|
"meta_description": null,
|
||||||
"meta_keywords": null,
|
"meta_keywords": null,
|
||||||
"featured": null,
|
"featured": true,
|
||||||
"image": null,
|
"image": null,
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"language": null,
|
"language": "en",
|
||||||
"author_id": 1,
|
"author_id": 1,
|
||||||
"created_at": 1373578890610,
|
"created_at": 1373578890610,
|
||||||
"created_by": 1,
|
"created_by": 1,
|
||||||
|
|
13
core/server/data/fixtures/003.js
Normal file
13
core/server/data/fixtures/003.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
var uuid = require('node-uuid');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
posts: [],
|
||||||
|
|
||||||
|
settings: [],
|
||||||
|
|
||||||
|
roles: [],
|
||||||
|
|
||||||
|
permissions: [],
|
||||||
|
|
||||||
|
permissions_roles: []
|
||||||
|
};
|
|
@ -15,13 +15,13 @@ up = function () {
|
||||||
t.string('slug');
|
t.string('slug');
|
||||||
t.text('content_raw');
|
t.text('content_raw');
|
||||||
t.text('content');
|
t.text('content');
|
||||||
t.string('meta_title');
|
t.string('meta_title').nullable();
|
||||||
t.string('meta_description');
|
t.string('meta_description').nullable();
|
||||||
t.string('meta_keywords');
|
t.string('meta_keywords').nullable();
|
||||||
t.bool('featured');
|
t.bool('featured').defaultTo(false);
|
||||||
t.string('image');
|
t.string('image').nullable();
|
||||||
t.string('status');
|
t.string('status');
|
||||||
t.string('language');
|
t.string('language').defaultTo('en');
|
||||||
t.integer('author_id');
|
t.integer('author_id');
|
||||||
t.dateTime('created_at');
|
t.dateTime('created_at');
|
||||||
t.integer('created_by');
|
t.integer('created_by');
|
||||||
|
|
49
core/server/data/migration/003.js
Normal file
49
core/server/data/migration/003.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
var when = require('when'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
knex = require('../../models/base').Knex,
|
||||||
|
migrationVersion = '003',
|
||||||
|
fixtures = require('../fixtures/' + migrationVersion),
|
||||||
|
errors = require('../../errorHandling'),
|
||||||
|
up,
|
||||||
|
down;
|
||||||
|
|
||||||
|
up = function up() {
|
||||||
|
|
||||||
|
return when.all([
|
||||||
|
|
||||||
|
knex('posts')
|
||||||
|
.whereNull('language')
|
||||||
|
.orWhere('language', 'en')
|
||||||
|
.update({
|
||||||
|
'language': 'en_US'
|
||||||
|
}),
|
||||||
|
|
||||||
|
knex('posts')
|
||||||
|
.whereNull('featured')
|
||||||
|
.update({
|
||||||
|
'featured': false
|
||||||
|
})
|
||||||
|
|
||||||
|
]).then(function incrementVersion() {
|
||||||
|
|
||||||
|
// Lastly, update the current version settings to reflect this version
|
||||||
|
return knex('settings')
|
||||||
|
.where('key', 'currentVersion')
|
||||||
|
.update({ 'value': migrationVersion });
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
down = function down() {
|
||||||
|
|
||||||
|
return when.all([
|
||||||
|
|
||||||
|
// No new tables as of yet, so just return a wrapped value
|
||||||
|
when(true)
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.up = up;
|
||||||
|
exports.down = down;
|
|
@ -4,11 +4,11 @@ var _ = require('underscore'),
|
||||||
series = require('when/sequence'),
|
series = require('when/sequence'),
|
||||||
errors = require('../../errorHandling'),
|
errors = require('../../errorHandling'),
|
||||||
knex = require('../../models/base').Knex,
|
knex = require('../../models/base').Knex,
|
||||||
initialVersion = "001",
|
initialVersion = '001',
|
||||||
// This currentVersion string should always be the current version of Ghost,
|
// This currentVersion string should always be the current version of Ghost,
|
||||||
// we could probably load it from the config file.
|
// we could probably load it from the config file.
|
||||||
// - Will be possible after default-settings.json restructure
|
// - Will be possible after default-settings.json restructure
|
||||||
currentVersion = "002";
|
currentVersion = '003';
|
||||||
|
|
||||||
function getCurrentVersion() {
|
function getCurrentVersion() {
|
||||||
return knex.Schema.hasTable('settings').then(function () {
|
return knex.Schema.hasTable('settings').then(function () {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var GhostBookshelf,
|
var GhostBookshelf,
|
||||||
Bookshelf = require('bookshelf'),
|
Bookshelf = require('bookshelf'),
|
||||||
|
moment = require('moment'),
|
||||||
_ = require('underscore'),
|
_ = require('underscore'),
|
||||||
config = require('../../../config'),
|
config = require('../../../config'),
|
||||||
Validator = require('validator').Validator;
|
Validator = require('validator').Validator;
|
||||||
|
@ -19,7 +20,7 @@ GhostBookshelf.Model = GhostBookshelf.Model.extend({
|
||||||
fixDates: function (attrs) {
|
fixDates: function (attrs) {
|
||||||
_.each(attrs, function (value, key) {
|
_.each(attrs, function (value, key) {
|
||||||
if (key.substr(-3) === '_at' && value !== null) {
|
if (key.substr(-3) === '_at' && value !== null) {
|
||||||
attrs[key] = new Date(attrs[key]);
|
attrs[key] = moment(attrs[key]).toDate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ var Post,
|
||||||
github = require('../../shared/vendor/showdown/extensions/github'),
|
github = require('../../shared/vendor/showdown/extensions/github'),
|
||||||
converter = new Showdown.converter({extensions: [github]}),
|
converter = new Showdown.converter({extensions: [github]}),
|
||||||
User = require('./user').User,
|
User = require('./user').User,
|
||||||
|
config = require('../../../config'),
|
||||||
Tag = require('./tag').Tag,
|
Tag = require('./tag').Tag,
|
||||||
Tags = require('./tag').Tags,
|
Tags = require('./tag').Tags,
|
||||||
GhostBookshelf = require('./base');
|
GhostBookshelf = require('./base');
|
||||||
|
@ -27,8 +28,8 @@ Post = GhostBookshelf.Model.extend({
|
||||||
defaults: function () {
|
defaults: function () {
|
||||||
return {
|
return {
|
||||||
uuid: uuid.v4(),
|
uuid: uuid.v4(),
|
||||||
status: 'draft'
|
status: 'draft',
|
||||||
// TODO: language: ghost.config().defaultLang);
|
language: config.defaultLang
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ I18n = function (ghost) {
|
||||||
|
|
||||||
return function (req, res, next) {
|
return function (req, res, next) {
|
||||||
|
|
||||||
if (lang === 'en') {
|
if (lang === 'en_US') {
|
||||||
// TODO: do stuff here to optimise for en
|
// TODO: do stuff here to optimise for en
|
||||||
|
|
||||||
// Make jslint empty block error go away
|
// Make jslint empty block error go away
|
||||||
lang = 'en';
|
lang = 'en_US';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO: potentially use req.acceptedLanguages rather than the default
|
/** TODO: potentially use req.acceptedLanguages rather than the default
|
||||||
|
@ -26,8 +26,8 @@ I18n = function (ghost) {
|
||||||
* TODO: switch this mess to be promise driven */
|
* TODO: switch this mess to be promise driven */
|
||||||
fs.stat(langFilePath, function (error) {
|
fs.stat(langFilePath, function (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('No language file found for language ' + lang + '. Defaulting to en');
|
console.log('No language file found for language ' + lang + '. Defaulting to en_US');
|
||||||
lang = 'en';
|
lang = 'en_US';
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile(langFilePath, function (error, data) {
|
fs.readFile(langFilePath, function (error, data) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue