0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00

Merge pull request #405 from gotdibbs/MySQL-Support

MySQL Support
This commit is contained in:
Hannah Wolfe 2013-08-24 08:17:49 -07:00
commit 05a64704e3
12 changed files with 84 additions and 18 deletions

1
.gitignore vendored
View file

@ -37,6 +37,7 @@ projectFilesBackup
/core/server/data/export/exported* /core/server/data/export/exported*
/docs /docs
/_site /_site
/core/test/functional/*_test.png
# Changelog, which is autogenerated, not committed # Changelog, which is autogenerated, not committed
CHANGELOG.md CHANGELOG.md

View file

@ -6,7 +6,7 @@ var path = require('path'),
// ## Admin settings // ## Admin settings
// Default language // Default language
config.defaultLang = 'en'; config.defaultLang = 'en_US';
// Force i18n to be on // Force i18n to be on
config.forceI18n = true; config.forceI18n = true;

View file

@ -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,

View file

@ -0,0 +1,13 @@
var uuid = require('node-uuid');
module.exports = {
posts: [],
settings: [],
roles: [],
permissions: [],
permissions_roles: []
};

View file

@ -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');

View 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;

View file

@ -4,10 +4,10 @@ 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.
currentVersion = "002"; currentVersion = '003';
function getCurrentVersion() { function getCurrentVersion() {
return knex.Schema.hasTable('settings').then(function () { return knex.Schema.hasTable('settings').then(function () {

View file

@ -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');
@ -16,7 +17,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();
} }
}); });

View file

@ -7,6 +7,7 @@ var Post,
Showdown = require('showdown'), Showdown = require('showdown'),
converter = new Showdown.converter(), converter = new Showdown.converter(),
User = require('./user').User, User = require('./user').User,
config = require('../../../config'),
GhostBookshelf = require('./base'); GhostBookshelf = require('./base');
Post = GhostBookshelf.Model.extend({ Post = GhostBookshelf.Model.extend({
@ -18,8 +19,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
}; };
}, },

View file

@ -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) {

View file

@ -19,6 +19,7 @@
"underscore": "1.5.1", "underscore": "1.5.1",
"showdown": "0.3.1", "showdown": "0.3.1",
"sqlite3": "2.1.14", "sqlite3": "2.1.14",
"mysql": "~2.0.0-alpha8",
"bookshelf": "0.2.4", "bookshelf": "0.2.4",
"knex": "0.1.8", "knex": "0.1.8",
"when": "2.2.1", "when": "2.2.1",