Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
view.on('render', function(next) {
locals.title = locals.topic.name;
locals.metadescription = keystone.utils.cropString(keystone.utils.htmlToText(locals.topic.content.html), 200, '...', true);
locals.topic.populate('watchedBy');
for (var i = 0; i < locals.topic.watchedBy.length; i++) {
if (req.user && req.user.id == locals.topic.watchedBy[i]) {
locals.watchedByUser = true;
break;
}
}
// add this topic to the session's viewed topics array
if (!_.contains(req.session.viewedTopics, locals.topic.id)) {
req.session.viewedTopics.push(locals.topic.id);
}
'cloudinary config': process.env.CLOUDINARY_URL || 'cloudinary://333779167276662:_8jbSi9FB3sWYrfimcl8VKh34rI@keystone-demo'
});
// Load your project's Models
keystone.import('models');
// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js
keystone.set('locals', {
_: require('lodash'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable
});
// Load your project's Routes
keystone.set('routes', require('./routes'));
// Setup common locals for your emails. The following are required by Keystone's
// default email templates, you may remove them if you're using your own.
// Configure the navigation bar in Keystone's Admin UI
keystone.set('nav', {
'posts': ['posts', 'post-categories'],
'galleries': 'galleries',
'enquiries': 'enquiries',
User.schema.methods.verifyEmail = function(req, res, next) {
var user = this;
user.emailVerificationKey = keystone.utils.randomString([16,24]);
user.save(function(err) {
if (err) return next(err);
// send email
new keystone.Email('verify-email').send({
user: user,
link: '/auth/verify/?email=' + user.email + '&key=' + user.emailVerificationKey,
subject: 'Please confirm your email address',
baseURL: req.protocol + '://' + req.get('host'),
to: user.email,
from: {
name: 'KeystoneJS Forum',
email: 'forum@keystonejs.com'
}
'cookie secret': 'Y43`>-nb]).#N>)65(HY:TT])f?/:%=W~c"eTHY[`S.CarRf]9VaOw^$aMM[EtGz'
});
// Load your project's Models
keystone.import('models');
// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js
keystone.set('locals', {
_: require('underscore'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable
});
// Load your project's Routes
keystone.set('routes', require('./routes'));
// Setup common locals for your emails. The following are required by Keystone's
// default email templates, you may remove them if you're using your own.
keystone.set('email locals', {
logo_src: '/images/logo-email.gif',
logo_width: 194,
logo_height: 76,
theme: {
email_bg: '#f9f9f9',
'basedir': __dirname
});
keystone.import('models');
keystone.set('routes', require('./routes'));
keystone.set('locals', {
_: require('lodash'),
moment: require('moment'),
js: 'javascript:;',
env: keystone.get('env'),
utils: keystone.utils,
plural: keystone.utils.plural,
editable: keystone.content.editable,
google_api_key: keystone.get('google api key'),
ga_property: keystone.get('ga property'),
ga_domain: keystone.get('ga domain'),
// host: (function() {
// if (keystone.get('env') === 'staging') return 'http://sydjs-beta.herokuapp.com';
// if (keystone.get('env') === 'production') return 'http://www.sydjs.com';
// return (keystone.get('host') || 'http://localhost:') + (keystone.get('port') || '3000');
// })()
});
keystone.set('nav', {
'meetups': ['meetups', 'talks', 'rsvps'],
'members': ['users', 'organisations'],
'posts': ['posts', 'post-categories', 'post-comments'],
'links': ['links', 'link-tags', 'link-comments']
'user model': 'User'
});
// Load your project's Models
keystone.import('models');
// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js
keystone.set('locals', {
_: require('underscore'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable
});
// Load your project's Routes
keystone.set('routes', require('./routes'));
// Configure the navigation bar in Keystone's Admin UI
keystone.set('nav', {
'posts': ['posts', 'post-categories'],
'teams': 'teams',
'users': 'users'
});
// Start Keystone to connect to your database and initialise the web server
'mongo' : config.mongo.uri,
'auto update': false,
'session': true,
'auth': true,
'user model': 'Admin',
'cookie secret': srs(64),
});
keystone.import('models');
keystone.set('locals', {
_: require('underscore'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable,
});
keystone.set('routes', require('./routes'));
keystone.set('nav', {
'apps': 'apps',
'pages': ['Page', 'Media'],
'votes': ['Vote', 'Ballot', 'Source', 'VerifiedBallot'],
});
keystone.start();
'chartbeat property': process.env.CHARTBEAT_PROPERTY,
'chartbeat domain': process.env.CHARTBEAT_DOMAIN
});
keystone.import('models');
keystone.set('routes', require('./routes'));
keystone.set('locals', {
_: require('underscore'),
globals: require('./lib/globals'),
js: 'javascript:;',
env: keystone.get('env'),
utils: keystone.utils,
plural: keystone.utils.plural,
config: require('./config'),
google_api_key: keystone.get('google api key'),
ga_property: keystone.get('ga property'),
ga_domain: keystone.get('ga domain'),
chartbeat_property: keystone.get('chartbeat property'),
chartbeat_domain: keystone.get('chartbeat domain')
});
keystone.set('email locals', {
keystoneURL: 'http://www.keystonejs.com/keystone',
logo: '/images/logo_email.jpg',
logo_width: 120,
logo_height: 112,
'chartbeat property': process.env.CHARTBEAT_PROPERTY,
'chartbeat domain': process.env.CHARTBEAT_DOMAIN
});
keystone.import('models');
keystone.set('routes', require('./routes'));
keystone.set('locals', {
_: require('underscore'),
globals: require('./lib/globals'),
js: 'javascript:;',
env: keystone.get('env'),
utils: keystone.utils,
plural: keystone.utils.plural,
config: require('./config'),
google_api_key: keystone.get('google api key'),
ga_property: keystone.get('ga property'),
ga_domain: keystone.get('ga domain'),
chartbeat_property: keystone.get('chartbeat property'),
chartbeat_domain: keystone.get('chartbeat domain')
});
keystone.set('email locals', {
keystoneURL: 'http://www.keystonejs.com/keystone',
logo: '/images/logo_email.jpg',
logo_width: 120,
logo_height: 112,
theme: {
mongo: `${process.env.MONGO_URI}` || 'localhost:27017/vivid',
port: 3000,
'session store': 'mongo',
updates: 'updates',
'auto update': true,
session: true,
auth: true,
'user model': 'User',
'cookie secret': process.env.COOKIE_SECRET || 'development secret'
})
keystone.set('cloudinary config', process.env.CLOUDINARY_URL)
keystone.import('./models')
keystone.set('locals', {
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable,
_: require('lodash')
})
keystone.set('nav', {
users: 'users'
})
const cl = cloudinary.Cloudinary.new()
cl.fromEnvironment();
(async () => {
await next.prepare()
const context = {
keystone,
cl,
next,