Merge pull request #4531 from Gargol/issue-4485

Cleans up HTML data attributes on body in default.hbs
This commit is contained in:
Hannah Wolfe 2014-12-01 10:54:19 +00:00
commit 4b71aeeddb
2 changed files with 40 additions and 9 deletions

View File

@ -1,16 +1,11 @@
import getConfig from 'ghost/utils/config-parser';
var ConfigInitializer = { var ConfigInitializer = {
name: 'config', name: 'config',
initialize: function (container, application) { initialize: function (container, application) {
var apps = $('body').data('apps'), var config = getConfig();
tagsUI = $('body').data('tagsui'), application.register('ghost:config', config, {instantiate: false});
fileStorage = $('body').data('filestorage'),
blogUrl = $('body').data('blogurl'),
blogTitle = $('body').data('blogtitle');
application.register(
'ghost:config', {apps: apps, fileStorage: fileStorage, blogUrl: blogUrl, tagsUI: tagsUI, blogTitle: blogTitle}, {instantiate: false}
);
application.inject('route', 'config', 'ghost:config'); application.inject('route', 'config', 'ghost:config');
application.inject('controller', 'config', 'ghost:config'); application.inject('controller', 'config', 'ghost:config');

View File

@ -0,0 +1,36 @@
var isNumeric = function (num) {
return !isNaN(num);
},
_mapType = function (val) {
if (val === '') {
return null;
} else if (val === 'true') {
return true;
} else if (val === 'false') {
return false;
} else if (isNumeric(val)) {
return +val;
} else {
return val;
}
},
parseConfiguration = function () {
var metaConfigTags = $('meta[name^="env-"]'),
propertyName,
config = {},
value,
key,
i;
for (i = 0; i < metaConfigTags.length; i += 1) {
key = $(metaConfigTags[i]).prop('name');
value = $(metaConfigTags[i]).prop('content');
propertyName = key.substring(4); // produce config name ignoring the initial 'env-'.
config[propertyName] = _mapType(value); // map string values to types if possible
}
return config;
};
export default parseConfiguration;