Vulcan/collections/settings.js

195 lines
3.7 KiB
JavaScript
Raw Normal View History

2014-09-17 21:11:59 +02:00
settingsSchemaObject = {
2014-07-06 14:09:55 +09:00
title: {
type: String,
label: "Title",
optional: true
},
siteUrl: {
type: String,
2014-07-18 09:21:45 +09:00
optional: true,
2014-08-20 15:59:11 +09:00
label: 'Site URL (with trailing "/")'
2014-07-06 14:09:55 +09:00
},
tagline: {
type: String,
label: "Tagline",
optional: true
},
requireViewInvite: {
type: Boolean,
label: "Require invite to view",
optional: true
},
requirePostInvite: {
type: Boolean,
label: "Require invite to post",
optional: true
},
requirePostsApproval: {
type: Boolean,
label: "Posts must be approved by admin",
optional: true
},
emailNotifications: {
type: Boolean,
label: "Enable email notifications",
optional: true
},
nestedComments: {
type: Boolean,
label: "Enable nested comments",
optional: true
},
redistributeKarma: {
type: Boolean,
label: "Enable redistributed karma",
optional: true
},
defaultEmail: {
type: String,
optional: true
},
scoreUpdateInterval: {
type: Number,
optional: true
},
2014-08-28 10:16:17 +09:00
defaultView: {
type: String,
optional: true,
autoform: {
options: _.map(viewNav, function (view) {
return {
value: camelCaseify(view.label),
label: view.label
}
})
}
2014-08-28 10:16:17 +09:00
},
2014-07-06 14:09:55 +09:00
postInterval: {
type: Number,
optional: true
},
commentInterval: {
type: Number,
optional: true
},
maxPostsPerDay: {
type: Number,
optional: true
},
startInvitesCount: {
type: Number,
defaultValue: 3,
optional: true
},
postsPerPage: {
type: Number,
defaultValue: 10,
optional: true
},
logoUrl: {
type: String,
optional: true
},
logoHeight: {
2014-06-22 10:58:02 +09:00
type: Number,
optional: true
2014-07-06 14:09:55 +09:00
},
logoWidth: {
2014-06-22 10:58:02 +09:00
type: Number,
optional: true
2014-07-06 14:09:55 +09:00
},
language: {
type: String,
defaultValue: 'en',
optional: true
},
2014-07-11 10:54:07 +09:00
backgroundCSS: {
2014-07-06 14:09:55 +09:00
type: String,
2014-07-11 10:54:07 +09:00
optional: true,
label: "Background CSS: color, image, etc."
2014-07-06 14:09:55 +09:00
},
2014-08-21 15:30:05 +09:00
// secondaryColor: {
// type: String,
// optional: true
// },
buttonColor: {
2014-07-06 14:09:55 +09:00
type: String,
optional: true
},
2014-08-21 15:30:05 +09:00
buttonTextColor: {
2014-07-06 14:09:55 +09:00
type: String,
optional: true
2014-08-21 15:30:05 +09:00
},
2014-07-06 14:09:55 +09:00
headerColor: {
type: String,
optional: true
},
2014-08-21 15:30:05 +09:00
headerTextColor: {
type: String,
optional: true
},
2014-07-06 14:09:55 +09:00
twitterAccount: {
type: String,
optional: true
},
googleAnalyticsId: {
type: String,
optional: true
},
mixpanelId: {
type: String,
optional: true
},
clickyId: {
type: String,
optional: true
},
footerCode: {
type: String,
optional: true
},
extraCode: {
type: String,
optional: true
},
2014-08-02 16:27:12 +09:00
emailFooter: {
type: String,
optional: true
},
2014-07-06 14:09:55 +09:00
notes: {
type: String,
optional: true
2014-08-02 16:27:12 +09:00
}
2014-09-17 21:11:59 +02:00
};
2014-07-06 14:09:55 +09:00
// add any extra properties to settingsSchemaObject (provided by packages for example)
_.each(addToSettingsSchema, function(item){
settingsSchemaObject[item.propertyName] = item.propertySchema;
});
Settings = new Meteor.Collection("settings");
2014-09-17 21:13:20 +02:00
SettingsSchema = new SimpleSchema(settingsSchemaObject);
Settings.attachSchema(SettingsSchema);
2013-07-04 12:51:26 +09:00
Settings.allow({
2014-06-22 10:58:02 +09:00
insert: isAdminById,
update: isAdminById,
remove: isAdminById
2013-07-04 12:51:26 +09:00
});
var query = Settings.find();
var handle = query.observeChanges({
added: function (id, fields) {
console.log('Added document to settings');
console.log(fields);
if (fields.language)
T9n.language = fields.language;
},
changed: function (id, fields) {
console.log('Changed document inside settings');
console.log(fields);
if (fields.language)
T9n.language = fields.language;
}
});