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)
This commit is contained in:
Sebastian Gierlinger 2013-09-11 17:23:07 +02:00 committed by Hannah Wolfe
parent cc785cc981
commit 212521712d
14 changed files with 23 additions and 363 deletions

View File

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

View File

@ -1,11 +0,0 @@
<section id="appearance" class="settings-content">
<header>
<h2 class="title">Appearance</h2>
</header>
<section class="content">
<h6 class="sub">Raw json be here</h6>
<p>Active theme: {{json settings.activeTheme}}</p>
<p>Available themes: {{json availableThemes}}</p>
<p>Available plugins: {{json availablePlugins}}</p>
</section>
</section>

View File

@ -1,241 +0,0 @@
<!-- id should be plugins-->
<header>
<h2 class="title">Plugins</h2>
<section class="page-actions">
<button class="button-add">Add Plugin</button>
</section>
</header>
<section class="content">
<section class="plugin-section">
<header class="plugin-section-header">
<h3>Updates</h3>
</header>
<table class="plugin-section-table">
<tbody>
<tr class="plugin-section-item">
<td>
<figure class="plugin-icon">
</figure>
<section class="plugin-meta">
<span class="plugin-title plugin-info">Ghost SEO</span>
<span class="plugin-download-progress" data-complete="45">
<span style="width: 45%"></span>
</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">Yoast</span>
<span class="plugin-sub-info">yoast.com</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">v 0.1.13</span>
<span class="plugin-sub-info">3 weeks ago</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info rating">
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span></span>
</span>
<span class="plugin-sub-info">48,200 users</span>
</section>
</td>
<td>
<section class="plugin-meta">
<button class="button-delete button-cancel">Cancel</button>
</section>
</td>
</tr>
<tr class="plugin-section-item">
<td>
<figure class="plugin-icon">
</figure>
<section class="plugin-meta">
<span class="plugin-title plugin-info">Ghost SEO</span>
<span class="plugin-sub-info">The #1 content marketing plugin for Ghost.</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">Yoast</span>
<span class="plugin-sub-info">yoast.com</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">v 0.1.13</span>
<span class="plugin-sub-info">3 weeks ago</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info rating">
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span></span>
</span>
<span class="plugin-sub-info">48,200 users</span>
</section>
</td>
<td>
<section class="plugin-meta">
<button class="button-save">Update</button>
</section>
</td>
</tr>
</tbody>
</table>
<footer class="plugin-section-footer">
<button class="button-alt button-update-all">Update All</button>
</footer>
</section>
<section class="plugin-section">
<header class="plugin-section-header">
<h3>Active Plugins</h3>
</header>
<table class="plugin-section-table">
<tbody>
<tr class="plugin-section-item">
<td>
<figure class="plugin-icon">
</figure>
<section class="plugin-meta">
<span class="plugin-title plugin-info">Ghost SEO</span>
<span class="plugin-sub-info">The #1 content marketing plugin for Ghost.</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">Yoast</span>
<span class="plugin-sub-info">yoast.com</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">v 0.1.13</span>
<span class="plugin-sub-info">3 weeks ago</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info rating">
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span></span>
</span>
<span class="plugin-sub-info">48,200 users</span>
</section>
</td>
<td>
<section class="plugin-meta">
<a href="#" class="plugin-settings-icon"></a>
</section>
</td>
</tr>
<tr class="plugin-section-item">
<td>
<figure class="plugin-icon">
</figure>
<section class="plugin-meta">
<span class="plugin-title plugin-info">Ghost SEO</span>
<span class="plugin-sub-info">The #1 content marketing plugin for Ghost.</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">Yoast</span>
<span class="plugin-sub-info">yoast.com</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">v 0.1.13</span>
<span class="plugin-sub-info">3 weeks ago</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info rating">
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span></span>
</span>
<span class="plugin-sub-info">48,200 users</span>
</section>
</td>
<td>
<section class="plugin-meta">
<a href="#" class="plugin-settings-icon"></a>
</section>
</td>
</tr>
</tbody>
</table>
</section>
<section class="plugin-section">
<header class="plugin-section-header">
<h3>Inactive Plugins</h3>
</header>
<table class="plugin-section-table">
<tbody>
<tr class="plugin-section-item inactive">
<td>
<figure class="plugin-icon">
</figure>
<section class="plugin-meta">
<span class="plugin-title plugin-info">Ghost SEO</span>
<span class="plugin-sub-info">The #1 content marketing plugin for Ghost.</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">Yoast</span>
<span class="plugin-sub-info">yoast.com</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info">v 0.1.13</span>
<span class="plugin-sub-info">3 weeks ago</span>
</section>
</td>
<td>
<section class="plugin-meta">
<span class="plugin-info rating">
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span class="active"></span>
<span></span>
</span>
<span class="plugin-sub-info">48,200 users</span>
</section>
</td>
<td>
<section class="plugin-meta">
<button class="button-add">Activate</button>
</section>
</td>
</tr>
</tbody>
</table>
</section>
</section>

View File

@ -1,57 +0,0 @@
<section id="users" class="settings-content">
<header>
<h2 class="title">Users</h2>
<section class="page-actions">
<button class="button-add">New User</button>
</section>
</header>
<section class="content">
<section id="users-pending" class="user-group">
<header class="user-group-header"><h3>Invited Users</h3></header>
<ul class="users">
<li class="user">
<figure class="user-image invite"></figure>
<section class="user-meta">
<h4 class="user-name">Some Name</h4>
<span class="user-last-seen">Invitation Sent: 7 hours ago</span>
</section>
</li>
</ul>
</section>
<section id="users-active" class="user-group">
<header class="user-group-header">
<h3>Active Users</h3>
<form class="user-search">
<label>
<i class="search-icon"></i>
<input class="user-search-input" type="text"/>
</label>
</form>
</header>
<ul class="users">
<li class="user">
<figure class="user-image">
<img src="/public/img/user.jpg" alt="user"/>
</figure>
<section class="user-meta">
<h4 class="user-name">Some Name</h4>
<span class="user-last-seen">Last Seen: 7 hours ago</span>
</section>
<span class="user-role admin">Admin</span>
</li>
<li class="user">
<figure class="user-image">
<img src="/public/img/user.jpg" alt="user"/>
</figure>
<section class="user-meta">
<h4 class="user-name">Some Name</h4>
<span class="user-last-seen">Last Seen: 2 days ago</span>
</section>
<span class="user-role editor">Editor</span>
</li>
</ul>
</section>
</section>
</section>

View File

@ -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: {
}
});
}());

View File

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

View File

@ -200,8 +200,8 @@ adminControllers = {
html: "<p><strong>Hello!</strong></p>" +
"<p>You've reset your password. Here's the new one: " + user.newPassword + "</p>" +
"<p>Ghost <br/>" +
'<a href="' + ghost.config().env[process.env.NODE_ENV].url + '">' +
ghost.config().env[process.env.NODE_ENV].url + '</a></p>'
'<a href="' + ghost.config().url + '">' +
ghost.config().url + '</a></p>'
};
return ghost.mail.send(message);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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