How to use the keystone.View function in keystone

To help you get started, we’ve selected a few keystone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skagitpublishing / connextCMS / routes / views / edituser.js View on Github external
exports = module.exports = function(req, res) {

        var view = new keystone.View(req, res);
        var locals = res.locals;

        locals.user = req.user;
        locals.user.password = "";

        locals.superusers = keystone.get('superusers');
  
        // Set locals
        locals.section = 'edituser';

        // Render the view
        view.render('edituser');

};
github JedWatson / sydjs-site / routes / views / organisations.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res),
		locals = res.locals;
	
	// locals.section = 'members';
	
	view.query('organisations', Organisation.model.find().sort('name'), 'members');
	
	view.render('site/organisations');
	
}
github JedWatson / sydjs-site / routes / views / member.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res),
		locals = res.locals;
	
	locals.section = 'members';
	locals.moment = moment;


	// Load the Member

	view.on('init', function(next) {
		User.model.findOne()
		.where('key', req.params.member)
		.exec(function(err, member) {
			if (err) return res.err(err);
			if (!member) {
				req.flash('info', 'Sorry, we couldn\'t find a matching member');
				return res.redirect('/members')
github keystonejs / generator-keystone / app / templates / routes / views / contact.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res);
	var locals = res.locals;
	
	// Set locals
	locals.section = 'contact';
	locals.enquiryTypes = Enquiry.fields.enquiryType.ops;
	locals.formData = req.body || {};
	locals.validationErrors = {};
	locals.enquirySubmitted = false;
	
	// On POST requests, add the Enquiry item to the database
	view.on('post', { action: 'contact' }, function(next) {
		
		var newEnquiry = new Enquiry.model(),
			updater = newEnquiry.getUpdateHandler(req);
		
		updater.process(req.body, {
github keystonejs / keystone-starter / routes / views / index.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res);
	var locals = res.locals;
	
	// locals.section is used to set the currently selected
	// item in the header navigation.
	locals.section = 'home';
	
	// Render the view
	view.render('index');
	
};
github skagitpublishing / connextCMS / routes / views / resetpassword.js View on Github external
exports = module.exports = function(req, res) { 

        var view = new keystone.View(req, res);
        var locals = res.locals;

        locals.user = req.user;
        //locals.user.password = "";

        locals.superusers = keystone.get('superusers');
  
        // Set locals
        locals.section = 'resetpassword';

        // Render the view
        view.render('resetpassword');

};
github JedWatson / sydjs-site / routes / views / meetup.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res),
		locals = res.locals;
	
	locals.section = 'meetups';
	locals.page.title = 'Meetups - SydJS';
	
	locals.rsvpStatus = {};
	
	
	// LOAD the Meetup
	
	view.on('init', function(next) {
		Meetup.model.findOne()
			.where('key', req.params.meetup)
			.exec(function(err, meetup) {
				
				if (err) return res.err(err);
github JedWatson / keystone-forum / routes / views / forgot-password.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res),
		locals = res.locals;
	
	view.on('post', { action: 'send-password' }, function(next) {
		
		User.model.findOne().where('email', req.body.email).exec(function(err, user) {
			if (err) return next(err);
			
			if (!user) {
				req.flash('error', "Sorry, we don't recognise that email address.");
				return next();
			}
			
			user.resetPassword(function(err) {
				if (err) {
					console.error("===== Reset Password failed to send email =====");
					console.error(err);
github JedWatson / sydjs-site / routes / views / me.js View on Github external
exports = module.exports = function(req, res) {
	
	var view = new keystone.View(req, res),
		locals = res.locals;
	
	locals.section = 'me';
	locals.page.title = 'Settings - SydJS';
	
	view.query('nextMeetup',
		Meetup.model.findOne()
			.where('state', 'active')
			.sort('startDate')
	, 'talks[who]');
	
	view.query('rsvps.history',
		RSVP.model.find()
			.where('who', req.user)
			.where('attending', true)
			.populate('meetup')