Merge remote-tracking branch 'origin/master' into socket.io1.x

v1.18.x
barisusakli 10 years ago
commit 957800b2c3

@ -1,12 +1,12 @@
services:
- redis-server
- redis-server
before_install:
- npm i --production
- node app --setup="{\"base_url\":\"http://127.0.0.1\",\"port\":4567,\"use_port\":false,\"secret\":\"abcdef\",\"bind_address\":\"0.0.0.0\",\"database\":\"redis\",\"redis:host\":\"127.0.0.1\",\"redis:port\":6379,\"redis:password\":\"\",\"redis:database\":0,\"admin:username\":\"admin\",\"admin:email\":\"test@example.org\",\"admin:password\":\"abcdef\",\"admin:password:confirm\":\"abcdef\"}" --ci="{\"host\":\"127.0.0.1\",\"port\":6379,\"database\":0}"
- npm i --production
- node app --setup="{\"url\":\"http://127.0.0.1:4567/\",\"secret\":\"abcdef\",\"database\":\"redis\",\"redis:host\":\"127.0.0.1\",\"redis:port\":6379,\"redis:password\":\"\",\"redis:database\":0,\"admin:username\":\"admin\",\"admin:email\":\"test@example.org\",\"admin:password\":\"abcdef\",\"admin:password:confirm\":\"abcdef\"}" --ci="{\"host\":\"127.0.0.1\",\"port\":6379,\"database\":0}"
language: node_js
node_js:
- "0.11"
- "0.10"
- "0.11"
- "0.10"
branches:
only:
- master
only:
- master

@ -110,7 +110,6 @@ function start() {
// nconf defaults, if not set in config
if (!nconf.get('upload_path')) nconf.set('upload_path', '/public/uploads');
if (!nconf.get('bcrypt_rounds')) nconf.set('bcrypt_rounds', 12);
// Parse out the relative_url and other goodies from the configured URL
var urlObject = url.parse(nconf.get('url'));
nconf.set('use_port', !!urlObject.port);

@ -41,8 +41,8 @@
"nodebb-plugin-mentions": "^0.7.0",
"nodebb-plugin-soundpack-default": "~0.1.1",
"nodebb-plugin-spam-be-gone": "^0.3.0",
"nodebb-theme-lavender": "~0.1.0",
"nodebb-theme-vanilla": "~0.1.0",
"nodebb-theme-lavender": "^0.2.0",
"nodebb-theme-vanilla": "^0.2.0",
"nodebb-widget-essentials": "~0.2.0",
"npm": "^2.1.4",
"passport": "^0.2.1",

@ -251,6 +251,7 @@ categoriesController.get = function(req, res, next) {
}
}
data.breadcrumbs = res.locals.breadcrumbs;
res.render('category', data);
});
};

@ -253,6 +253,7 @@ topicsController.get = function(req, res, next) {
}
}
data.breadcrumbs = res.locals.breadcrumbs;
res.render('topic', data);
});
};

@ -197,6 +197,58 @@ middleware.checkAccountPermissions = function(req, res, next) {
});
};
middleware.buildBreadcrumbs = function(req, res, next) {
var breadcrumbs = [],
findParents = function(cid) {
var currentCategory;
async.doWhilst(function(next) {
categories.getCategoryFields(currentCategory ? currentCategory.parentCid : cid, ['name', 'slug', 'parentCid'], function(err, data) {
if (err) {
return next(err);
}
breadcrumbs.unshift({
text: data.name,
url: nconf.get('relative_path') + '/category/' + data.slug
});
currentCategory = data;
next();
});
}, function() {
return !!currentCategory.parentCid && currentCategory.parentCid !== '0';
}, function(err) {
if (err) {
winston.warn('[buildBreadcrumb] Could not build breadcrumbs: ' + err.message);
}
// Home breadcrumb
translator.translate('[[global:home]]', meta.config.defaultLang || 'en_GB', function(translated) {
breadcrumbs.unshift({
text: translated,
url: nconf.get('relative_path')
});
res.locals.breadcrumbs = breadcrumbs || [];
next();
});
});
};
if (req.params.topic_id) {
topics.getTopicFields(parseInt(req.params.topic_id, 10), ['cid', 'title', 'slug'], function(err, data) {
breadcrumbs.unshift({
text: data.title,
url: nconf.get('relative_path') + '/topic/' + data.slug
});
findParents(parseInt(data.cid, 10));
});
} else {
findParents(parseInt(req.params.category_id, 10));
}
};
middleware.buildHeader = function(req, res, next) {
res.locals.renderHeader = true;
@ -438,6 +490,9 @@ middleware.addExpiresHeaders = function(req, res, next) {
if (app.enabled('cache')) {
res.setHeader("Cache-Control", "public, max-age=5184000");
res.setHeader("Expires", new Date(Date.now() + 5184000000).toUTCString());
} else {
res.setHeader("Cache-Control", "public, max-age=0");
res.setHeader("Expires", new Date().toUTCString());
}
next();

@ -241,7 +241,7 @@
return res.status(400).send(err.message);
}
res.status(200).send(nconf.get('relative_path') + (data.referrer ? data.referrer : '/'));
res.status(200).send(data.referrer ? data.referrer : '/');
});
}

@ -40,8 +40,8 @@ function staticRoutes(app, middleware, controllers) {
function topicRoutes(app, middleware, controllers) {
app.get('/api/topic/teaser/:topic_id', controllers.topics.teaser);
setupPageRoute(app, '/topic/:topic_id/:slug/:post_index?', middleware, [], controllers.topics.get);
setupPageRoute(app, '/topic/:topic_id/:slug?', middleware, [middleware.addSlug], controllers.topics.get);
setupPageRoute(app, '/topic/:topic_id/:slug/:post_index?', middleware, [middleware.buildBreadcrumbs], controllers.topics.get);
setupPageRoute(app, '/topic/:topic_id/:slug?', middleware, [middleware.buildBreadcrumbs, middleware.addSlug], controllers.topics.get);
}
function tagRoutes(app, middleware, controllers) {
@ -55,8 +55,8 @@ function categoryRoutes(app, middleware, controllers) {
setupPageRoute(app, '/unread', middleware, [middleware.authenticate], controllers.categories.unread);
app.get('/api/unread/total', middleware.authenticate, controllers.categories.unreadTotal);
setupPageRoute(app, '/category/:category_id/:slug/:topic_index', middleware, [], controllers.categories.get);
setupPageRoute(app, '/category/:category_id/:slug?', middleware, [middleware.addSlug], controllers.categories.get);
setupPageRoute(app, '/category/:category_id/:slug/:topic_index', middleware, [middleware.buildBreadcrumbs], controllers.categories.get);
setupPageRoute(app, '/category/:category_id/:slug?', middleware, [middleware.buildBreadcrumbs, middleware.addSlug], controllers.categories.get);
}
function accountRoutes(app, middleware, controllers) {

@ -314,11 +314,25 @@ Upgrade.upgrade = function(callback) {
function(config, next) {
try {
config = JSON.parse(config);
// If the config contains "url", it has already been updated, abort.
if (config.hasOwnProperty('url')) {
return next();
}
config.url = config.base_url + (config.use_port ? ':' + config.port : '') + config.relative_path;
if (config.port == '4567') delete config.port;
if (config.bcrypt_rounds == 12) delete config.bcrypt_rounds;
if (config.upload_path === '/public/uploads') delete config.upload_path;
if (config.bind_address === '0.0.0.0') delete config.bind_address;
if (config.port == '4567') {
delete config.port;
}
if (config.bcrypt_rounds == 12) {
delete config.bcrypt_rounds;
}
if (config.upload_path === '/public/uploads') {
delete config.upload_path;
}
if (config.bind_address === '0.0.0.0') {
delete config.bind_address;
}
delete config.base_url;
delete config.use_port;
delete config.relative_path;

@ -272,7 +272,7 @@ var async = require('async'),
return callback(null, password);
}
Password.hash(nconf.get('bcrypt_rounds'), password, callback);
Password.hash(nconf.get('bcrypt_rounds') || 12, password, callback);
};
User.addTopicIdToUser = function(uid, tid, timestamp, callback) {

@ -19,7 +19,8 @@
base_dir: path.join(__dirname,'../..'),
themes_path: path.join(__dirname, '../../node_modules'),
upload_url: path.join(path.sep, '../../uploads', path.sep),
views_dir: path.join(__dirname, '../../public/templates')
views_dir: path.join(__dirname, '../../public/templates'),
relative_path: ''
});
var dbType = nconf.get('database'),

Loading…
Cancel
Save