mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
✨ 🔦 add nconf files
refs #6982 - add defaults.json - add overrides.json - add env specific default values - add nconf wrapper in /config - add config utils in /config/utils.js [ci skip]
This commit is contained in:
parent
96203a46dc
commit
7d3e8fa8a9
9 changed files with 244 additions and 0 deletions
35
core/server/config/defaults.json
Normal file
35
core/server/config/defaults.json
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"url": "http://localhost:2368",
|
||||
"urlSSL": false,
|
||||
"forceAdminSSL": false,
|
||||
"server": {
|
||||
"host": "127.0.0.1",
|
||||
"port": 2368
|
||||
},
|
||||
"database": {
|
||||
"client": "sqlite3",
|
||||
"debug": false,
|
||||
"connection": {
|
||||
"filename": "content/data/ghost.db"
|
||||
}
|
||||
},
|
||||
"privacy": false,
|
||||
"paths": {
|
||||
"contentPath": "content/",
|
||||
"themePath": "content/themes/",
|
||||
"imagesPath": "content/images/",
|
||||
"appPath": "content/apps/",
|
||||
"storagePath": {
|
||||
"custom": "content/storage/"
|
||||
},
|
||||
"schedulingPath": "core/server/scheduling/"
|
||||
},
|
||||
"storage": {
|
||||
"active": {
|
||||
"images": "local-file-store"
|
||||
}
|
||||
},
|
||||
"scheduling": {
|
||||
"active": "SchedulingDefault"
|
||||
}
|
||||
}
|
12
core/server/config/env/config.development.json
vendored
Normal file
12
core/server/config/env/config.development.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"url": "http://localhost:2368",
|
||||
"database": {
|
||||
"connection": {
|
||||
"filename": "content/data/ghost-dev.db"
|
||||
},
|
||||
"debug": false
|
||||
},
|
||||
"paths": {
|
||||
"contentPath": "content/"
|
||||
}
|
||||
}
|
12
core/server/config/env/config.production.json
vendored
Normal file
12
core/server/config/env/config.production.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"url": "http://my-ghost-blog.com",
|
||||
"database": {
|
||||
"connection": {
|
||||
"filename": "content/data/ghost.db"
|
||||
},
|
||||
"debug": false
|
||||
},
|
||||
"paths": {
|
||||
"contentPath": "content/"
|
||||
}
|
||||
}
|
17
core/server/config/env/config.testing-mysql.json
vendored
Normal file
17
core/server/config/env/config.testing-mysql.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"url": "http://127.0.0.1:2369",
|
||||
"server": {
|
||||
"port": 2369
|
||||
},
|
||||
"database": {
|
||||
"client": "mysql",
|
||||
"connection": {
|
||||
"host" : "127.0.0.1",
|
||||
"user" : "root",
|
||||
"password" : "",
|
||||
"database" : "ghost_testing",
|
||||
"charset" : "utf8"
|
||||
}
|
||||
},
|
||||
"logging": false
|
||||
}
|
17
core/server/config/env/config.testing-pg.json
vendored
Normal file
17
core/server/config/env/config.testing-pg.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"url": "http://127.0.0.1:2369",
|
||||
"server": {
|
||||
"port": 2369
|
||||
},
|
||||
"database": {
|
||||
"client": "pg",
|
||||
"connection": {
|
||||
"host" : "127.0.0.1",
|
||||
"user" : "postgres",
|
||||
"password" : "",
|
||||
"database" : "ghost_testing",
|
||||
"charset" : "utf8"
|
||||
}
|
||||
},
|
||||
"logging": false
|
||||
}
|
13
core/server/config/env/config.testing.json
vendored
Normal file
13
core/server/config/env/config.testing.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"url": "http://127.0.0.1:2369",
|
||||
"database": {
|
||||
"connection": {
|
||||
"filename": "content/data/ghost-test.db"
|
||||
},
|
||||
"useNullAsDefault": true
|
||||
},
|
||||
"server": {
|
||||
"port": 2369
|
||||
},
|
||||
"logging": false
|
||||
}
|
32
core/server/config/index.js
Normal file
32
core/server/config/index.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
var nconf = require('nconf'),
|
||||
path = require('path'),
|
||||
localUtils = require('./utils'),
|
||||
env = process.env.NODE_ENV || 'development';
|
||||
|
||||
nconf.set('NODE_ENV', env);
|
||||
|
||||
/**
|
||||
* command line arguments
|
||||
*/
|
||||
nconf.argv();
|
||||
|
||||
/**
|
||||
* env arguments
|
||||
*/
|
||||
nconf.env();
|
||||
|
||||
/**
|
||||
* load config files
|
||||
*/
|
||||
nconf.file('1', __dirname + '/overrides.json');
|
||||
nconf.file('2', path.join(process.cwd(), 'config.' + env + '.json'));
|
||||
nconf.file('3', __dirname + '/env/config.' + env + '.json');
|
||||
nconf.file('4', __dirname + '/defaults.json');
|
||||
|
||||
/**
|
||||
* transform all relative paths to absolute paths
|
||||
*/
|
||||
localUtils.makePathsAbsolute.bind(nconf)();
|
||||
|
||||
module.exports = nconf;
|
||||
module.exports.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
|
69
core/server/config/overrides.json
Normal file
69
core/server/config/overrides.json
Normal file
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"ghostVersion": "0.10.1",
|
||||
"paths": {
|
||||
"appRoot": ".",
|
||||
"corePath": "core/",
|
||||
"internalAppPath": "core/server/apps/",
|
||||
"storagePath": {
|
||||
"default": "core/server/storage/"
|
||||
},
|
||||
"clientAssets": "core/built/assets",
|
||||
"imagesRelPath": "content/images",
|
||||
"helperTemplates": "core/server/helpers/tpl/",
|
||||
"adminViews": "core/server/views/"
|
||||
},
|
||||
"internalApps": [
|
||||
"private-blogging",
|
||||
"subscribers",
|
||||
"amp"
|
||||
],
|
||||
"routeKeywords": {
|
||||
"tag": "tag",
|
||||
"author": "author",
|
||||
"page": "page",
|
||||
"preview": "p",
|
||||
"private": "private",
|
||||
"subscribe": "subscribe",
|
||||
"amp": "amp"
|
||||
},
|
||||
"slugs": {
|
||||
"reserved": ["admin", "app", "apps", "archive", "archives", "categories",
|
||||
"category", "dashboard", "feed", "ghost-admin", "login", "logout",
|
||||
"page", "pages", "post", "posts", "public", "register", "setup",
|
||||
"signin", "signout", "signup", "user", "users", "wp-admin", "wp-login"],
|
||||
"protected": ["ghost", "rss", "amp"]
|
||||
},
|
||||
"uploads": {
|
||||
"subscribers": {
|
||||
"extensions": [".csv"],
|
||||
"contentTypes": ["text/csv", "application/csv", "application/octet-stream"]
|
||||
},
|
||||
"images": {
|
||||
"extensions": [".jpg", ".jpeg", ".gif", ".png", ".svg", ".svgz"],
|
||||
"contentTypes": ["image/jpeg", "image/png", "image/gif", "image/svg+xml"]
|
||||
},
|
||||
"db": {
|
||||
"extensions": [".json", ".zip"],
|
||||
"contentTypes": ["application/octet-stream", "application/json", "application/zip", "application/x-zip-compressed"]
|
||||
},
|
||||
"themes": {
|
||||
"extensions": [".zip"],
|
||||
"contentTypes": ["application/zip", "application/x-zip-compressed"]
|
||||
}
|
||||
},
|
||||
"storage": {
|
||||
"active": {
|
||||
"themes": "local-file-store"
|
||||
}
|
||||
},
|
||||
"times": {
|
||||
"cannotScheduleAPostBeforeInMinutes": 2,
|
||||
"publishAPostBySchedulerToleranceInMinutes": 2
|
||||
},
|
||||
"theme": {
|
||||
"timezone": "Etc/UTC"
|
||||
},
|
||||
"maintenance": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
37
core/server/config/utils.js
Normal file
37
core/server/config/utils.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
var path = require('path'),
|
||||
_ = require('lodash');
|
||||
|
||||
exports.isPrivacyDisabled = function isPrivacyDisabled(privacyFlag) {
|
||||
if (!this.get('privacy')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('privacy').useTinfoil === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.get('privacy')[privacyFlag] === false;
|
||||
};
|
||||
|
||||
/**
|
||||
* transform all relative paths to absolute paths
|
||||
* @TODO: imagesRelPath is a dirty little attribute (especially when looking at the usages)
|
||||
*/
|
||||
exports.makePathsAbsolute = function makePathsAbsolute(paths, parent) {
|
||||
var self = this;
|
||||
|
||||
if (!paths && !parent) {
|
||||
paths = this.get('paths');
|
||||
parent = 'paths';
|
||||
}
|
||||
|
||||
_.each(paths, function (configValue, pathsKey) {
|
||||
if (_.isObject(configValue)) {
|
||||
makePathsAbsolute.bind(self)(configValue, parent + ':' + pathsKey);
|
||||
} else {
|
||||
if (configValue[0] !== '/' && pathsKey !== 'imagesRelPath') {
|
||||
self.set(parent + ':' + pathsKey, path.join(__dirname + '/../../../', configValue));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Add table
Reference in a new issue