Vulcan/packages/nova-lib/lib/settings.js

28 lines
873 B
JavaScript
Raw Normal View History

2016-02-16 15:08:30 +09:00
Telescope.settings = {};
Telescope.settings.get = function(setting, defaultValue) {
2016-04-11 10:23:23 +09:00
const collection = Telescope.settings.collection;
2016-02-16 15:08:30 +09:00
2016-04-11 10:23:23 +09:00
if (Meteor.isServer && Meteor.settings && typeof Meteor.settings[setting] !== "undefined") { // if on the server, look in Meteor.settings
2016-02-16 15:08:30 +09:00
return Meteor.settings[setting];
2016-04-11 10:23:23 +09:00
} else if (Meteor.settings && Meteor.settings.public && typeof Meteor.settings.public[setting] !== "undefined") { // look in Meteor.settings.public
2016-02-16 15:08:30 +09:00
return Meteor.settings.public[setting];
2016-04-11 10:23:23 +09:00
} else if (collection && collection.findOne() && typeof collection.findOne()[setting] !== "undefined") { // look in collection
return Telescope.settings.collection.findOne()[setting];
2016-02-16 15:08:30 +09:00
} else if (typeof defaultValue !== 'undefined') { // fallback to default
return defaultValue;
} else { // or return undefined
return undefined;
}
2016-02-17 14:39:56 +09:00
};