From 212521712dc47f420f2c3885b349cd1a21b8863b Mon Sep 17 00:00:00 2001 From: Sebastian Gierlinger Date: Wed, 11 Sep 2013 17:23:07 +0200 Subject: [PATCH] Clean up config (drop 'env') closes #628 - removed .env from config.js - ghost.config() returns correct config for NODE_ENV - removed .env[process.env.NODE_ENV] - updated tests - deleted users.hbs, plugins.hbs, appearance.hbs (forgot to delete in PR #649) --- config.js | 6 +- core/client/tpl/settings/appearance.hbs | 11 - core/client/tpl/settings/plugins.hbs | 241 -------------------- core/client/tpl/settings/users.hbs | 57 ----- core/client/views/settings.js | 28 --- core/ghost.js | 4 +- core/server/controllers/admin.js | 4 +- core/server/controllers/frontend.js | 2 +- core/server/helpers/index.js | 2 +- core/server/mail.js | 4 +- core/server/models/base.js | 2 +- core/test/unit/mail_spec.js | 12 +- core/test/unit/server_helpers_index_spec.js | 5 +- index.js | 8 +- 14 files changed, 23 insertions(+), 363 deletions(-) delete mode 100644 core/client/tpl/settings/appearance.hbs delete mode 100644 core/client/tpl/settings/plugins.hbs delete mode 100644 core/client/tpl/settings/users.hbs diff --git a/config.js b/config.js index b6ec04cc86..d811592dca 100644 --- a/config.js +++ b/config.js @@ -1,11 +1,11 @@ // # Ghost Configuration var path = require('path'), - config = {}; + config = {}; // ## Environment // **Warning:** Only change the settings below here if you are sure of what you are doing! -config.env = { +config = { testing: { database: { client: 'sqlite3', @@ -99,4 +99,4 @@ config.env = { }; // Export config -module.exports = config; +module.exports = config; \ No newline at end of file diff --git a/core/client/tpl/settings/appearance.hbs b/core/client/tpl/settings/appearance.hbs deleted file mode 100644 index fadb08597d..0000000000 --- a/core/client/tpl/settings/appearance.hbs +++ /dev/null @@ -1,11 +0,0 @@ -
-
-

Appearance

-
-
-
Raw json be here
-

Active theme: {{json settings.activeTheme}}

-

Available themes: {{json availableThemes}}

-

Available plugins: {{json availablePlugins}}

-
-
\ No newline at end of file diff --git a/core/client/tpl/settings/plugins.hbs b/core/client/tpl/settings/plugins.hbs deleted file mode 100644 index fc4b3c7a23..0000000000 --- a/core/client/tpl/settings/plugins.hbs +++ /dev/null @@ -1,241 +0,0 @@ - -
-

Plugins

-
- -
-
-
-
-
-

Updates

-
- - - - - - - - - - - - - - - - - -
-
- -
-
- Ghost SEO - - - -
-
-
- Yoast - yoast.com -
-
-
- v 0.1.13 - 3 weeks ago -
-
-
- - - - - - - - 48,200 users -
-
-
- -
-
-
- -
-
- Ghost SEO - The #1 content marketing plugin for Ghost. -
-
-
- Yoast - yoast.com -
-
-
- v 0.1.13 - 3 weeks ago -
-
-
- - - - - - - - 48,200 users -
-
-
- -
-
-
- -
-
-
-
-

Active Plugins

-
- - - - - - - - - - - - - - - - - -
-
- -
-
- Ghost SEO - The #1 content marketing plugin for Ghost. -
-
-
- Yoast - yoast.com -
-
-
- v 0.1.13 - 3 weeks ago -
-
-
- - - - - - - - 48,200 users -
-
-
- -
-
-
- -
-
- Ghost SEO - The #1 content marketing plugin for Ghost. -
-
-
- Yoast - yoast.com -
-
-
- v 0.1.13 - 3 weeks ago -
-
-
- - - - - - - - 48,200 users -
-
-
- -
-
-
-
-
-

Inactive Plugins

-
- - - - - - - - - - -
-
- -
-
- Ghost SEO - The #1 content marketing plugin for Ghost. -
-
-
- Yoast - yoast.com -
-
-
- v 0.1.13 - 3 weeks ago -
-
-
- - - - - - - - 48,200 users -
-
-
- -
-
-
-
\ No newline at end of file diff --git a/core/client/tpl/settings/users.hbs b/core/client/tpl/settings/users.hbs deleted file mode 100644 index ae3ef9629a..0000000000 --- a/core/client/tpl/settings/users.hbs +++ /dev/null @@ -1,57 +0,0 @@ -
-
-

Users

-
- -
-
-
-
-

Invited Users

-
    -
  • -
    -
    -

    Some Name

    - Invitation Sent: 7 hours ago -
    -
  • -
-
-
-
-

Active Users

- - -
- -
    -
  • -
    - user -
    -
    -

    Some Name

    - Last Seen: 7 hours ago -
    - Admin -
  • -
  • -
    - user -
    -
    -

    Some Name

    - Last Seen: 2 days ago -
    - Editor -
  • -
-
-
-
\ No newline at end of file diff --git a/core/client/views/settings.js b/core/client/views/settings.js index 406c71c4ed..9396783597 100644 --- a/core/client/views/settings.js +++ b/core/client/views/settings.js @@ -337,32 +337,4 @@ } }); - // ### User settings - Settings.users = Settings.Pane.extend({ - id: 'users', - events: { - } - }); - - // ### Appearance settings - Settings.appearance = Settings.Pane.extend({ - id: 'appearance', - events: { - } - }); - - // ### Services settings - Settings.services = Settings.Pane.extend({ - id: 'services', - events: { - } - }); - - // ### Plugins settings - Settings.plugins = Settings.Pane.extend({ - id: 'plugins', - events: { - } - }); - }()); diff --git a/core/ghost.js b/core/ghost.js index b9ce482079..0e312416dd 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -93,7 +93,7 @@ Ghost = function () { _.extend(instance, { app: function () { return app; }, - config: function () { return config; }, + config: function () { return config[process.env.NODE_ENV]; }, // there's no management here to be sure this has loaded settings: function () { return instance.settingsCache; }, @@ -102,7 +102,7 @@ Ghost = function () { /* this is a bit of a hack until we have a better way to combine settings and config * this data is what becomes globally available to themes */ return { - url: instance.config().env[process.env.NODE_ENV].url, + url: instance.config().url, title: instance.settings().title, description: instance.settings().description, logo: instance.settings().logo, diff --git a/core/server/controllers/admin.js b/core/server/controllers/admin.js index 0ac7f131ff..8eabae3a46 100644 --- a/core/server/controllers/admin.js +++ b/core/server/controllers/admin.js @@ -200,8 +200,8 @@ adminControllers = { html: "

Hello!

" + "

You've reset your password. Here's the new one: " + user.newPassword + "

" + "

Ghost
" + - '' + - ghost.config().env[process.env.NODE_ENV].url + '

' + '' + + ghost.config().url + '

' }; return ghost.mail.send(message); diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js index 8f465b595e..bbcc33c9f5 100644 --- a/core/server/controllers/frontend.js +++ b/core/server/controllers/frontend.js @@ -65,7 +65,7 @@ frontendControllers = { }, 'rss': function (req, res) { // Initialize RSS - var siteUrl = ghost.config().env[process.env.NODE_ENV].url, + var siteUrl = ghost.config().url, feed = new RSS({ title: ghost.settings().title, description: ghost.settings().description, diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index a129ae75cd..a611c79944 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -68,7 +68,7 @@ coreHelpers = function (ghost) { var output = ''; if (options && options.hash.absolute) { - output += ghost.config().env[process.env.NODE_ENV].url; + output += ghost.config().url; } if (models.isPost(this)) { diff --git a/core/server/mail.js b/core/server/mail.js index b3e9723d6a..0a54bc8ab3 100644 --- a/core/server/mail.js +++ b/core/server/mail.js @@ -18,7 +18,7 @@ GhostMailer.prototype.init = function (ghost) { this.api = require('./api'); var self = this, - config = ghost.config().env[process.env.NODE_ENV]; + config = ghost.config(); if (config.mail && config.mail.transport && config.mail.options) { this.createTransport(config); @@ -96,7 +96,7 @@ GhostMailer.prototype.send = function (message) { return when.reject(new Error('Email Error: Incomplete message data.')); } - var from = 'ghost-mailer@' + url.parse(this.ghost.config().env[process.env.NODE_ENV].url).hostname, + var from = 'ghost-mailer@' + url.parse(this.ghost.config().hostname), to = message.to || this.ghost.settings().email, sendMail = nodefn.lift(this.transport.sendMail.bind(this.transport)); diff --git a/core/server/models/base.js b/core/server/models/base.js index 911a216541..a42bc8ac73 100644 --- a/core/server/models/base.js +++ b/core/server/models/base.js @@ -6,7 +6,7 @@ var GhostBookshelf, // Initializes Bookshelf as its own instance, so we can modify the Models and not mess up // others' if they're using the library outside of ghost. -GhostBookshelf = Bookshelf.Initialize('ghost', config.env[process.env.NODE_ENV || 'development'].database); +GhostBookshelf = Bookshelf.Initialize('ghost', config[process.env.NODE_ENV || 'development'].database); GhostBookshelf.validator = new Validator(); diff --git a/core/test/unit/mail_spec.js b/core/test/unit/mail_spec.js index f1986828a7..151cf7f495 100644 --- a/core/test/unit/mail_spec.js +++ b/core/test/unit/mail_spec.js @@ -80,7 +80,7 @@ describe("Mail", function () { }); it('should setup SMTP transport on initialization', function (done) { - fakeConfig.env[process.env.NODE_ENV].mail = SMTP; + fakeConfig.mail = SMTP; ghost.mail.init(ghost).then(function(){ ghost.mail.should.have.property('transport'); ghost.mail.transport.transportType.should.eql('SMTP'); @@ -90,7 +90,7 @@ describe("Mail", function () { }); it('should setup sendmail transport on initialization', function (done) { - fakeConfig.env[process.env.NODE_ENV].mail = SENDMAIL; + fakeConfig.mail = SENDMAIL; ghost.mail.init(ghost).then(function(){ ghost.mail.should.have.property('transport'); ghost.mail.transport.transportType.should.eql('SENDMAIL'); @@ -100,7 +100,7 @@ describe("Mail", function () { }); it('should fallback to sendmail if no config set', function (done) { - fakeConfig.env[process.env.NODE_ENV].mail = null; + fakeConfig.mail = null; ghost.mail.init(ghost).then(function(){ ghost.mail.should.have.property('transport'); ghost.mail.transport.transportType.should.eql('SENDMAIL'); @@ -110,7 +110,7 @@ describe("Mail", function () { }); it('should fallback to sendmail if config is empty', function (done) { - fakeConfig.env[process.env.NODE_ENV].mail = {}; + fakeConfig.mail = {}; ghost.mail.init(ghost).then(function(){ ghost.mail.should.have.property('transport'); ghost.mail.transport.transportType.should.eql('SENDMAIL'); @@ -120,7 +120,7 @@ describe("Mail", function () { }); it('should disable transport if config is empty & sendmail not found', function (done) { - fakeConfig.env[process.env.NODE_ENV].mail = {}; + fakeConfig.mail = {}; ghost.mail.detectSendmail.restore(); sandbox.stub(ghost.mail, "detectSendmail", when.reject); ghost.mail.init(ghost).then(function(){ @@ -130,7 +130,7 @@ describe("Mail", function () { }); it('should disable transport if config is empty & platform is win32', function (done) { - fakeConfig.env[process.env.NODE_ENV].mail = {}; + fakeConfig.mail = {}; ghost.mail.detectSendmail.restore(); ghost.mail.isWindows.restore(); sandbox.stub(ghost.mail, 'isWindows', function(){ return true }); diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js index 001230b84f..632c77e7e0 100644 --- a/core/test/unit/server_helpers_index_spec.js +++ b/core/test/unit/server_helpers_index_spec.js @@ -220,10 +220,7 @@ describe('Core Helpers', function () { it('should output an absolute URL if the option is present', function () { var configStub = sinon.stub(ghost, "config", function () { - return {env: { - testing: { url: 'http://testurl.com' }, - travis: { url: 'http://testurl.com' } - }}; + return { url: 'http://testurl.com' }; }), rendered = handlebars.helpers.url.call( diff --git a/index.js b/index.js index 240f501db8..cbb7e151fd 100644 --- a/index.js +++ b/index.js @@ -244,8 +244,8 @@ when.all([ghost.init(), helpers.loadCoreHelpers(ghost)]).then(function () { // ## Start Ghost App ghost.app().listen( - ghost.config().env[process.env.NODE_ENV].server.port, - ghost.config().env[process.env.NODE_ENV].server.host, + ghost.config().server.port, + ghost.config().server.host, function () { // Tell users if their node version is not supported, and exit @@ -270,8 +270,8 @@ when.all([ghost.init(), helpers.loadCoreHelpers(ghost)]).then(function () { // Startup message console.log("Express server listening on address:", - ghost.config().env[process.env.NODE_ENV].server.host + ':' - + ghost.config().env[process.env.NODE_ENV].server.port); + ghost.config().server.host + ':' + + ghost.config().server.port); // Let everyone know we have finished loading loading.resolve();