mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
71c358b638
No Issue - Switches to the newer style of dependency injection. - Instead of injection Controllers via "needs," use Ember.inject.controller(). - Get rid of initializers that were only injecting objects into various factories. Converts these objects into Ember.Service objects and declaratively inject them where needed via Ember.inject.service(). The added benefit to this is that it's no longer a mystery where these properties/methods come from and it's straightforward to inject them where needed.
44 lines
983 B
JavaScript
44 lines
983 B
JavaScript
import Ember from 'ember';
|
|
|
|
function isNumeric(num) {
|
|
return !isNaN(num);
|
|
}
|
|
|
|
function _mapType(val) {
|
|
if (val === '') {
|
|
return null;
|
|
} else if (val === 'true') {
|
|
return true;
|
|
} else if (val === 'false') {
|
|
return false;
|
|
} else if (isNumeric(val)) {
|
|
return +val;
|
|
} else if (val.indexOf('{') === 0) {
|
|
try {
|
|
return JSON.parse(val);
|
|
} catch (e) {
|
|
/*jshint unused:false */
|
|
return val;
|
|
}
|
|
} else {
|
|
return val;
|
|
}
|
|
}
|
|
|
|
export default Ember.Service.extend(Ember._ProxyMixin, {
|
|
content: Ember.computed(function () {
|
|
var metaConfigTags = Ember.$('meta[name^="env-"]'),
|
|
config = {};
|
|
|
|
metaConfigTags.each(function (i, el) {
|
|
var key = el.name,
|
|
value = el.content,
|
|
propertyName = key.substring(4);
|
|
|
|
config[propertyName] = _mapType(value);
|
|
});
|
|
|
|
return config;
|
|
})
|
|
});
|