mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	Merge branch 'master' of github.com:psychobunny/node-forum
This commit is contained in:
		| @@ -205,8 +205,8 @@ footer.footer { | ||||
| 	.latest-post { | ||||
| 		float: right; | ||||
| 		padding-top: 2px; | ||||
| 		margin-right: 30px; | ||||
| 		width: 50%; | ||||
| 		margin-right: 0px; | ||||
| 		width: 40%; | ||||
|  | ||||
| 		.pull-right { | ||||
| 			width: 100%; | ||||
|   | ||||
| @@ -21,12 +21,11 @@ var ajaxify = {}; | ||||
|  | ||||
|  | ||||
| 	window.onpopstate = function(event) { | ||||
| 		// "quiet": If set to true, will not call pushState | ||||
| 		if (event !== null && event.state && event.state.url !== undefined) ajaxify.go(event.state.url, null, null, true); | ||||
| 	}; | ||||
|  | ||||
| 	ajaxify.go = function(url, callback, template, quiet) { | ||||
| 		// "quiet": If set to true, will not call pushState | ||||
|  | ||||
| 		// leave room and join global | ||||
| 		app.enter_room('global'); | ||||
|  | ||||
| @@ -61,9 +60,6 @@ var ajaxify = {}; | ||||
| 				jQuery('#content, #footer').fadeIn(200); | ||||
| 			}, url, template); | ||||
|  | ||||
| 			return true; | ||||
| 		} else { | ||||
| 			document.location.href = url; | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| @@ -71,24 +67,18 @@ var ajaxify = {}; | ||||
| 	} | ||||
|  | ||||
| 	ajaxify.enable = function() { | ||||
| 		$('a').unbind('mouseup', ajaxify.onmouseup).bind('mouseup', ajaxify.onmouseup); | ||||
| 		$('a').unbind('click', ajaxify.onclick).bind('click', ajaxify.onclick); | ||||
| 	} | ||||
|  | ||||
| 	ajaxify.onmouseup = function(ev) { | ||||
| 	ajaxify.onclick = function(ev) { | ||||
| 		if (this.href == window.location.href + "#") return; | ||||
| 		var url = this.href.replace(rootUrl +'/', ''); | ||||
|  | ||||
| 		if (!ev.ctrlKey && ev.which === 1) { | ||||
| 			if (ajaxify.go(url)) ev.preventDefault(); | ||||
| 		} else if ((ev.ctrlKey && ev.which === 1) || ev.which === 2) { | ||||
| 			window.open(this.href, '_blank'); | ||||
| 			if (ajaxify.go(url)) { | ||||
| 				ev.preventDefault(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	ajaxify.onclick = function(ev) { | ||||
| 		ev.preventDefault(); | ||||
| 	} | ||||
|  | ||||
| 	$('document').ready(function() { | ||||
|   | ||||
| @@ -36,6 +36,7 @@ var socket, | ||||
| 				$('#disconnect-modal').show(); | ||||
| 				$('#reload-button').on('click',function(){ | ||||
| 					$('#disconnect-modal').hide(); | ||||
| 					console.log(window.location.href); | ||||
| 					window.location.reload(); | ||||
| 				}); | ||||
| 			}); | ||||
|   | ||||
| @@ -40,6 +40,7 @@ var templates = {}; | ||||
| 		for (var t in templatesToLoad) { | ||||
| 			(function(file) { | ||||
| 				$.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) { | ||||
| 		 | ||||
| 					var template = function() { | ||||
| 						this.toString = function() { | ||||
| 							return this.html; | ||||
| @@ -168,6 +169,12 @@ function load_template(callback, url, template) { | ||||
|  | ||||
| 	jQuery.get(API_URL + url, function(data) { | ||||
|  | ||||
| 		console.log(data); | ||||
| 		if(!data) { | ||||
| 			window.location.href = '/403'; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		var tpl = templates.get_custom_map(url); | ||||
| 		 | ||||
| 		if (tpl == false && !templates[url]) { | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| 	<link href="/vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen"> | ||||
| 	<link rel="stylesheet" href="/vendor/fontawesome/css/font-awesome.min.css"> | ||||
| 	<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script> | ||||
| 	<script type="text/javascript" src="/vendor/bootstrap/js/bootstrap.min.js"></script> | ||||
| 	<script type="text/javascript" src="/vendor/bootstrap/js/bootstrap.js"></script> | ||||
| 	<script type="text/javascript" src="/socket.io/socket.io.js"></script> | ||||
| 	<script type="text/javascript" src="/src/app.js"></script> | ||||
| 	<script type="text/javascript" src="/src/templates.js"></script> | ||||
|   | ||||
							
								
								
									
										2
									
								
								public/vendor/bootstrap/js/bootstrap.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								public/vendor/bootstrap/js/bootstrap.js
									
									
									
									
										vendored
									
									
								
							| @@ -788,7 +788,7 @@ | ||||
|   /* APPLY TO STANDARD DROPDOWN ELEMENTS | ||||
|    * =================================== */ | ||||
|  | ||||
|   $(document) | ||||
|   $('.dropdown') | ||||
|     .on('click.dropdown.data-api', clearMenus) | ||||
|     .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) | ||||
|     .on('click.dropdown-menu', function (e) { e.stopPropagation() }) | ||||
|   | ||||
							
								
								
									
										18
									
								
								src/posts.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/posts.js
									
									
									
									
									
								
							| @@ -13,12 +13,16 @@ marked.setOptions({ | ||||
| (function(Posts) { | ||||
|  | ||||
| 	Posts.get = function(callback, tid, current_user, start, end) { | ||||
|  | ||||
| 		if (start == null) start = 0; | ||||
| 		if (end == null) end = start + 10; | ||||
|  | ||||
| 		var post_data, user_data, thread_data, vote_data, viewer_data; | ||||
|  | ||||
| 		topics.markAsRead(tid, current_user); | ||||
| 		getTopicPosts(); | ||||
|  | ||||
| 		getUserReputation(); | ||||
| 		 | ||||
|  | ||||
| 		//compile thread after all data is asynchronously called | ||||
| 		function generateThread() { | ||||
| @@ -71,11 +75,18 @@ marked.setOptions({ | ||||
| 			}); | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		function getTopicPosts() { | ||||
| 			// get all data for thread in asynchronous fashion | ||||
| 			RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) { | ||||
| 				RDB.handle(err); | ||||
| 				 | ||||
| 				if(pids.length === 0 ){ | ||||
| 					callback(false); | ||||
| 					return; | ||||
| 				} | ||||
| 				 | ||||
| 				topics.markAsRead(tid, current_user); | ||||
| 				 | ||||
| 				var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [], deleted = []; | ||||
|  | ||||
| 				for (var i=0, ii=pids.length; i<ii; i++) { | ||||
| @@ -142,7 +153,9 @@ marked.setOptions({ | ||||
| 						}); | ||||
| 					}); | ||||
| 			}); | ||||
| 		} | ||||
|  | ||||
| 		function getUserReputation() { | ||||
| 			user.getUserField(current_user, 'reputation', function(reputation){ | ||||
| 				viewer_data = { | ||||
| 					reputation: reputation | ||||
| @@ -150,6 +163,7 @@ marked.setOptions({ | ||||
| 				generateThread(); | ||||
| 			}); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	Posts.reply = function(socket, tid, uid, content) { | ||||
|   | ||||
| @@ -101,8 +101,6 @@ var user = require('./../user.js'), | ||||
| 			var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']; | ||||
| 			var type = req.files.userPhoto.type; | ||||
| 			 | ||||
| 			console.log(req.files.userPhoto); | ||||
|  | ||||
| 			if(allowedTypes.indexOf(type) === -1) { | ||||
| 				res.send({ | ||||
| 					error: 'Allowed image types are png, jpg and gif!' | ||||
| @@ -284,9 +282,9 @@ var user = require('./../user.js'), | ||||
| 		 | ||||
| 				user.getUserData(uid, function(data) { | ||||
| 					if(data) { | ||||
| 						console.log(data.joindate); | ||||
|  | ||||
| 						data.joindate = utils.relativeTime(data.joindate); | ||||
| 						console.log(data.joindate); | ||||
|  | ||||
| 						if(!data.birthday) | ||||
| 							data.age = ''; | ||||
| 						else | ||||
|   | ||||
| @@ -20,6 +20,12 @@ var	RDB = require('./redis.js'), | ||||
| 		var range_var = (category_id) ? 'categories:' + category_id + ':tid'  : 'topics:tid'; | ||||
|  | ||||
| 		RDB.smembers(range_var, function(err, tids) { | ||||
| 			 | ||||
| 			if(tids.length === 0) { | ||||
| 				callback(false); | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			var title = [], | ||||
| 				uid = [], | ||||
| 				timestamp = [], | ||||
|   | ||||
| @@ -80,7 +80,7 @@ var config = require('../config.js'), | ||||
| 		for(var i=0,ii=fields.length; i<ii; ++i) { | ||||
| 			key = fields[i]; | ||||
| 			if(data[key] !== undefined) { | ||||
| 				console.log(data[key]); | ||||
|  | ||||
| 				User.setUserField(uid, key, data[key]); | ||||
| 				 | ||||
| 				if(key === 'email') { | ||||
|   | ||||
| @@ -154,26 +154,46 @@ var express = require('express'), | ||||
| 				break; | ||||
| 			case 'topic' : | ||||
| 					posts.get(function(data) { | ||||
| 						if(!data) { | ||||
| 							res.send(false); | ||||
| 							return; | ||||
| 						} | ||||
| 						res.send(JSON.stringify(data)); | ||||
| 					}, req.params.id, (req.user) ? req.user.uid : 0); | ||||
| 				break; | ||||
| 			case 'category' : | ||||
| 					topics.get(function(data) { | ||||
| 						if(!data) { | ||||
| 							res.send(false); | ||||
| 							return; | ||||
| 						} | ||||
| 						res.send(JSON.stringify(data)); | ||||
| 					}, req.params.id, (req.user) ? req.user.uid : 0); | ||||
| 				break; | ||||
| 			case 'latest' : | ||||
| 					topics.get(function(data) { | ||||
| 						if(!data) { | ||||
| 							res.send(false); | ||||
| 							return; | ||||
| 						} | ||||
| 						res.send(JSON.stringify(data)); | ||||
| 					}); | ||||
| 				break; | ||||
| 			case 'popular' : | ||||
| 					topics.get(function(data) { | ||||
| 						if(!data) { | ||||
| 							res.send(false); | ||||
| 							return; | ||||
| 						} | ||||
| 						res.send(JSON.stringify(data)); | ||||
| 					}); | ||||
| 				break; | ||||
| 			case 'active' : | ||||
| 					topics.get(function(data) { | ||||
| 						if(!data) { | ||||
| 							res.send(false); | ||||
| 							return; | ||||
| 						} | ||||
| 						res.send(JSON.stringify(data)); | ||||
| 					}); | ||||
| 				break; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user