mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	closes #2597
This commit is contained in:
		| @@ -34,8 +34,6 @@ define('forum/topic/posts', [ | |||||||
| 		var posts = data.posts; | 		var posts = data.posts; | ||||||
| 		socket.emit('topics.getPageCount', ajaxify.variables.get('topic_id'), function(err, newPageCount) { | 		socket.emit('topics.getPageCount', ajaxify.variables.get('topic_id'), function(err, newPageCount) { | ||||||
|  |  | ||||||
| 			pagination.recreatePaginationLinks(newPageCount); |  | ||||||
|  |  | ||||||
| 			if (pagination.currentPage === pagination.pageCount) { | 			if (pagination.currentPage === pagination.pageCount) { | ||||||
| 				createNewPosts(data); | 				createNewPosts(data); | ||||||
| 			} else if(data.posts && data.posts.length && parseInt(data.posts[0].uid, 10) === parseInt(app.uid, 10)) { | 			} else if(data.posts && data.posts.length && parseInt(data.posts[0].uid, 10) === parseInt(app.uid, 10)) { | ||||||
|   | |||||||
| @@ -22,7 +22,8 @@ categoriesController.recent = function(req, res, next) { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; | 		data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; | ||||||
|  | 		data['rssFeedUrl'] = nconf.get('relative_path') + '/recent.rss'; | ||||||
|  | 		data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]); | ||||||
| 		res.render('recent', data); | 		res.render('recent', data); | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
| @@ -52,7 +53,9 @@ categoriesController.popular = function(req, res, next) { | |||||||
|  |  | ||||||
| 		var data = { | 		var data = { | ||||||
| 			topics: topics, | 			topics: topics, | ||||||
| 			'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1 | 			'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1, | ||||||
|  | 			rssFeedUrl: nconf.get('relative_path') + '/popular.rss', | ||||||
|  | 			breadcrumbs: helpers.buildBreadcrumbs([{text: '[[global:header.popular]]'}]) | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		if (uid === 0) { | 		if (uid === 0) { | ||||||
| @@ -72,6 +75,7 @@ categoriesController.unread = function(req, res, next) { | |||||||
| 			return next(err); | 			return next(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]); | ||||||
| 		res.render('unread', data); | 		res.render('unread', data); | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
| @@ -188,7 +192,7 @@ categoriesController.get = function(req, res, next) { | |||||||
| 					url: nconf.get('relative_path') + '/category/' + categoryData.slug | 					url: nconf.get('relative_path') + '/category/' + categoryData.slug | ||||||
| 				} | 				} | ||||||
| 			]; | 			]; | ||||||
| 			helpers.buildBreadcrumbs(categoryData.parentCid, function(err, crumbs) { | 			helpers.buildCategoryBreadcrumbs(categoryData.parentCid, function(err, crumbs) { | ||||||
| 				if (err) { | 				if (err) { | ||||||
| 					return next(err); | 					return next(err); | ||||||
| 				} | 				} | ||||||
| @@ -255,6 +259,7 @@ categoriesController.get = function(req, res, next) { | |||||||
|  |  | ||||||
| 		data.currentPage = page; | 		data.currentPage = page; | ||||||
| 		data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; | 		data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; | ||||||
|  | 		data['rssFeedUrl'] = nconf.get('relative_path') + '/category/' + data.cid + '.rss'; | ||||||
|  |  | ||||||
| 		pagination.create(data.currentPage, data.pageCount, data); | 		pagination.create(data.currentPage, data.pageCount, data); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ helpers.notAllowed = function(req, res, error) { | |||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| helpers.buildBreadcrumbs = function(cid, callback) { | helpers.buildCategoryBreadcrumbs = function(cid, callback) { | ||||||
| 	var breadcrumbs = []; | 	var breadcrumbs = []; | ||||||
|  |  | ||||||
| 	async.whilst(function() { | 	async.whilst(function() { | ||||||
| @@ -62,15 +62,33 @@ helpers.buildBreadcrumbs = function(cid, callback) { | |||||||
| 			return callback(err); | 			return callback(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		translator.translate('[[global:home]]', meta.config.defaultLang || 'en_GB', function(translated) { |  | ||||||
| 		breadcrumbs.unshift({ | 		breadcrumbs.unshift({ | ||||||
| 				text: translated, | 			text: '[[global:home]]', | ||||||
| 			url: nconf.get('relative_path') + '/' | 			url: nconf.get('relative_path') + '/' | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
| 		callback(null, breadcrumbs); | 		callback(null, breadcrumbs); | ||||||
| 	}); | 	}); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | helpers.buildBreadcrumbs = function(crumbs) { | ||||||
|  | 	var breadcrumbs = [ | ||||||
|  | 		{ | ||||||
|  | 			text: '[[global:home]]', | ||||||
|  | 			url: nconf.get('relative_path') + '/' | ||||||
|  | 		} | ||||||
|  | 	]; | ||||||
|  |  | ||||||
|  | 	crumbs.forEach(function(crumb) { | ||||||
|  | 		if (crumb) { | ||||||
|  | 			if (crumb.url) { | ||||||
|  | 				crumb.url = nconf.get('relative_path') + crumb.url; | ||||||
|  | 			} | ||||||
|  | 			breadcrumbs.push(crumb); | ||||||
|  | 		} | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
|  | 	return breadcrumbs; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| module.exports = helpers; | module.exports = helpers; | ||||||
| @@ -105,9 +105,18 @@ Controllers.home = function(req, res, next) { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| Controllers.reset = function(req, res, next) { | Controllers.reset = function(req, res, next) { | ||||||
| 	res.render(req.params.code ? 'reset_code' : 'reset', { | 	if (req.params.code) { | ||||||
| 		reset_code: req.params.code ? req.params.code : null | 		res.render('reset_code', { | ||||||
|  | 			reset_code: req.params.code ? req.params.code : null, | ||||||
|  | 			breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}]) | ||||||
| 		}); | 		}); | ||||||
|  | 	} else { | ||||||
|  | 		res.render('reset', { | ||||||
|  | 			reset_code: req.params.code ? req.params.code : null, | ||||||
|  | 			breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]'}]) | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| Controllers.login = function(req, res, next) { | Controllers.login = function(req, res, next) { | ||||||
| @@ -120,6 +129,7 @@ Controllers.login = function(req, res, next) { | |||||||
| 	data.showResetLink = emailersPresent; | 	data.showResetLink = emailersPresent; | ||||||
| 	data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1; | 	data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1; | ||||||
| 	data.allowRegistration = parseInt(meta.config.allowRegistration, 10) === 1; | 	data.allowRegistration = parseInt(meta.config.allowRegistration, 10) === 1; | ||||||
|  | 	data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]); | ||||||
| 	data.error = req.flash('error')[0]; | 	data.error = req.flash('error')[0]; | ||||||
|  |  | ||||||
| 	res.render('login', data); | 	res.render('login', data); | ||||||
| @@ -151,6 +161,7 @@ Controllers.register = function(req, res, next) { | |||||||
| 	data.maximumUsernameLength = meta.config.maximumUsernameLength; | 	data.maximumUsernameLength = meta.config.maximumUsernameLength; | ||||||
| 	data.minimumPasswordLength = meta.config.minimumPasswordLength; | 	data.minimumPasswordLength = meta.config.minimumPasswordLength; | ||||||
| 	data.termsOfUse = meta.config.termsOfUse; | 	data.termsOfUse = meta.config.termsOfUse; | ||||||
|  | 	data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]); | ||||||
| 	data.regFormEntry = []; | 	data.regFormEntry = []; | ||||||
| 	data.error = req.flash('error')[0]; | 	data.error = req.flash('error')[0]; | ||||||
|  |  | ||||||
| @@ -200,7 +211,8 @@ Controllers.outgoing = function(req, res, next) { | |||||||
| 	var url = req.query.url, | 	var url = req.query.url, | ||||||
| 		data = { | 		data = { | ||||||
| 			url: url, | 			url: url, | ||||||
| 			title: meta.config.title | 			title: meta.config.title, | ||||||
|  | 			breadcrumbs: helpers.buildBreadcrumbs([{text: '[[notifications:outgoing_link]]'}]) | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 	if (url) { | 	if (url) { | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ searchController.search = function(req, res, next) { | |||||||
| 	if (!plugins.hasListeners('filter:search.query')) { | 	if (!plugins.hasListeners('filter:search.query')) { | ||||||
| 		return helpers.notFound(req, res); | 		return helpers.notFound(req, res); | ||||||
| 	} | 	} | ||||||
|  | 	var breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]); | ||||||
| 	if (!req.params.term) { | 	if (!req.params.term) { | ||||||
| 		return res.render('search', { | 		return res.render('search', { | ||||||
| 			time: 0, | 			time: 0, | ||||||
| @@ -20,7 +20,8 @@ searchController.search = function(req, res, next) { | |||||||
| 			posts: [], | 			posts: [], | ||||||
| 			topics: [], | 			topics: [], | ||||||
| 			users: [], | 			users: [], | ||||||
| 			tags: [] | 			tags: [], | ||||||
|  | 			breadcrumbs: breadcrumbs | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -38,6 +39,7 @@ searchController.search = function(req, res, next) { | |||||||
| 			return next(err); | 			return next(err); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		results.breadcrumbs = breadcrumbs; | ||||||
| 		res.render('search', results); | 		res.render('search', results); | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ var tagsController = {}, | |||||||
| 	nconf = require('nconf'), | 	nconf = require('nconf'), | ||||||
| 	validator = require('validator'), | 	validator = require('validator'), | ||||||
| 	meta = require('../meta'), | 	meta = require('../meta'), | ||||||
| 	topics = require('../topics'); | 	topics = require('../topics'), | ||||||
|  | 	helpers =  require('./helpers'); | ||||||
|  |  | ||||||
| tagsController.getTag = function(req, res, next) { | tagsController.getTag = function(req, res, next) { | ||||||
| 	var tag = validator.escape(req.params.tag); | 	var tag = validator.escape(req.params.tag); | ||||||
| @@ -41,8 +42,13 @@ tagsController.getTag = function(req, res, next) { | |||||||
| 					content: nconf.get('url') + '/tags/' + tag | 					content: nconf.get('url') + '/tags/' + tag | ||||||
| 				} | 				} | ||||||
| 			]; | 			]; | ||||||
|  | 			var data = { | ||||||
| 			res.render('tag', {topics: topics, tag: tag, nextStart: end + 1}); | 				topics: topics, | ||||||
|  | 				tag: tag, | ||||||
|  | 				nextStart: end + 1, | ||||||
|  | 				breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]', url: '/tags'}, {text: tag}]) | ||||||
|  | 			}; | ||||||
|  | 			res.render('tag', data); | ||||||
| 		}); | 		}); | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
| @@ -52,8 +58,12 @@ tagsController.getTags = function(req, res, next) { | |||||||
| 		if (err) { | 		if (err) { | ||||||
| 			return next(err); | 			return next(err); | ||||||
| 		} | 		} | ||||||
|  | 		var data = { | ||||||
| 		res.render('tags', {tags: tags, nextStart: 100}); | 			tags: tags, | ||||||
|  | 			nextStart: 100, | ||||||
|  | 			breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}]) | ||||||
|  | 		}; | ||||||
|  | 		res.render('tags', data); | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -139,7 +139,7 @@ topicsController.get = function(req, res, next) { | |||||||
| 				} | 				} | ||||||
| 			]; | 			]; | ||||||
|  |  | ||||||
| 			helpers.buildBreadcrumbs(topicData.category.parentCid, function(err, crumbs) { | 			helpers.buildCategoryBreadcrumbs(topicData.category.parentCid, function(err, crumbs) { | ||||||
| 				if (err) { | 				if (err) { | ||||||
| 					return next(err); | 					return next(err); | ||||||
| 				} | 				} | ||||||
| @@ -255,6 +255,7 @@ topicsController.get = function(req, res, next) { | |||||||
| 		data['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1; | 		data['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1; | ||||||
| 		data['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1; | 		data['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1; | ||||||
| 		data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; | 		data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; | ||||||
|  | 		data['rssFeedUrl'] = nconf.get('relative_path') + '/topic/' + data.tid + '.rss'; | ||||||
|  |  | ||||||
| 		topics.increaseViewCount(tid); | 		topics.increaseViewCount(tid); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user