Merge branch 'master' of https://github.com/designcreateplay/NodeBB into pagination

v1.18.x
Baris Soner Usakli 11 years ago
commit 8744013013

@ -106,11 +106,9 @@
upgrade.check(function(schema_ok) { upgrade.check(function(schema_ok) {
if (schema_ok || nconf.get('check-schema') === false) { if (schema_ok || nconf.get('check-schema') === false) {
sockets.init(); sockets.init(webserver.server);
plugins.init(); plugins.init();
global.templates = {};
global.translator = translator;
translator.loadServer(); translator.loadServer();

@ -79,7 +79,7 @@
template.prototype.parse = parse; template.prototype.parse = parse;
template.prototype.html = String(html); template.prototype.html = String(html);
global.templates[file] = new template; templates[file] = new template;
loaded--; loaded--;
if (loaded === 0) { if (loaded === 0) {
@ -396,7 +396,7 @@
namespace = ''; namespace = '';
} else { } else {
// clean up all undefined conditionals // clean up all undefined conditionals
template = template.replace(/<!-- IF([^@]*?)ENDIF([^@]*?)-->/gi, ''); template = template.replace(/<!-- IF([^@]*?)ENDIF([^@]*?)-->/gi, '');
} }
return template; return template;

@ -5,6 +5,7 @@ var db = require('./database.js'),
topics = require('./topics.js'), topics = require('./topics.js'),
plugins = require('./plugins'), plugins = require('./plugins'),
CategoryTools = require('./categoryTools'), CategoryTools = require('./categoryTools'),
meta = require('./meta'),
async = require('async'), async = require('async'),
winston = require('winston'), winston = require('winston'),

@ -1,16 +1,18 @@
var User = require('./user'), var fs = require('fs'),
async = require('async'),
path = require('path'),
User = require('./user'),
Plugins = require('./plugins'), Plugins = require('./plugins'),
Meta = require('./meta'), Meta = require('./meta'),
Translator = require('../public/src/translator'), Translator = require('../public/src/translator'),
templates = require('../public/src/templates'),
fs = require('fs'),
async = require('async'),
path = require('path'),
Emailer = {}; Emailer = {};
var render = function(template, params, callback) { var render = function(template, params, callback) {
if (templates[template] !== null) {
if (templates[template]) {
Translator.translate(templates[template].parse(params), function(template) { Translator.translate(templates[template].parse(params), function(template) {
callback(null, template); callback(null, template);
}); });

@ -1,7 +1,7 @@
var db = require('./database'), var db = require('./database'),
async = require('async'), async = require('async'),
user = require('./user'), user = require('./user'),
plugins = require('./plugins'); plugins = require('./plugins'),
meta = require('./meta'); meta = require('./meta');

@ -255,7 +255,7 @@ var fs = require('fs'),
}, },
minFile: function (next) { minFile: function (next) {
if (!fs.existsSync(Meta.js.minFile)) { if (!fs.existsSync(Meta.js.minFile)) {
winston.warn('No minified client-side library found'); winston.info('No minified client-side library found');
return next(null, 0); return next(null, 0);
} }

@ -194,7 +194,7 @@ var db = require('./database'),
post.user_rep = userData.reputation || 0; post.user_rep = userData.reputation || 0;
post.user_postcount = userData.postcount || 0; post.user_postcount = userData.postcount || 0;
post.user_banned = parseInt(userData.banned, 10) === 1; post.user_banned = parseInt(userData.banned, 10) === 1;
post.picture = userData.picture || gravatar.url('', {}, https = nconf.get('https')); post.picture = userData.picture || gravatar.url('', {}, true);
if(meta.config.disableSignatures === undefined || parseInt(meta.config.disableSignatures, 10) === 0) { if(meta.config.disableSignatures === undefined || parseInt(meta.config.disableSignatures, 10) === 0) {
post.signature = signature; post.signature = signature;

@ -7,13 +7,14 @@ var nconf = require('nconf'),
user = require('./../user'), user = require('./../user'),
groups = require('../groups'), groups = require('../groups'),
topics = require('./../topics'), topics = require('./../topics'),
pkg = require('./../../package.json'), pkg = require('./../../package'),
categories = require('./../categories'), categories = require('./../categories'),
meta = require('../meta'), meta = require('../meta'),
plugins = require('../plugins'), plugins = require('../plugins'),
Languages = require('../languages'), Languages = require('../languages'),
events = require('./../events'), events = require('./../events'),
utils = require('./../../public/src/utils.js'); utils = require('./../../public/src/utils'),
templates = require('./../../public/src/templates');
(function (Admin) { (function (Admin) {
Admin.isAdmin = function (req, res, next) { Admin.isAdmin = function (req, res, next) {

@ -30,9 +30,9 @@ Sockets.userSockets = {};
Sockets.rooms = {}; Sockets.rooms = {};
Sockets.init = function() { Sockets.init = function(server) {
io = socketioWildcard(SocketIO).listen(global.server, { io = socketioWildcard(SocketIO).listen(server, {
log: false, log: false,
transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket'], transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket'],
'browser client minification': true 'browser client minification': true

@ -58,7 +58,7 @@ SocketMeta.updateHeader = function(socket, data, callback) {
email: '', email: '',
picture: gravatar.url('', { picture: gravatar.url('', {
s: '24' s: '24'
}, nconf.get('https')), }, true),
config: { config: {
allowGuestSearching: meta.config.allowGuestSearching allowGuestSearching: meta.config.allowGuestSearching
} }

@ -738,14 +738,14 @@ var async = require('async'),
topicData.unreplied = parseInt(topicData.postcount, 10) === 1; topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
topicData.username = topicInfo.username || 'anonymous'; topicData.username = topicInfo.username || 'anonymous';
topicData.userslug = topicInfo.userslug || ''; topicData.userslug = topicInfo.userslug || '';
topicData.picture = topicInfo.picture || gravatar.url('', {}, https = nconf.get('https')); topicData.picture = topicInfo.picture || gravatar.url('', {}, true);
topicData.categoryIcon = topicInfo.categoryData.icon; topicData.categoryIcon = topicInfo.categoryData.icon;
topicData.categoryName = topicInfo.categoryData.name; topicData.categoryName = topicInfo.categoryData.name;
topicData.categorySlug = topicInfo.categoryData.slug; topicData.categorySlug = topicInfo.categoryData.slug;
topicData.badgeclass = (topicInfo.hasread && parseInt(current_user, 10) !== 0) ? '' : 'badge-important'; topicData.badgeclass = (topicInfo.hasread && parseInt(current_user, 10) !== 0) ? '' : 'badge-important';
topicData.teaser_username = topicInfo.teaserInfo.username || ''; topicData.teaser_username = topicInfo.teaserInfo.username || '';
topicData.teaser_userslug = topicInfo.teaserInfo.userslug || ''; topicData.teaser_userslug = topicInfo.teaserInfo.userslug || '';
topicData.teaser_userpicture = topicInfo.teaserInfo.picture || gravatar.url('', {}, https = nconf.get('https')); topicData.teaser_userpicture = topicInfo.teaserInfo.picture || gravatar.url('', {}, true);
topicData.teaser_pid = topicInfo.teaserInfo.pid; topicData.teaser_pid = topicInfo.teaserInfo.pid;
topicData.teaser_timestamp = utils.toISOString(topicInfo.teaserInfo.timestamp); topicData.teaser_timestamp = utils.toISOString(topicInfo.teaserInfo.timestamp);
@ -1053,7 +1053,7 @@ var async = require('async'),
pid: postData.pid, pid: postData.pid,
username: userData.username || 'anonymous', username: userData.username || 'anonymous',
userslug: userData.userslug, userslug: userData.userslug,
picture: userData.picture || gravatar.url('', {}, https = nconf.get('https')), picture: userData.picture || gravatar.url('', {}, true),
timestamp: postData.timestamp timestamp: postData.timestamp
}); });
}); });

@ -17,7 +17,7 @@ var db = require('./database'),
Upgrade.check = function(callback) { Upgrade.check = function(callback) {
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
var latestSchema = new Date(2014, 0, 23, 16, 5).getTime(); var latestSchema = new Date(2014, 0, 25, 0, 0).getTime();
db.get('schemaDate', function(err, value) { db.get('schemaDate', function(err, value) {
if (parseInt(value, 10) >= latestSchema) { if (parseInt(value, 10) >= latestSchema) {
@ -318,11 +318,46 @@ Upgrade.upgrade = function(callback) {
winston.info('[2014/1/23] Updating Administrators Group'); winston.info('[2014/1/23] Updating Administrators Group');
next(); next();
}); });
}) });
} else { } else {
winston.info('[2014/1/23] Updating Administrators Group -- skipped'); winston.info('[2014/1/23] Updating Administrators Group -- skipped');
next(); next();
} }
},
function(next) {
thisSchemaDate = new Date(2014, 0, 25, 0, 0).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
if(err) {
return next(err);
}
if(!uids || !uids.length) {
winston.info('[2014/1/25] Updating User Gravatars to HTTPS -- skipped');
return next();
}
var gravatar = require('gravatar');
function updateGravatar(uid, next) {
User.getUserFields(uid, ['email', 'picture', 'gravatarpicture'], function(err, userData) {
var gravatarPicture = User.createGravatarURLFromEmail(userData.email);
if(userData.picture === userData.gravatarpicture) {
User.setUserField(uid, 'picture', gravatarPicture);
}
User.setUserField(uid, 'gravatarpicture', gravatarPicture, next);
});
}
winston.info('[2014/1/25] Updating User Gravatars to HTTPS');
async.each(uids, updateGravatar, next);
});
} else {
winston.info('[2014/1/25] Updating User Gravatars to HTTPS -- skipped');
next();
}
} }
// Add new schema updates here // Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!! // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!

@ -442,15 +442,14 @@ var bcrypt = require('bcrypt'),
size: '128', size: '128',
default: 'identicon', default: 'identicon',
rating: 'pg' rating: 'pg'
}, };
https = nconf.get('https');
if (!email) { if (!email) {
email = ''; email = '';
options.forcedefault = 'y'; options.forcedefault = 'y';
} }
return gravatar.url(email, options, https); return gravatar.url(email, options, true);
}; };
User.hashPassword = function(password, callback) { User.hashPassword = function(password, callback) {

@ -28,7 +28,9 @@ var path = require('path'),
meta = require('./meta'), meta = require('./meta'),
feed = require('./feed'), feed = require('./feed'),
plugins = require('./plugins'), plugins = require('./plugins'),
logger = require('./logger'); logger = require('./logger'),
templates = require('./../public/src/templates'),
translator = require('./../public/src/translator');
if(nconf.get('ssl')) { if(nconf.get('ssl')) {
server = require('https').createServer({ server = require('https').createServer({
@ -39,13 +41,12 @@ if(nconf.get('ssl')) {
server = require('http').createServer(WebServer); server = require('http').createServer(WebServer);
} }
module.exports.server = server;
(function (app) { (function (app) {
"use strict"; "use strict";
var templates = null, var clientScripts;
clientScripts;
plugins.ready(function() { plugins.ready(function() {
// Minify client-side libraries // Minify client-side libraries
@ -60,9 +61,6 @@ if(nconf.get('ssl')) {
}); });
}); });
server.app = app;
/** /**
* `options` object requires: req, res * `options` object requires: req, res
* accepts: metaTags, linkTags * accepts: metaTags, linkTags
@ -200,7 +198,6 @@ if(nconf.get('ssl')) {
// Local vars, other assorted setup // Local vars, other assorted setup
app.use(function (req, res, next) { app.use(function (req, res, next) {
nconf.set('https', req.secure);
res.locals.csrf_token = req.session._csrf; res.locals.csrf_token = req.session._csrf;
// Disable framing // Disable framing
@ -376,8 +373,6 @@ if(nconf.get('ssl')) {
}); });
module.exports.init = function () { module.exports.init = function () {
templates = global.templates;
// translate all static templates served by webserver here. ex. footer, logout // translate all static templates served by webserver here. ex. footer, logout
plugins.fireHook('filter:footer.build', '', function(err, appendHTML) { plugins.fireHook('filter:footer.build', '', function(err, appendHTML) {
var footer = templates.footer.parse({ var footer = templates.footer.parse({
@ -932,6 +927,3 @@ if(nconf.get('ssl')) {
}); });
}(WebServer)); }(WebServer));
global.server = server;

Loading…
Cancel
Save