mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Merge pull request #4531 from Gargol/issue-4485
Cleans up HTML data attributes on body in default.hbs
This commit is contained in:
commit
4b71aeeddb
@ -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');
|
||||||
|
36
ghost/admin/utils/config-parser.js
Normal file
36
ghost/admin/utils/config-parser.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user