2015-05-11 12:15:10 +09:00
|
|
|
Pages = new Mongo.Collection('pages');
|
2015-04-22 07:50:11 +09:00
|
|
|
|
2015-07-08 15:37:55 +09:00
|
|
|
Telescope.subscriptions.preload('pages');
|
|
|
|
|
2015-05-11 12:15:10 +09:00
|
|
|
Pages.schema = new SimpleSchema({
|
2015-04-22 07:50:11 +09:00
|
|
|
title: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
slug: {
|
|
|
|
type: String,
|
|
|
|
optional: true
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
type: String,
|
|
|
|
autoform: {
|
|
|
|
rows: 10
|
|
|
|
}
|
|
|
|
},
|
|
|
|
order: {
|
|
|
|
type: Number,
|
|
|
|
optional: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-05-11 12:15:10 +09:00
|
|
|
Pages.schema.internationalize();
|
2015-04-27 09:55:29 +09:00
|
|
|
|
2015-05-11 12:15:10 +09:00
|
|
|
Pages.attachSchema(Pages.schema);
|
2015-04-22 07:50:11 +09:00
|
|
|
|
2015-05-11 12:15:10 +09:00
|
|
|
Pages.before.insert(function (userId, doc) {
|
2015-04-22 07:50:11 +09:00
|
|
|
// if no slug has been provided, generate one
|
|
|
|
if (!doc.slug)
|
|
|
|
doc.slug = Telescope.utils.slugify(doc.title);
|
|
|
|
});
|
|
|
|
|
2015-05-17 15:38:02 +09:00
|
|
|
Telescope.modules.add("primaryNav", {
|
2015-05-18 10:30:08 +09:00
|
|
|
template: "pages_menu",
|
2015-04-22 07:50:11 +09:00
|
|
|
order: 5
|
|
|
|
});
|
|
|
|
|
2015-05-17 15:38:02 +09:00
|
|
|
Telescope.modules.add("mobileNav", {
|
2015-05-18 10:30:08 +09:00
|
|
|
template: 'pages_menu',
|
2015-04-22 07:50:11 +09:00
|
|
|
order: 5
|
|
|
|
});
|
|
|
|
|
|
|
|
Meteor.startup(function () {
|
2015-05-11 12:15:10 +09:00
|
|
|
Pages.allow({
|
2015-04-27 17:14:07 +09:00
|
|
|
insert: Users.is.adminById,
|
|
|
|
update: Users.is.adminById,
|
|
|
|
remove: Users.is.adminById
|
2015-04-22 07:50:11 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
Meteor.methods({
|
|
|
|
insertPage: function(pageTitle, pageContent){
|
2015-07-10 11:40:11 +09:00
|
|
|
check(pageTitle, String);
|
|
|
|
check(pageContent, String);
|
2015-04-22 07:50:11 +09:00
|
|
|
return Feeds.insert({title: pageTitle, content: pageContent});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|