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