mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
fixed conflicts
This commit is contained in:
@@ -1,8 +1,4 @@
|
|||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
|
||||||
end_of_line = lf
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.js, *.css, *.tpl]
|
[*.js, *.css, *.tpl]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
17
.jsbeautifyrc
Normal file
17
.jsbeautifyrc
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"indent_size": 4,
|
||||||
|
"indent_char": " ",
|
||||||
|
"indent_level": 0,
|
||||||
|
"indent_with_tabs": false,
|
||||||
|
"preserve_newlines": true,
|
||||||
|
"max_preserve_newlines": 10,
|
||||||
|
"jslint_happy": false,
|
||||||
|
"brace_style": "collapse",
|
||||||
|
"keep_array_indentation": false,
|
||||||
|
"keep_function_indentation": false,
|
||||||
|
"space_before_conditional": true,
|
||||||
|
"break_chained_methods": false,
|
||||||
|
"eval_code": false,
|
||||||
|
"unescape_strings": false,
|
||||||
|
"wrap_line_length": 0
|
||||||
|
}
|
||||||
86
.jshintrc
Normal file
86
.jshintrc
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
// JSHint Default Configuration File (as on JSHint website)
|
||||||
|
// See http://jshint.com/docs/ for more details
|
||||||
|
|
||||||
|
"maxerr" : 50, // {int} Maximum error before stopping
|
||||||
|
|
||||||
|
// Enforcing
|
||||||
|
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
|
||||||
|
"camelcase" : false, // true: Identifiers must be in camelCase
|
||||||
|
"curly" : true, // true: Require {} for every new block or scope
|
||||||
|
"eqeqeq" : true, // true: Require triple equals (===) for comparison
|
||||||
|
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
|
||||||
|
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
|
||||||
|
"indent" : 4, // {int} Number of spaces to use for indentation
|
||||||
|
"latedef" : false, // true: Require variables/functions to be defined before being used
|
||||||
|
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
|
||||||
|
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
|
||||||
|
"noempty" : true, // true: Prohibit use of empty blocks
|
||||||
|
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
|
||||||
|
"plusplus" : false, // true: Prohibit use of `++` & `--`
|
||||||
|
"quotmark" : false, // Quotation mark consistency:
|
||||||
|
// false : do nothing (default)
|
||||||
|
// true : ensure whatever is used is consistent
|
||||||
|
// "single" : require single quotes
|
||||||
|
// "double" : require double quotes
|
||||||
|
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
|
||||||
|
"unused" : true, // true: Require all defined variables be used
|
||||||
|
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
|
||||||
|
"trailing" : false, // true: Prohibit trailing whitespaces
|
||||||
|
"maxparams" : false, // {int} Max number of formal params allowed per function
|
||||||
|
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
|
||||||
|
"maxstatements" : false, // {int} Max number statements per function
|
||||||
|
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
|
||||||
|
"maxlen" : false, // {int} Max number of characters per line
|
||||||
|
|
||||||
|
// Relaxing
|
||||||
|
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
|
||||||
|
"boss" : false, // true: Tolerate assignments where comparisons would be expected
|
||||||
|
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
|
||||||
|
"eqnull" : false, // true: Tolerate use of `== null`
|
||||||
|
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
|
||||||
|
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
|
||||||
|
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
|
||||||
|
// (ex: `for each`, multiple try/catch, function expression…)
|
||||||
|
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
|
||||||
|
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
|
||||||
|
"funcscope" : false, // true: Tolerate defining variables inside control statements"
|
||||||
|
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
|
||||||
|
"iterator" : false, // true: Tolerate using the `__iterator__` property
|
||||||
|
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
|
||||||
|
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
|
||||||
|
"laxcomma" : false, // true: Tolerate comma-first style coding
|
||||||
|
"loopfunc" : false, // true: Tolerate functions being defined in loops
|
||||||
|
"multistr" : false, // true: Tolerate multi-line strings
|
||||||
|
"proto" : false, // true: Tolerate using the `__proto__` property
|
||||||
|
"scripturl" : false, // true: Tolerate script-targeted URLs
|
||||||
|
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
|
||||||
|
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
|
||||||
|
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
|
||||||
|
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
|
||||||
|
"validthis" : false, // true: Tolerate using this in a non-constructor function
|
||||||
|
|
||||||
|
// Environments
|
||||||
|
"browser" : true, // Web Browser (window, document, etc)
|
||||||
|
"couch" : false, // CouchDB
|
||||||
|
"devel" : true, // Development/debugging (alert, confirm, etc)
|
||||||
|
"dojo" : false, // Dojo Toolkit
|
||||||
|
"jquery" : true, // jQuery
|
||||||
|
"mootools" : false, // MooTools
|
||||||
|
"node" : true, // Node.js
|
||||||
|
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
|
||||||
|
"prototypejs" : false, // Prototype and Scriptaculous
|
||||||
|
"rhino" : false, // Rhino
|
||||||
|
"worker" : false, // Web Workers
|
||||||
|
"wsh" : false, // Windows Scripting Host
|
||||||
|
"yui" : false, // Yahoo User Interface
|
||||||
|
|
||||||
|
// Legacy
|
||||||
|
"nomen" : false, // true: Prohibit dangling `_` in variables
|
||||||
|
"onevar" : false, // true: Allow only one `var` statement per function
|
||||||
|
"passfail" : false, // true: Stop on first error
|
||||||
|
"white" : false, // true: Check against strict whitespace and indentation rules
|
||||||
|
|
||||||
|
// Custom Globals
|
||||||
|
"globals" : {} // additional predefined global variables
|
||||||
|
}
|
||||||
8
app.js
8
app.js
@@ -53,7 +53,9 @@ winston.info('');
|
|||||||
|
|
||||||
if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.get('upgrade'))) {
|
if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.get('upgrade'))) {
|
||||||
// Load server-side config
|
// Load server-side config
|
||||||
nconf.file({ file: __dirname + '/config.json'});
|
nconf.file({
|
||||||
|
file: __dirname + '/config.json'
|
||||||
|
});
|
||||||
|
|
||||||
var meta = require('./src/meta.js');
|
var meta = require('./src/meta.js');
|
||||||
|
|
||||||
@@ -93,7 +95,9 @@ if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else if (nconf.get('upgrade')) {
|
} else if (nconf.get('upgrade')) {
|
||||||
nconf.file({ file: __dirname + '/config.json'});
|
nconf.file({
|
||||||
|
file: __dirname + '/config.json'
|
||||||
|
});
|
||||||
var meta = require('./src/meta.js');
|
var meta = require('./src/meta.js');
|
||||||
|
|
||||||
meta.configs.init(function() {
|
meta.configs.init(function() {
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ var socket,
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
reconnecting = false;
|
reconnecting = false;
|
||||||
reconnectTries = 0;
|
reconnectTries = 0;
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
socket.emit('api:updateHeader', {
|
||||||
|
fields: ['username', 'picture', 'userslug']
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -165,8 +167,7 @@ var socket,
|
|||||||
|
|
||||||
clearTimeout(alert.attr('timeoutId'));
|
clearTimeout(alert.attr('timeoutId'));
|
||||||
startTimeout(alert, params.timeout);
|
startTimeout(alert, params.timeout);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var div = document.createElement('div'),
|
var div = document.createElement('div'),
|
||||||
button = document.createElement('button'),
|
button = document.createElement('button'),
|
||||||
strong = document.createElement('strong'),
|
strong = document.createElement('strong'),
|
||||||
|
|||||||
@@ -26,7 +26,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
followBtn.on('click', function() {
|
followBtn.on('click', function() {
|
||||||
socket.emit('api:user.follow', {uid: theirid}, function(success) {
|
socket.emit('api:user.follow', {
|
||||||
|
uid: theirid
|
||||||
|
}, function(success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
followBtn.hide();
|
followBtn.hide();
|
||||||
unfollowBtn.show();
|
unfollowBtn.show();
|
||||||
@@ -39,7 +41,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
unfollowBtn.on('click', function() {
|
unfollowBtn.on('click', function() {
|
||||||
socket.emit('api:user.unfollow', {uid: theirid}, function(success) {
|
socket.emit('api:user.unfollow', {
|
||||||
|
uid: theirid
|
||||||
|
}, function(success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
followBtn.show();
|
followBtn.show();
|
||||||
unfollowBtn.hide();
|
unfollowBtn.hide();
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
var gravatarPicture = templates.get('gravatarpicture');
|
var gravatarPicture = templates.get('gravatarpicture');
|
||||||
var uploadedPicture = templates.get('uploadedpicture');
|
var uploadedPicture = templates.get('uploadedpicture');
|
||||||
|
|
||||||
@@ -51,7 +49,9 @@ $(document).ready(function() {
|
|||||||
$('#upload-picture-modal').modal('hide');
|
$('#upload-picture-modal').modal('hide');
|
||||||
}, 750);
|
}, 750);
|
||||||
|
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
socket.emit('api:updateHeader', {
|
||||||
|
fields: ['username', 'picture', 'userslug']
|
||||||
|
});
|
||||||
success('File uploaded successfully!');
|
success('File uploaded successfully!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -131,15 +131,13 @@ $(document).ready(function() {
|
|||||||
if (gravatarPicture) {
|
if (gravatarPicture) {
|
||||||
$('#user-gravatar-picture').attr('src', gravatarPicture);
|
$('#user-gravatar-picture').attr('src', gravatarPicture);
|
||||||
$('#gravatar-box').show();
|
$('#gravatar-box').show();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$('#gravatar-box').hide();
|
$('#gravatar-box').hide();
|
||||||
|
|
||||||
if (uploadedPicture) {
|
if (uploadedPicture) {
|
||||||
$('#user-uploaded-picture').attr('src', uploadedPicture);
|
$('#user-uploaded-picture').attr('src', uploadedPicture);
|
||||||
$('#uploaded-box').show();
|
$('#uploaded-box').show();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$('#uploaded-box').hide();
|
$('#uploaded-box').hide();
|
||||||
|
|
||||||
|
|
||||||
@@ -263,7 +261,10 @@ $(document).ready(function() {
|
|||||||
$('#changePasswordBtn').on('click', function() {
|
$('#changePasswordBtn').on('click', function() {
|
||||||
|
|
||||||
if (passwordvalid && passwordsmatch && currentPassword.val()) {
|
if (passwordvalid && passwordsmatch && currentPassword.val()) {
|
||||||
socket.emit('api:user.changePassword', {'currentPassword': currentPassword.val(),'newPassword': password.val() }, function(err) {
|
socket.emit('api:user.changePassword', {
|
||||||
|
'currentPassword': currentPassword.val(),
|
||||||
|
'newPassword': password.val()
|
||||||
|
}, function(err) {
|
||||||
|
|
||||||
currentPassword.val('');
|
currentPassword.val('');
|
||||||
password.val('');
|
password.val('');
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#submitBtn').on('click', function() {
|
$('#submitBtn').on('click', function() {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
var modified_categories = {};
|
var modified_categories = {};
|
||||||
|
|
||||||
function modified(el) {
|
function modified(el) {
|
||||||
@@ -73,7 +72,9 @@ jQuery('.blockclass').each(function() {
|
|||||||
timeout: 2000
|
timeout: 2000
|
||||||
});
|
});
|
||||||
|
|
||||||
var html = templates.prepare(templates['admin/categories'].blocks['categories']).parse({categories:[data]});
|
var html = templates.prepare(templates['admin/categories'].blocks['categories']).parse({
|
||||||
|
categories: [data]
|
||||||
|
});
|
||||||
$('#entry-container').append(html);
|
$('#entry-container').append(html);
|
||||||
|
|
||||||
$('#new-category-modal').modal('hide');
|
$('#new-category-modal').modal('hide');
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var nodebb_admin = (function(nodebb_admin) {
|
var nodebb_admin = (function(nodebb_admin) {
|
||||||
|
|
||||||
nodebb_admin.config = undefined;
|
nodebb_admin.config = undefined;
|
||||||
@@ -63,7 +60,10 @@ var nodebb_admin = (function(nodebb_admin) {
|
|||||||
value = fields[x].value;
|
value = fields[x].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:config.set', { key: key, value: value });
|
socket.emit('api:config.set', {
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -119,4 +119,3 @@ var nodebb_admin = (function(nodebb_admin) {
|
|||||||
return nodebb_admin;
|
return nodebb_admin;
|
||||||
|
|
||||||
}(nodebb_admin || {}));
|
}(nodebb_admin || {}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
var nodebb_admin = (function(nodebb_admin) {
|
var nodebb_admin = (function(nodebb_admin) {
|
||||||
|
|
||||||
var themes = {};
|
var themes = {};
|
||||||
@@ -58,10 +56,12 @@ var nodebb_admin = (function(nodebb_admin) {
|
|||||||
cssSrc = parentEl.attr('data-css'),
|
cssSrc = parentEl.attr('data-css'),
|
||||||
cssName = parentEl.attr('data-theme');
|
cssName = parentEl.attr('data-theme');
|
||||||
socket.emit('api:config.set', {
|
socket.emit('api:config.set', {
|
||||||
key: 'theme:id', value: 'bootswatch:' + cssName
|
key: 'theme:id',
|
||||||
|
value: 'bootswatch:' + cssName
|
||||||
});
|
});
|
||||||
socket.emit('api:config.set', {
|
socket.emit('api:config.set', {
|
||||||
key: 'theme:src', value: cssSrc
|
key: 'theme:src',
|
||||||
|
value: cssSrc
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,28 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'pin':
|
case 'pin':
|
||||||
if (!$this.hasClass('active')) socket.emit('api:topic.pin', { tid: tid });
|
if (!$this.hasClass('active')) socket.emit('api:topic.pin', {
|
||||||
else socket.emit('api:topic.unpin', { tid: tid });
|
tid: tid
|
||||||
|
});
|
||||||
|
else socket.emit('api:topic.unpin', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'lock':
|
case 'lock':
|
||||||
if (!$this.hasClass('active')) socket.emit('api:topic.lock', { tid: tid });
|
if (!$this.hasClass('active')) socket.emit('api:topic.lock', {
|
||||||
else socket.emit('api:topic.unlock', { tid: tid });
|
tid: tid
|
||||||
|
});
|
||||||
|
else socket.emit('api:topic.unlock', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (!$this.hasClass('active')) socket.emit('api:topic.delete', { tid: tid });
|
if (!$this.hasClass('active')) socket.emit('api:topic.delete', {
|
||||||
else socket.emit('api:topic.restore', { tid: tid });
|
tid: tid
|
||||||
|
});
|
||||||
|
else socket.emit('api:topic.restore', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var yourid = templates.get('yourid');
|
var yourid = templates.get('yourid');
|
||||||
@@ -179,8 +178,7 @@
|
|||||||
.show()
|
.show()
|
||||||
.addClass('label-danger')
|
.addClass('label-danger')
|
||||||
.removeClass('label-success');
|
.removeClass('label-success');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$('#user-notfound-notify').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!')
|
$('#user-notfound-notify').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!')
|
||||||
.show()
|
.show()
|
||||||
.addClass('label-success')
|
.addClass('label-success')
|
||||||
@@ -191,7 +189,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function onUsersLoaded(users) {
|
function onUsersLoaded(users) {
|
||||||
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({ users: users });
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
||||||
|
users: users
|
||||||
|
});
|
||||||
$('#users-container').append(html);
|
$('#users-container').append(html);
|
||||||
updateUserButtons();
|
updateUserButtons();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,9 @@
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
function onNewTopic(data) {
|
function onNewTopic(data) {
|
||||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: [data] }),
|
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
||||||
|
topics: [data]
|
||||||
|
}),
|
||||||
topic = document.createElement('div'),
|
topic = document.createElement('div'),
|
||||||
container = document.getElementById('topics-container'),
|
container = document.getElementById('topics-container'),
|
||||||
topics = document.querySelectorAll('#topics-container a'),
|
topics = document.querySelectorAll('#topics-container a'),
|
||||||
@@ -98,7 +100,9 @@
|
|||||||
|
|
||||||
function onTopicsLoaded(topics) {
|
function onTopicsLoaded(topics) {
|
||||||
|
|
||||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: topics }),
|
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
||||||
|
topics: topics
|
||||||
|
}),
|
||||||
container = $('#topics-container');
|
container = $('#topics-container');
|
||||||
|
|
||||||
jQuery('#topics-container, .category-sidebar').removeClass('hidden');
|
jQuery('#topics-container, .category-sidebar').removeClass('hidden');
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('.user-favourite-posts .topic-row').on('click', function() {
|
$('.user-favourite-posts .topic-row').on('click', function() {
|
||||||
ajaxify.go($(this).attr('topic-url'));
|
ajaxify.go($(this).attr('topic-url'));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
@@ -13,13 +13,14 @@
|
|||||||
|
|
||||||
if (yourid !== theirid) {
|
if (yourid !== theirid) {
|
||||||
$('.unfollow-btn').hide();
|
$('.unfollow-btn').hide();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$('.unfollow-btn').on('click', function() {
|
$('.unfollow-btn').on('click', function() {
|
||||||
var unfollowBtn = $(this);
|
var unfollowBtn = $(this);
|
||||||
var followingUid = $(this).attr('followingUid');
|
var followingUid = $(this).attr('followingUid');
|
||||||
|
|
||||||
socket.emit('api:user.unfollow', {uid: followingUid}, function(success) {
|
socket.emit('api:user.unfollow', {
|
||||||
|
uid: followingUid
|
||||||
|
}, function(success) {
|
||||||
var username = unfollowBtn.attr('data-username');
|
var username = unfollowBtn.attr('data-username');
|
||||||
if (success) {
|
if (success) {
|
||||||
unfollowBtn.parent().remove();
|
unfollowBtn.parent().remove();
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
stats_online.innerHTML = data.users;
|
stats_online.innerHTML = data.users;
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
socket.emit('api:updateHeader', {
|
||||||
|
fields: ['username', 'picture', 'userslug']
|
||||||
|
});
|
||||||
socket.on('api:updateHeader', function(data) {
|
socket.on('api:updateHeader', function(data) {
|
||||||
|
|
||||||
jQuery('#search-button').on('click', function() {
|
jQuery('#search-button').on('click', function() {
|
||||||
@@ -134,9 +136,15 @@
|
|||||||
notifList.addEventListener('click', function(e) {
|
notifList.addEventListener('click', function(e) {
|
||||||
var target;
|
var target;
|
||||||
switch (e.target.nodeName) {
|
switch (e.target.nodeName) {
|
||||||
case 'SPAN': target = e.target.parentNode.parentNode; break;
|
case 'SPAN':
|
||||||
case 'A': target = e.target.parentNode; break;
|
target = e.target.parentNode.parentNode;
|
||||||
case 'li': target = e.target; break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
target = e.target.parentNode;
|
||||||
|
break;
|
||||||
|
case 'li':
|
||||||
|
target = e.target;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (target) {
|
if (target) {
|
||||||
var nid = parseInt(target.getAttribute('data-nid'));
|
var nid = parseInt(target.getAttribute('data-nid'));
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Alternate Logins
|
// Alternate Logins
|
||||||
var altLoginEl = document.querySelector('.alt-logins');
|
var altLoginEl = document.querySelector('.alt-logins');
|
||||||
altLoginEl.addEventListener('click', function(e) {
|
altLoginEl.addEventListener('click', function(e) {
|
||||||
var target;
|
var target;
|
||||||
switch (e.target.nodeName) {
|
switch (e.target.nodeName) {
|
||||||
case 'LI': target = e.target; break;
|
case 'LI':
|
||||||
case 'I': target = e.target.parentNode; break;
|
target = e.target;
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
target = e.target.parentNode;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (target) {
|
if (target) {
|
||||||
document.location.href = target.getAttribute('data-url');
|
document.location.href = target.getAttribute('data-url');
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
'event:new_post'
|
'event:new_post'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var newTopicCount = 0, newPostCount = 0;
|
var newTopicCount = 0,
|
||||||
|
newPostCount = 0;
|
||||||
|
|
||||||
$('#new-topics-alert').on('click', function() {
|
$('#new-topics-alert').on('click', function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
@@ -50,7 +51,9 @@
|
|||||||
|
|
||||||
function onTopicsLoaded(topics) {
|
function onTopicsLoaded(topics) {
|
||||||
|
|
||||||
var html = templates.prepare(templates['recent'].blocks['topics']).parse({ topics: topics }),
|
var html = templates.prepare(templates['recent'].blocks['topics']).parse({
|
||||||
|
topics: topics
|
||||||
|
}),
|
||||||
container = $('#topics-container');
|
container = $('#topics-container');
|
||||||
|
|
||||||
$('#category-no-topics').remove();
|
$('#category-no-topics').remove();
|
||||||
@@ -60,7 +63,9 @@
|
|||||||
|
|
||||||
function loadMoreTopics() {
|
function loadMoreTopics() {
|
||||||
loadingMoreTopics = true;
|
loadingMoreTopics = true;
|
||||||
socket.emit('api:topics.loadMoreRecentTopics', {after:$('#topics-container').children().length}, function(data) {
|
socket.emit('api:topics.loadMoreRecentTopics', {
|
||||||
|
after: $('#topics-container').children().length
|
||||||
|
}, function(data) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
onTopicsLoaded(data.topics);
|
onTopicsLoaded(data.topics);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,10 @@
|
|||||||
|
|
||||||
if (!utils.isEmailValid(emailEl.val())) {
|
if (!utils.isEmailValid(emailEl.val())) {
|
||||||
showError(email_notify, 'Invalid email address.');
|
showError(email_notify, 'Invalid email address.');
|
||||||
}
|
} else
|
||||||
else
|
socket.emit('user.email.exists', {
|
||||||
socket.emit('user.email.exists', { email: emailEl.val() });
|
email: emailEl.val()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
emailEl.on('blur', function() {
|
emailEl.on('blur', function() {
|
||||||
@@ -58,7 +59,9 @@
|
|||||||
} else if (!utils.isUserNameValid(username.val())) {
|
} else if (!utils.isUserNameValid(username.val())) {
|
||||||
showError(username_notify, 'Invalid username!');
|
showError(username_notify, 'Invalid username!');
|
||||||
} else {
|
} else {
|
||||||
socket.emit('user.exists', {username: username.val()});
|
socket.emit('user.exists', {
|
||||||
|
username: username.val()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
document.getElementById('reset').onclick = function() {
|
document.getElementById('reset').onclick = function() {
|
||||||
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) {
|
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) {
|
||||||
socket.emit('user:reset.send', { email: inputEl.value });
|
socket.emit('user:reset.send', {
|
||||||
|
email: inputEl.value
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
jQuery('#success').hide();
|
jQuery('#success').hide();
|
||||||
jQuery(errorEl).show();
|
jQuery(errorEl).show();
|
||||||
|
|||||||
@@ -18,12 +18,17 @@
|
|||||||
noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.';
|
noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.';
|
||||||
noticeEl.style.display = 'block';
|
noticeEl.style.display = 'block';
|
||||||
} else {
|
} else {
|
||||||
socket.emit('user:reset.commit', { code: reset_code, password: password.value });
|
socket.emit('user:reset.commit', {
|
||||||
|
code: reset_code,
|
||||||
|
password: password.value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// Enable the form if the code is valid
|
// Enable the form if the code is valid
|
||||||
socket.emit('user:reset.valid', { code: reset_code });
|
socket.emit('user:reset.valid', {
|
||||||
|
code: reset_code
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
ajaxify.register_events(['user:reset.valid', 'user:reset.commit']);
|
ajaxify.register_events(['user:reset.valid', 'user:reset.commit']);
|
||||||
|
|||||||
@@ -34,11 +34,15 @@
|
|||||||
$('#delete_thread').on('click', function(e) {
|
$('#delete_thread').on('click', function(e) {
|
||||||
if (thread_state.deleted !== '1') {
|
if (thread_state.deleted !== '1') {
|
||||||
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
|
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
|
||||||
if (confirm) socket.emit('api:topic.delete', { tid: tid });
|
if (confirm) socket.emit('api:topic.delete', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
bootbox.confirm('Are you sure you want to restore this thread?', function(confirm) {
|
bootbox.confirm('Are you sure you want to restore this thread?', function(confirm) {
|
||||||
if (confirm) socket.emit('api:topic.restore', { tid: tid });
|
if (confirm) socket.emit('api:topic.restore', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -46,18 +50,26 @@
|
|||||||
|
|
||||||
$('#lock_thread').on('click', function(e) {
|
$('#lock_thread').on('click', function(e) {
|
||||||
if (thread_state.locked !== '1') {
|
if (thread_state.locked !== '1') {
|
||||||
socket.emit('api:topic.lock', { tid: tid });
|
socket.emit('api:topic.lock', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topic.unlock', { tid: tid });
|
socket.emit('api:topic.unlock', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#pin_thread').on('click', function(e) {
|
$('#pin_thread').on('click', function(e) {
|
||||||
if (thread_state.pinned !== '1') {
|
if (thread_state.pinned !== '1') {
|
||||||
socket.emit('api:topic.pin', { tid: tid });
|
socket.emit('api:topic.pin', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topic.unpin', { tid: tid });
|
socket.emit('api:topic.unpin', {
|
||||||
|
tid: tid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -132,7 +144,10 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
socket.emit('api:topic.move', { tid: tid, cid: targetCid });
|
socket.emit('api:topic.move', {
|
||||||
|
tid: tid,
|
||||||
|
cid: targetCid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -242,7 +257,9 @@
|
|||||||
cmp.push(tid, null, null, quoted);
|
cmp.push(tid, null, null, quoted);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
socket.emit('api:posts.getRawPost', { pid: pid });
|
socket.emit('api:posts.getRawPost', {
|
||||||
|
pid: pid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -252,10 +269,15 @@
|
|||||||
|
|
||||||
var element = $(this).find('i');
|
var element = $(this).find('i');
|
||||||
if (element.attr('class') == 'icon-star-empty') {
|
if (element.attr('class') == 'icon-star-empty') {
|
||||||
socket.emit('api:posts.favourite', {pid: pid, room_id: app.current_room});
|
socket.emit('api:posts.favourite', {
|
||||||
}
|
pid: pid,
|
||||||
else {
|
room_id: app.current_room
|
||||||
socket.emit('api:posts.unfavourite', {pid: pid, room_id: app.current_room});
|
});
|
||||||
|
} else {
|
||||||
|
socket.emit('api:posts.unfavourite', {
|
||||||
|
pid: pid,
|
||||||
|
room_id: app.current_room
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -276,8 +298,12 @@
|
|||||||
|
|
||||||
if (confirmDel) {
|
if (confirmDel) {
|
||||||
deleteAction ?
|
deleteAction ?
|
||||||
socket.emit('api:posts.delete', { pid: pid }) :
|
socket.emit('api:posts.delete', {
|
||||||
socket.emit('api:posts.restore', { pid: pid });
|
pid: pid
|
||||||
|
}) :
|
||||||
|
socket.emit('api:posts.restore', {
|
||||||
|
pid: pid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -644,8 +670,7 @@
|
|||||||
var height = Math.floor(el.height());
|
var height = Math.floor(el.height());
|
||||||
var elBottom = elTop + (height < 300 ? height : 300);
|
var elBottom = elTop + (height < 300 ? height : 300);
|
||||||
|
|
||||||
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom)
|
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom) && (elBottom <= scrollBottom) && (elTop >= scrollTop));
|
||||||
&& (elBottom <= scrollBottom) && (elTop >= scrollTop));
|
|
||||||
|
|
||||||
|
|
||||||
if (inView) {
|
if (inView) {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
'event:new_post'
|
'event:new_post'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var newTopicCount = 0, newPostCount = 0;
|
var newTopicCount = 0,
|
||||||
|
newPostCount = 0;
|
||||||
|
|
||||||
$('#new-topics-alert').on('click', function() {
|
$('#new-topics-alert').on('click', function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
@@ -68,7 +69,9 @@
|
|||||||
|
|
||||||
function onTopicsLoaded(topics) {
|
function onTopicsLoaded(topics) {
|
||||||
|
|
||||||
var html = templates.prepare(templates['unread'].blocks['topics']).parse({ topics: topics }),
|
var html = templates.prepare(templates['unread'].blocks['topics']).parse({
|
||||||
|
topics: topics
|
||||||
|
}),
|
||||||
container = $('#topics-container');
|
container = $('#topics-container');
|
||||||
|
|
||||||
$('#category-no-topics').remove();
|
$('#category-no-topics').remove();
|
||||||
@@ -78,7 +81,9 @@
|
|||||||
|
|
||||||
function loadMoreTopics() {
|
function loadMoreTopics() {
|
||||||
loadingMoreTopics = true;
|
loadingMoreTopics = true;
|
||||||
socket.emit('api:topics.loadMoreUnreadTopics', {after:parseInt($('#topics-container').attr('data-next-start'), 10)}, function(data) {
|
socket.emit('api:topics.loadMoreUnreadTopics', {
|
||||||
|
after: parseInt($('#topics-container').attr('data-next-start'), 10)
|
||||||
|
}, function(data) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
onTopicsLoaded(data.topics);
|
onTopicsLoaded(data.topics);
|
||||||
$('#topics-container').attr('data-next-start', data.nextStart);
|
$('#topics-container').attr('data-next-start', data.nextStart);
|
||||||
|
|||||||
@@ -67,8 +67,7 @@
|
|||||||
if (data && data.length === 0) {
|
if (data && data.length === 0) {
|
||||||
$('#user-notfound-notify').html('User not found!');
|
$('#user-notfound-notify').html('User not found!');
|
||||||
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$('#user-notfound-notify').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!');
|
$('#user-notfound-notify').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!');
|
||||||
$('#user-notfound-notify').parent().addClass('btn-success label-success');
|
$('#user-notfound-notify').parent().addClass('btn-success label-success');
|
||||||
}
|
}
|
||||||
@@ -78,7 +77,9 @@
|
|||||||
|
|
||||||
|
|
||||||
function onUsersLoaded(users) {
|
function onUsersLoaded(users) {
|
||||||
var html = templates.prepare(templates['users'].blocks['users']).parse({ users: users });
|
var html = templates.prepare(templates['users'].blocks['users']).parse({
|
||||||
|
users: users
|
||||||
|
});
|
||||||
$('#users-container').append(html);
|
$('#users-container').append(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
(function(module) {
|
(function(module) {
|
||||||
|
|
||||||
var config = {},
|
var config = {},
|
||||||
@@ -252,7 +250,8 @@
|
|||||||
return template.replace(regex, block);
|
return template.replace(regex, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
var template = this.html, regex, block;
|
var template = this.html,
|
||||||
|
regex, block;
|
||||||
|
|
||||||
return (function parse(data, namespace, template) {
|
return (function parse(data, namespace, template) {
|
||||||
if (!data || data.length == 0) {
|
if (!data || data.length == 0) {
|
||||||
@@ -274,7 +273,9 @@
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var numblocks = data[d].length - 1, i = 0, result = "";
|
var numblocks = data[d].length - 1,
|
||||||
|
i = 0,
|
||||||
|
result = "";
|
||||||
|
|
||||||
do {
|
do {
|
||||||
result += parse(data[d][i], namespace, block);
|
result += parse(data[d][i], namespace, block);
|
||||||
@@ -312,7 +313,8 @@
|
|||||||
templates.init();
|
templates.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
})('undefined' === typeof module ? {module:{exports:{}}} : module)
|
})('undefined' === typeof module ? {
|
||||||
|
module: {
|
||||||
|
exports: {}
|
||||||
|
}
|
||||||
|
} : module)
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
module.exports = utils = {
|
module.exports = utils = {
|
||||||
generateUUID: function() {
|
generateUUID: function() {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
var r = Math.random() * 16 | 0,
|
||||||
|
v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -150,8 +151,7 @@
|
|||||||
badge
|
badge
|
||||||
.removeClass('badge-inverse')
|
.removeClass('badge-inverse')
|
||||||
.addClass('badge-important')
|
.addClass('badge-important')
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
badge
|
badge
|
||||||
.removeClass('badge-important')
|
.removeClass('badge-important')
|
||||||
.addClass('badge-inverse')
|
.addClass('badge-inverse')
|
||||||
@@ -167,19 +167,27 @@
|
|||||||
|
|
||||||
|
|
||||||
if (!String.prototype.trim) {
|
if (!String.prototype.trim) {
|
||||||
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};
|
String.prototype.trim = function() {
|
||||||
|
return this.replace(/^\s+|\s+$/g, '');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.prototype.ltrim) {
|
if (!String.prototype.ltrim) {
|
||||||
String.prototype.ltrim=function(){return this.replace(/^\s+/,'');};
|
String.prototype.ltrim = function() {
|
||||||
|
return this.replace(/^\s+/, '');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.prototype.rtrim) {
|
if (!String.prototype.rtrim) {
|
||||||
String.prototype.rtrim=function(){return this.replace(/\s+$/,'');};
|
String.prototype.rtrim = function() {
|
||||||
|
return this.replace(/\s+$/, '');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.prototype.fulltrim) {
|
if (!String.prototype.fulltrim) {
|
||||||
String.prototype.fulltrim=function(){return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');};
|
String.prototype.fulltrim = function() {
|
||||||
|
return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, '').replace(/\s+/g, ' ');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,4 +195,8 @@
|
|||||||
window.utils = module.exports;
|
window.utils = module.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
})('undefined' === typeof module ? {module:{exports:{}}} : module)
|
})('undefined' === typeof module ? {
|
||||||
|
module: {
|
||||||
|
exports: {}
|
||||||
|
}
|
||||||
|
} : module)
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="alert_window"></div>
|
||||||
|
|
||||||
<div id="footer" class="container" style="padding-top: 50px; display:none;">
|
<div id="footer" class="container" style="padding-top: 50px; display:none;">
|
||||||
<footer class="footer">Copyright © 2013 <a target="_blank" href="http://www.nodebb.com">NodeBB</a> by <a target="_blank" href="https://github.com/psychobunny">psychobunny</a>, <a href="https://github.com/julianlam" target="_blank">julianlam</a>, <a href="https://github.com/barisusakli" target="_blank">barisusakli</a> from <a target="_blank" href="http://www.designcreateplay.com">designcreateplay</a></footer>
|
<footer class="footer">Copyright © 2013 <a target="_blank" href="http://www.nodebb.com">NodeBB</a> by <a target="_blank" href="https://github.com/psychobunny">psychobunny</a>, <a href="https://github.com/julianlam" target="_blank">julianlam</a>, <a href="https://github.com/barisusakli" target="_blank">barisusakli</a> from <a target="_blank" href="http://www.designcreateplay.com">designcreateplay</a></footer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -63,8 +63,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="alert_window"></div>
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
||||||
<div class="post-signature">{main_posts.signature}</div>
|
<div class="post-signature">{main_posts.signature}</div>
|
||||||
<div class="profile-block">
|
<div class="post-info">
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
posted <span class="relativeTimeAgo">{main_posts.relativeTime} ago</span>
|
posted <span class="relativeTimeAgo">{main_posts.relativeTime} ago</span>
|
||||||
<span class="{main_posts.edited-class}">| last edited by <strong><a href="/users/{main_posts.editorslug}">{main_posts.editorname}</a></strong> {main_posts.relativeEditTime} ago</span>
|
<span class="{main_posts.edited-class}">| last edited by <strong><a href="/users/{main_posts.editorslug}">{main_posts.editorname}</a></strong> {main_posts.relativeEditTime} ago</span>
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
|
|
||||||
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
|
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
|
||||||
<div class="post-signature">{posts.signature}</div>
|
<div class="post-signature">{posts.signature}</div>
|
||||||
<div class="profile-block">
|
<div class="post-info">
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
posted <span class="relativeTimeAgo">{posts.relativeTime} ago</span>
|
posted <span class="relativeTimeAgo">{posts.relativeTime} ago</span>
|
||||||
<span class="{posts.edited-class}">| last edited by <strong><a href="/users/{posts.editorslug}">{posts.editorname}</a></strong> {posts.relativeEditTime} ago</span>
|
<span class="{posts.edited-class}">| last edited by <strong><a href="/users/{posts.editorslug}">{posts.editorname}</a></strong> {posts.relativeEditTime} ago</span>
|
||||||
|
|||||||
@@ -35,15 +35,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-block {
|
.main-post, .sub-posts {
|
||||||
|
.post-info {
|
||||||
background: rgba(0, 0, 0, 0.02);
|
background: rgba(0, 0, 0, 0.02);
|
||||||
margin: 15px -11px -11px -11px;
|
margin: 15px -11px -11px -11px;
|
||||||
border-radius: 0 0 5px 5px;
|
border-radius: 0 0 5px 5px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
line-height: 15px;
|
|
||||||
padding: 5px 8px 5px 5px;
|
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.active-users {
|
.active-users {
|
||||||
color: rgb(153,153,153);
|
color: rgb(153,153,153);
|
||||||
|
|||||||
@@ -42,10 +42,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.main-post, .sub-posts {
|
.main-post, .sub-posts {
|
||||||
.profile-block, .post-block {
|
.post-info, .post-block {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.06);
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
border-radius: 5px;
|
border-radius: 0 0 5px 5px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
.post-signature {
|
.post-signature {
|
||||||
@@ -64,6 +64,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.post-block {
|
.post-block {
|
||||||
|
border-radius: 5px;
|
||||||
|
|
||||||
.topic-buttons {
|
.topic-buttons {
|
||||||
background: rgba(0, 0, 0, 0.02);
|
background: rgba(0, 0, 0, 0.02);
|
||||||
border: 1px solid rgba(0, 0, 0, 0.06);
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
|||||||
@@ -106,4 +106,3 @@ var RDB = require('../redis'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
|
|
||||||
|
|||||||
@@ -312,7 +312,9 @@ var RDB = require('./redis.js'),
|
|||||||
|
|
||||||
Categories.getCategories = function(cids, callback, current_user) {
|
Categories.getCategories = function(cids, callback, current_user) {
|
||||||
if (!cids || !Array.isArray(cids) || cids.length === 0) {
|
if (!cids || !Array.isArray(cids) || cids.length === 0) {
|
||||||
callback({'categories' : []});
|
callback({
|
||||||
|
'categories': []
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +344,9 @@ var RDB = require('./redis.js'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback({'categories': categories});
|
callback({
|
||||||
|
'categories': categories
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (room_id) {
|
if (room_id) {
|
||||||
io.sockets.in(room_id).emit('event:rep_up', {uid: uid !== postData.uid ? postData.uid : 0, pid: pid});
|
io.sockets. in (room_id).emit('event:rep_up', {
|
||||||
|
uid: uid !== postData.uid ? postData.uid : 0,
|
||||||
|
pid: pid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:posts.favourite', {
|
socket.emit('api:posts.favourite', {
|
||||||
@@ -71,7 +74,10 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (room_id) {
|
if (room_id) {
|
||||||
io.sockets.in(room_id).emit('event:rep_down', {uid: uid !== uid_of_poster ? uid_of_poster : 0, pid: pid});
|
io.sockets. in (room_id).emit('event:rep_down', {
|
||||||
|
uid: uid !== uid_of_poster ? uid_of_poster : 0,
|
||||||
|
pid: pid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:posts.unfavourite', {
|
socket.emit('api:posts.unfavourite', {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
|
|
||||||
|
|
||||||
@@ -22,7 +20,10 @@ var request = require('request');
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var upload = post.form({type:type, image:image});
|
var upload = post.form({
|
||||||
|
type: type,
|
||||||
|
image: image
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
imgur.setClientID = function(id) {
|
imgur.setClientID = function(id) {
|
||||||
@@ -30,4 +31,3 @@ var request = require('request');
|
|||||||
}
|
}
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
|
|
||||||
|
|||||||
@@ -8,46 +8,38 @@ var async = require('async'),
|
|||||||
reds = require('reds'),
|
reds = require('reds'),
|
||||||
|
|
||||||
install = {
|
install = {
|
||||||
questions: [
|
questions: [{
|
||||||
{
|
|
||||||
name: 'base_url',
|
name: 'base_url',
|
||||||
description: 'URL of this installation',
|
description: 'URL of this installation',
|
||||||
'default': 'http://localhost',
|
'default': 'http://localhost',
|
||||||
pattern: /^http(?:s)?:\/\//,
|
pattern: /^http(?:s)?:\/\//,
|
||||||
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'port',
|
name: 'port',
|
||||||
description: 'Port number of your NodeBB',
|
description: 'Port number of your NodeBB',
|
||||||
'default': 4567
|
'default': 4567
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'use_port',
|
name: 'use_port',
|
||||||
description: 'Use a port number to access NodeBB?',
|
description: 'Use a port number to access NodeBB?',
|
||||||
'default': 'y',
|
'default': 'y',
|
||||||
pattern: /y[es]*|n[o]?/,
|
pattern: /y[es]*|n[o]?/,
|
||||||
message: 'Please enter \'yes\' or \'no\'',
|
message: 'Please enter \'yes\' or \'no\'',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'secret',
|
name: 'secret',
|
||||||
description: 'Please enter a NodeBB secret',
|
description: 'Please enter a NodeBB secret',
|
||||||
'default': utils.generateUUID()
|
'default': utils.generateUUID()
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'redis:host',
|
name: 'redis:host',
|
||||||
description: 'Host IP or address of your Redis instance',
|
description: 'Host IP or address of your Redis instance',
|
||||||
'default': '127.0.0.1'
|
'default': '127.0.0.1'
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'redis:port',
|
name: 'redis:port',
|
||||||
description: 'Host port of your Redis instance',
|
description: 'Host port of your Redis instance',
|
||||||
'default': 6379
|
'default': 6379
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'redis:password',
|
name: 'redis:password',
|
||||||
description: 'Password of your Redis database'
|
description: 'Password of your Redis database'
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
setup: function(callback) {
|
setup: function(callback) {
|
||||||
async.series([
|
async.series([
|
||||||
function(next) {
|
function(next) {
|
||||||
@@ -97,15 +89,28 @@ var async = require('async'),
|
|||||||
// Applying default database configs
|
// Applying default database configs
|
||||||
winston.info('Populating database with default configs, if not already set...')
|
winston.info('Populating database with default configs, if not already set...')
|
||||||
var meta = require('./meta'),
|
var meta = require('./meta'),
|
||||||
defaults = [
|
defaults = [{
|
||||||
{ field: 'postDelay', value: 10000 },
|
field: 'postDelay',
|
||||||
{ field: 'minimumPostLength', value: 8 },
|
value: 10000
|
||||||
{ field: 'minimumTitleLength', value: 3 },
|
}, {
|
||||||
{ field: 'minimumUsernameLength', value: 2 },
|
field: 'minimumPostLength',
|
||||||
{ field: 'maximumUsernameLength', value: 16 },
|
value: 8
|
||||||
{ field: 'minimumPasswordLength', value: 6 },
|
}, {
|
||||||
{ field: 'imgurClientID', value: '' }
|
field: 'minimumTitleLength',
|
||||||
];
|
value: 3
|
||||||
|
}, {
|
||||||
|
field: 'minimumUsernameLength',
|
||||||
|
value: 2
|
||||||
|
}, {
|
||||||
|
field: 'maximumUsernameLength',
|
||||||
|
value: 16
|
||||||
|
}, {
|
||||||
|
field: 'minimumPasswordLength',
|
||||||
|
value: 6
|
||||||
|
}, {
|
||||||
|
field: 'imgurClientID',
|
||||||
|
value: ''
|
||||||
|
}];
|
||||||
|
|
||||||
async.each(defaults, function(configObj, next) {
|
async.each(defaults, function(configObj, next) {
|
||||||
meta.configs.setOnEmpty(configObj.field, configObj.value, next);
|
meta.configs.setOnEmpty(configObj.field, configObj.value, next);
|
||||||
@@ -189,27 +194,23 @@ var async = require('async'),
|
|||||||
Groups = require('./groups');
|
Groups = require('./groups');
|
||||||
|
|
||||||
winston.warn('No administrators have been detected, running initial user setup');
|
winston.warn('No administrators have been detected, running initial user setup');
|
||||||
var questions = [
|
var questions = [{
|
||||||
{
|
|
||||||
name: 'username',
|
name: 'username',
|
||||||
description: 'Administrator username',
|
description: 'Administrator username',
|
||||||
required: true,
|
required: true,
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'email',
|
name: 'email',
|
||||||
description: 'Administrator email address',
|
description: 'Administrator email address',
|
||||||
pattern: /.+@.+/,
|
pattern: /.+@.+/,
|
||||||
required: true
|
required: true
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'password',
|
name: 'password',
|
||||||
description: 'Password',
|
description: 'Password',
|
||||||
required: true,
|
required: true,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
getAdminInfo = function(callback) {
|
getAdminInfo = function(callback) {
|
||||||
prompt.get(questions, function(err, results) {
|
prompt.get(questions, function(err, results) {
|
||||||
if (!results) return callback(new Error('aborted'));
|
if (!results) return callback(new Error('aborted'));
|
||||||
@@ -251,7 +252,9 @@ var async = require('async'),
|
|||||||
], function(err) {
|
], function(err) {
|
||||||
winston.info('Configuration Saved OK');
|
winston.info('Configuration Saved OK');
|
||||||
|
|
||||||
nconf.file({ file: path.join(__dirname, '..', 'config.json') });
|
nconf.file({
|
||||||
|
file: path.join(__dirname, '..', 'config.json')
|
||||||
|
});
|
||||||
|
|
||||||
var RDB = require('./redis');
|
var RDB = require('./redis');
|
||||||
reds.createClient = function() {
|
reds.createClient = function() {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
var user = require('./user.js'),
|
var user = require('./user.js'),
|
||||||
bcrypt = require('bcrypt'),
|
bcrypt = require('bcrypt'),
|
||||||
RDB = require('./redis.js'),
|
RDB = require('./redis.js'),
|
||||||
@@ -41,7 +40,11 @@ var user = require('./user.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
next(null, { user: { uid: uid } });
|
next(null, {
|
||||||
|
user: {
|
||||||
|
uid: uid
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
next(new Error('invalid-password'));
|
next(new Error('invalid-password'));
|
||||||
}
|
}
|
||||||
@@ -158,4 +161,3 @@ var user = require('./user.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
var RDB = require('./redis'),
|
var RDB = require('./redis'),
|
||||||
async = require('async');
|
async = require('async');
|
||||||
|
|
||||||
|
|||||||
@@ -130,4 +130,3 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PostTools.edit = function(uid, pid, title, content) {
|
PostTools.edit = function(uid, pid, title, content) {
|
||||||
var success = function() {
|
var success = function() {
|
||||||
posts.setPostField(pid, 'content', content);
|
posts.setPostField(pid, 'content', content);
|
||||||
@@ -77,7 +78,10 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
next(null, {tid:tid, isMainPost:isMainPost});
|
next(null, {
|
||||||
|
tid: tid,
|
||||||
|
isMainPost: isMainPost
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -85,12 +89,12 @@ var RDB = require('./redis.js'),
|
|||||||
PostTools.toHTML(content, next);
|
PostTools.toHTML(content, next);
|
||||||
}
|
}
|
||||||
], function(err, results) {
|
], function(err, results) {
|
||||||
console.log("TEEEST");
|
|
||||||
io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', {
|
io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
title: title,
|
title: title,
|
||||||
isMainPost: results[0].isMainPost,
|
isMainPost: results[0].isMainPost,
|
||||||
content: results[1]
|
content: results[1]
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
16
src/posts.js
16
src/posts.js
@@ -124,8 +124,7 @@ var RDB = require('./redis.js'),
|
|||||||
plugins.fireHook('filter:post.get', data, function(data) {
|
plugins.fireHook('filter:post.get', data, function(data) {
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -134,8 +133,7 @@ var RDB = require('./redis.js'),
|
|||||||
RDB.hmgetObject('post:' + pid, fields, function(err, data) {
|
RDB.hmgetObject('post:' + pid, fields, function(err, data) {
|
||||||
if (err === null) {
|
if (err === null) {
|
||||||
callback(data);
|
callback(data);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -245,7 +243,9 @@ var RDB = require('./redis.js'),
|
|||||||
threadTools.notify_followers(tid, uid);
|
threadTools.notify_followers(tid, uid);
|
||||||
|
|
||||||
Posts.addUserInfoToPost(postData, function() {
|
Posts.addUserInfoToPost(postData, function() {
|
||||||
var socketData = { posts: [postData] };
|
var socketData = {
|
||||||
|
posts: [postData]
|
||||||
|
};
|
||||||
io.sockets. in ('topic_' + tid).emit('event:new_post', socketData);
|
io.sockets. in ('topic_' + tid).emit('event:new_post', socketData);
|
||||||
io.sockets. in ('recent_posts').emit('event:new_post', socketData);
|
io.sockets. in ('recent_posts').emit('event:new_post', socketData);
|
||||||
io.sockets. in ('users/' + uid).emit('event:new_post', socketData);
|
io.sockets. in ('users/' + uid).emit('event:new_post', socketData);
|
||||||
@@ -374,8 +374,7 @@ var RDB = require('./redis.js'),
|
|||||||
Posts.getPostsByPids(pids, function(err, posts) {
|
Posts.getPostsByPids(pids, function(err, posts) {
|
||||||
callback(posts);
|
callback(posts);
|
||||||
});
|
});
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
callback([]);
|
callback([]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -389,8 +388,7 @@ var RDB = require('./redis.js'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('post.stats', stats);
|
socket.emit('post.stats', stats);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
callback(null, returnData);
|
callback(null, returnData);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
var user = require('./../user.js'),
|
var user = require('./../user.js'),
|
||||||
Groups = require('../groups'),
|
Groups = require('../groups'),
|
||||||
topics = require('./../topics.js'),
|
topics = require('./../topics.js'),
|
||||||
@@ -62,34 +61,59 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/admin/index', function(req, res) {
|
app.get('/api/admin/index', function(req, res) {
|
||||||
res.json({version:pkg.version});
|
res.json({
|
||||||
|
version: pkg.version
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/admin/users/search', function(req, res) {
|
app.get('/api/admin/users/search', function(req, res) {
|
||||||
res.json({search_display: 'block', loadmore_display:'none', users: []});
|
res.json({
|
||||||
|
search_display: 'block',
|
||||||
|
loadmore_display: 'none',
|
||||||
|
users: []
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/admin/users/latest', function(req, res) {
|
app.get('/api/admin/users/latest', function(req, res) {
|
||||||
user.getUsers('users:joindate', 0, 49, function(err, data) {
|
user.getUsers('users:joindate', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', loadmore_display:'block', users:data, yourid:req.user.uid });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
loadmore_display: 'block',
|
||||||
|
users: data,
|
||||||
|
yourid: req.user.uid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/admin/users/sort-posts', function(req, res) {
|
app.get('/api/admin/users/sort-posts', function(req, res) {
|
||||||
user.getUsers('users:postcount', 0, 49, function(err, data) {
|
user.getUsers('users:postcount', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', loadmore_display:'block', users:data, yourid:req.user.uid });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
loadmore_display: 'block',
|
||||||
|
users: data,
|
||||||
|
yourid: req.user.uid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/admin/users/sort-reputation', function(req, res) {
|
app.get('/api/admin/users/sort-reputation', function(req, res) {
|
||||||
user.getUsers('users:reputation', 0, 49, function(err, data) {
|
user.getUsers('users:reputation', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', loadmore_display:'block', users:data, yourid:req.user.uid });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
loadmore_display: 'block',
|
||||||
|
users: data,
|
||||||
|
yourid: req.user.uid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/admin/users', function(req, res) {
|
app.get('/api/admin/users', function(req, res) {
|
||||||
user.getUsers('users:joindate', 0, 49, function(err, data) {
|
user.getUsers('users:joindate', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', users:data, yourid:req.user.uid });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
users: data,
|
||||||
|
yourid: req.user.uid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,9 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/reset/:code', function(req, res) {
|
app.get('/api/reset/:code', function(req, res) {
|
||||||
res.json({ reset_code: req.params.code });
|
res.json({
|
||||||
|
reset_code: req.params.code
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/404', function(req, res) {
|
app.get('/api/404', function(req, res) {
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
callbackURL: nconf.get('url') + 'auth/twitter/callback'
|
callbackURL: nconf.get('url') + 'auth/twitter/callback'
|
||||||
}, function(token, tokenSecret, profile, done) {
|
}, function(token, tokenSecret, profile, done) {
|
||||||
login_module.loginViaTwitter(profile.id, profile.username, profile.photos, function(err, user) {
|
login_module.loginViaTwitter(profile.id, profile.username, profile.photos, function(err, user) {
|
||||||
if (err) { return done(err); }
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
done(null, user);
|
done(null, user);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -40,7 +42,9 @@
|
|||||||
callbackURL: nconf.get('url') + 'auth/google/callback'
|
callbackURL: nconf.get('url') + 'auth/google/callback'
|
||||||
}, function(accessToken, refreshToken, profile, done) {
|
}, function(accessToken, refreshToken, profile, done) {
|
||||||
login_module.loginViaGoogle(profile.id, profile.displayName, profile.emails[0].value, function(err, user) {
|
login_module.loginViaGoogle(profile.id, profile.displayName, profile.emails[0].value, function(err, user) {
|
||||||
if (err) { return done(err); }
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
done(null, user);
|
done(null, user);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -55,7 +59,9 @@
|
|||||||
callbackURL: nconf.get('url') + 'auth/facebook/callback'
|
callbackURL: nconf.get('url') + 'auth/facebook/callback'
|
||||||
}, function(accessToken, refreshToken, profile, done) {
|
}, function(accessToken, refreshToken, profile, done) {
|
||||||
login_module.loginViaFacebook(profile.id, profile.displayName, profile.emails[0].value, function(err, user) {
|
login_module.loginViaFacebook(profile.id, profile.displayName, profile.emails[0].value, function(err, user) {
|
||||||
if (err) { return done(err); }
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
done(null, user);
|
done(null, user);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -90,7 +96,10 @@
|
|||||||
winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
||||||
login_module.logout(req.sessionID, function(logout) {
|
login_module.logout(req.sessionID, function(logout) {
|
||||||
req.logout();
|
req.logout();
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + templates['logout'] + templates['footer']);
|
res.send(header + templates['logout'] + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -107,7 +116,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (login_strategies.indexOf('google') !== -1) {
|
if (login_strategies.indexOf('google') !== -1) {
|
||||||
app.get('/auth/google', passport.authenticate('google', { scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email' }));
|
app.get('/auth/google', passport.authenticate('google', {
|
||||||
|
scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
|
||||||
|
}));
|
||||||
|
|
||||||
app.get('/auth/google/callback', passport.authenticate('google', {
|
app.get('/auth/google/callback', passport.authenticate('google', {
|
||||||
successRedirect: '/',
|
successRedirect: '/',
|
||||||
@@ -116,7 +127,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (login_strategies.indexOf('facebook') !== -1) {
|
if (login_strategies.indexOf('facebook') !== -1) {
|
||||||
app.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));
|
app.get('/auth/facebook', passport.authenticate('facebook', {
|
||||||
|
scope: 'email'
|
||||||
|
}));
|
||||||
|
|
||||||
app.get('/auth/facebook/callback', passport.authenticate('facebook', {
|
app.get('/auth/facebook/callback', passport.authenticate('facebook', {
|
||||||
successRedirect: '/',
|
successRedirect: '/',
|
||||||
@@ -127,13 +140,19 @@
|
|||||||
|
|
||||||
|
|
||||||
app.get('/reset/:code', function(req, res) {
|
app.get('/reset/:code', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('reset/' + req.params.code) + templates['footer']);
|
res.send(header + app.create_route('reset/' + req.params.code) + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/reset', function(req, res) {
|
app.get('/reset', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('reset') + templates['footer']);
|
res.send(header + app.create_route('reset') + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -144,12 +163,18 @@
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.send({ success : false, message : info.message });
|
return res.send({
|
||||||
|
success: false,
|
||||||
|
message: info.message
|
||||||
|
});
|
||||||
}
|
}
|
||||||
req.login({
|
req.login({
|
||||||
uid: user.uid
|
uid: user.uid
|
||||||
}, function() {
|
}, function() {
|
||||||
res.send({ success : true, message : 'authentication succeeded' });
|
res.send({
|
||||||
|
success: true,
|
||||||
|
message: 'authentication succeeded'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})(req, res, next);
|
})(req, res, next);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
(function(TestBed) {
|
(function(TestBed) {
|
||||||
TestBed.create_routes = function(app) {
|
TestBed.create_routes = function(app) {
|
||||||
|
|
||||||
|
|||||||
@@ -18,38 +18,55 @@ var user = require('./../user.js'),
|
|||||||
if (data) {
|
if (data) {
|
||||||
res.send(data);
|
res.send(data);
|
||||||
} else {
|
} else {
|
||||||
res.json(404, {error:"User doesn't exist!"});
|
res.json(404, {
|
||||||
|
error: "User doesn't exist!"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users', function(req, res) {
|
app.get('/users', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("users", "users") + templates['footer']);
|
res.send(header + app.create_route("users", "users") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users-latest', function(req, res) {
|
app.get('/users-latest', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("users-latest", "users") + templates['footer']);
|
res.send(header + app.create_route("users-latest", "users") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users-sort-posts', function(req, res) {
|
app.get('/users-sort-posts', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("users-sort-posts", "users") + templates['footer']);
|
res.send(header + app.create_route("users-sort-posts", "users") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users-sort-reputation', function(req, res) {
|
app.get('/users-sort-reputation', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("users-sort-reputation", "users") + templates['footer']);
|
res.send(header + app.create_route("users-sort-reputation", "users") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users-search', function(req, res) {
|
app.get('/users-search', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("users-search", "users") + templates['footer']);
|
res.send(header + app.create_route("users-search", "users") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -66,7 +83,10 @@ var user = require('./../user.js'),
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('users/' + req.params.userslug, 'account') + templates['footer']);
|
res.send(header + app.create_route('users/' + req.params.userslug, 'account') + templates['footer']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -80,7 +100,10 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
user.getUserField(req.user.uid, 'userslug', function(err, userslug) {
|
user.getUserField(req.user.uid, 'userslug', function(err, userslug) {
|
||||||
if (req.params.userslug && userslug === req.params.userslug) {
|
if (req.params.userslug && userslug === req.params.userslug) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('users/' + req.params.userslug + '/edit', 'accountedit') + templates['footer']);
|
res.send(header + app.create_route('users/' + req.params.userslug + '/edit', 'accountedit') + templates['footer']);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -96,7 +119,10 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
user.getUserField(req.user.uid, 'userslug', function(err, userslug) {
|
user.getUserField(req.user.uid, 'userslug', function(err, userslug) {
|
||||||
if (req.params.userslug && userslug === req.params.userslug) {
|
if (req.params.userslug && userslug === req.params.userslug) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('users/' + req.params.userslug + '/settings', 'accountsettings') + templates['footer']);
|
res.send(header + app.create_route('users/' + req.params.userslug + '/settings', 'accountsettings') + templates['footer']);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -177,7 +203,9 @@ var user = require('./../user.js'),
|
|||||||
winston.err(err);
|
winston.err(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({ path: imageUrl });
|
res.json({
|
||||||
|
path: imageUrl
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -200,7 +228,10 @@ var user = require('./../user.js'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('users/' + req.params.userslug + '/following', 'following') + templates['footer']);
|
res.send(header + app.create_route('users/' + req.params.userslug + '/following', 'following') + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -216,7 +247,10 @@ var user = require('./../user.js'),
|
|||||||
res.redirect('/404');
|
res.redirect('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('users/' + req.params.userslug + '/followers', 'followers') + templates['footer']);
|
res.send(header + app.create_route('users/' + req.params.userslug + '/followers', 'followers') + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -232,7 +266,10 @@ var user = require('./../user.js'),
|
|||||||
res.redirect('/404');
|
res.redirect('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route('users/' + req.params.userslug + '/favourites', 'favourites') + templates['footer']);
|
res.send(header + app.create_route('users/' + req.params.userslug + '/favourites', 'favourites') + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -250,7 +287,9 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -266,7 +305,9 @@ var user = require('./../user.js'),
|
|||||||
res.json(userData);
|
res.json(userData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -284,12 +325,16 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
user.get_uid_by_userslug(req.params.userslug, function(err, uid) {
|
user.get_uid_by_userslug(req.params.userslug, function(err, uid) {
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uid !== callerUID || callerUID === "0") {
|
if (uid !== callerUID || callerUID === "0") {
|
||||||
res.json(403, { error: 'Not allowed!' });
|
res.json(403, {
|
||||||
|
error: 'Not allowed!'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.getUserFields(uid, ['username', 'userslug', 'showemail'], function(err, userData) {
|
user.getUserFields(uid, ['username', 'userslug', 'showemail'], function(err, userData) {
|
||||||
@@ -303,7 +348,9 @@ var user = require('./../user.js'),
|
|||||||
userData.showemail = "";
|
userData.showemail = "";
|
||||||
res.json(userData);
|
res.json(userData);
|
||||||
} else {
|
} else {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -314,12 +361,16 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
user.get_uid_by_userslug(req.params.userslug, function(err, uid) {
|
user.get_uid_by_userslug(req.params.userslug, function(err, uid) {
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uid !== callerUID || callerUID === "0") {
|
if (uid !== callerUID || callerUID === "0") {
|
||||||
res.json(403, { error: 'Not allowed!' });
|
res.json(403, {
|
||||||
|
error: 'Not allowed!'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +387,9 @@ var user = require('./../user.js'),
|
|||||||
res.json(userData);
|
res.json(userData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -350,7 +403,9 @@ var user = require('./../user.js'),
|
|||||||
user.isFollowing(callerUID, userData.theirid, function(isFollowing) {
|
user.isFollowing(callerUID, userData.theirid, function(isFollowing) {
|
||||||
posts.getPostsByUid(userData.theirid, 0, 9, function(posts) {
|
posts.getPostsByUid(userData.theirid, 0, 9, function(posts) {
|
||||||
|
|
||||||
userData.posts = posts.filter(function(p) {return p.deleted !== "1";});
|
userData.posts = posts.filter(function(p) {
|
||||||
|
return p.deleted !== "1";
|
||||||
|
});
|
||||||
userData.isFollowing = isFollowing;
|
userData.isFollowing = isFollowing;
|
||||||
if (!userData.profileviews)
|
if (!userData.profileviews)
|
||||||
userData.profileviews = 1;
|
userData.profileviews = 1;
|
||||||
@@ -364,7 +419,9 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.json(404, { error: 'User not found!' }) ;
|
res.json(404, {
|
||||||
|
error: 'User not found!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -378,24 +435,40 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
function getUsersSortedByJoinDate(req, res) {
|
function getUsersSortedByJoinDate(req, res) {
|
||||||
user.getUsers('users:joindate', 0, 49, function(err, data) {
|
user.getUsers('users:joindate', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', loadmore_display:'block', users:data });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
loadmore_display: 'block',
|
||||||
|
users: data
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsersSortedByPosts(req, res) {
|
function getUsersSortedByPosts(req, res) {
|
||||||
user.getUsers('users:postcount', 0, 49, function(err, data) {
|
user.getUsers('users:postcount', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', loadmore_display:'block', users:data });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
loadmore_display: 'block',
|
||||||
|
users: data
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsersSortedByReputation(req, res) {
|
function getUsersSortedByReputation(req, res) {
|
||||||
user.getUsers('users:reputation', 0, 49, function(err, data) {
|
user.getUsers('users:reputation', 0, 49, function(err, data) {
|
||||||
res.json({ search_display: 'none', loadmore_display:'block', users:data });
|
res.json({
|
||||||
|
search_display: 'none',
|
||||||
|
loadmore_display: 'block',
|
||||||
|
users: data
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsersForSearch(req, res) {
|
function getUsersForSearch(req, res) {
|
||||||
res.json({ search_display: 'block', loadmore_display:'none', users: [] });
|
res.json({
|
||||||
|
search_display: 'block',
|
||||||
|
loadmore_display: 'none',
|
||||||
|
users: []
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserDataByUserSlug(userslug, callerUID, callback) {
|
function getUserDataByUserSlug(userslug, callerUID, callback) {
|
||||||
|
|||||||
@@ -6,11 +6,19 @@ var path = require('path'),
|
|||||||
topics = require('./topics'),
|
topics = require('./topics'),
|
||||||
sitemap = {
|
sitemap = {
|
||||||
getStaticUrls: function(callback) {
|
getStaticUrls: function(callback) {
|
||||||
callback(null, [
|
callback(null, [{
|
||||||
{ url: '', changefreq: 'weekly', priority: '0.6' },
|
url: '',
|
||||||
{ url: 'recent', changefreq: 'daily', priority: '0.4' },
|
changefreq: 'weekly',
|
||||||
{ url: 'users', changefreq: 'daily', priority: '0.4' }
|
priority: '0.6'
|
||||||
]);
|
}, {
|
||||||
|
url: 'recent',
|
||||||
|
changefreq: 'daily',
|
||||||
|
priority: '0.4'
|
||||||
|
}, {
|
||||||
|
url: 'users',
|
||||||
|
changefreq: 'daily',
|
||||||
|
priority: '0.4'
|
||||||
|
}]);
|
||||||
},
|
},
|
||||||
getDynamicUrls: function(callback) {
|
getDynamicUrls: function(callback) {
|
||||||
var returnUrls = [];
|
var returnUrls = [];
|
||||||
|
|||||||
@@ -240,7 +240,9 @@ var RDB = require('./redis.js'),
|
|||||||
status: 'ok',
|
status: 'ok',
|
||||||
follow: true
|
follow: true
|
||||||
});
|
});
|
||||||
} else callback({ status: 'error' });
|
} else callback({
|
||||||
|
status: 'error'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -251,7 +253,9 @@ var RDB = require('./redis.js'),
|
|||||||
status: 'ok',
|
status: 'ok',
|
||||||
follow: false
|
follow: false
|
||||||
});
|
});
|
||||||
} else callback({ status: 'error' });
|
} else callback({
|
||||||
|
status: 'error'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,9 @@ var RDB = require('./redis.js')
|
|||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
async.whilst(
|
async.whilst(
|
||||||
function () { return unreadTids.length < 21 && !done; },
|
function() {
|
||||||
|
return unreadTids.length < 21 && !done;
|
||||||
|
},
|
||||||
function(callback) {
|
function(callback) {
|
||||||
RDB.zrevrange('topics:recent', start, stop, function(err, tids) {
|
RDB.zrevrange('topics:recent', start, stop, function(err, tids) {
|
||||||
|
|
||||||
@@ -197,7 +199,9 @@ var RDB = require('./redis.js')
|
|||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
async.whilst(
|
async.whilst(
|
||||||
function () { return unreadTids.length < 20 && !done; },
|
function() {
|
||||||
|
return unreadTids.length < 20 && !done;
|
||||||
|
},
|
||||||
function(callback) {
|
function(callback) {
|
||||||
RDB.zrevrange('topics:recent', start, stop, function(err, tids) {
|
RDB.zrevrange('topics:recent', start, stop, function(err, tids) {
|
||||||
if (err)
|
if (err)
|
||||||
@@ -266,6 +270,7 @@ var RDB = require('./redis.js')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// temporary. I don't think this call should belong here
|
// temporary. I don't think this call should belong here
|
||||||
|
|
||||||
function getPrivileges(next) {
|
function getPrivileges(next) {
|
||||||
categories.privileges(category_id, current_user, function(user_privs) {
|
categories.privileges(category_id, current_user, function(user_privs) {
|
||||||
next(null, user_privs);
|
next(null, user_privs);
|
||||||
@@ -438,7 +443,9 @@ var RDB = require('./redis.js')
|
|||||||
numTids, x;
|
numTids, x;
|
||||||
|
|
||||||
// Sort into ascending order
|
// Sort into ascending order
|
||||||
tids.sort(function(a, b) { return a - b; });
|
tids.sort(function(a, b) {
|
||||||
|
return a - b;
|
||||||
|
});
|
||||||
|
|
||||||
// Eliminate everything after the "after" tid
|
// Eliminate everything after the "after" tid
|
||||||
if (after) {
|
if (after) {
|
||||||
@@ -457,7 +464,9 @@ var RDB = require('./redis.js')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort into descending order
|
// Sort into descending order
|
||||||
tids.sort(function(a, b) { return b - a; });
|
tids.sort(function(a, b) {
|
||||||
|
return b - a;
|
||||||
|
});
|
||||||
|
|
||||||
async.each(tids, function(tid, next) {
|
async.each(tids, function(tid, next) {
|
||||||
Topics.getTopicDataWithUsername(tid, function(topicData) {
|
Topics.getTopicDataWithUsername(tid, function(topicData) {
|
||||||
@@ -688,7 +697,9 @@ var RDB = require('./redis.js')
|
|||||||
Topics.getTopicForCategoryView(tid, uid, function(topicData) {
|
Topics.getTopicForCategoryView(tid, uid, function(topicData) {
|
||||||
io.sockets. in ('category_' + category_id).emit('event:new_topic', topicData);
|
io.sockets. in ('category_' + category_id).emit('event:new_topic', topicData);
|
||||||
io.sockets. in ('recent_posts').emit('event:new_topic', topicData);
|
io.sockets. in ('recent_posts').emit('event:new_topic', topicData);
|
||||||
io.sockets.in('users/' + uid).emit('event:new_post', {posts:postData});
|
io.sockets. in ('users/' + uid).emit('event:new_post', {
|
||||||
|
posts: postData
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(null, postData);
|
callback(null, postData);
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ function upgradeCategory(cid, callback) {
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
RDB.rename('temp_categories:' + cid + ':tid', 'categories:' + cid + ':tid');
|
RDB.rename('temp_categories:' + cid + ':tid', 'categories:' + cid + ':tid');
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
94
src/user.js
94
src/user.js
@@ -87,7 +87,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
RDB.incr('usercount', function(err, count) {
|
RDB.incr('usercount', function(err, count) {
|
||||||
RDB.handle(err);
|
RDB.handle(err);
|
||||||
|
|
||||||
if (typeof io !== 'undefined') io.sockets.emit('user.count', {count: count});
|
if (typeof io !== 'undefined') io.sockets.emit('user.count', {
|
||||||
|
count: count
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
RDB.zadd('users:joindate', timestamp, uid);
|
RDB.zadd('users:joindate', timestamp, uid);
|
||||||
@@ -96,7 +98,10 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
userSearch.index(username, uid);
|
userSearch.index(username, uid);
|
||||||
|
|
||||||
if (typeof io !== 'undefined') io.sockets.emit('user.latest', {userslug: userslug, username: username});
|
if (typeof io !== 'undefined') io.sockets.emit('user.latest', {
|
||||||
|
userslug: userslug,
|
||||||
|
username: username
|
||||||
|
});
|
||||||
|
|
||||||
if (password !== undefined) {
|
if (password !== undefined) {
|
||||||
User.hashPassword(password, function(err, hash) {
|
User.hashPassword(password, function(err, hash) {
|
||||||
@@ -195,11 +200,15 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
User.updateProfile = function(uid, data, callback) {
|
User.updateProfile = function(uid, data, callback) {
|
||||||
|
|
||||||
var fields = ['email', 'fullname', 'website', 'location', 'birthday', 'signature'];
|
var fields = ['email', 'fullname', 'website', 'location', 'birthday', 'signature'];
|
||||||
var returnData = {success:false};
|
var returnData = {
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
|
||||||
function isSignatureValid(next) {
|
function isSignatureValid(next) {
|
||||||
if (data['signature'] !== undefined && data['signature'].length > 150) {
|
if (data['signature'] !== undefined && data['signature'].length > 150) {
|
||||||
next({error:'Signature can\'t be longer than 150 characters!'}, false);
|
next({
|
||||||
|
error: 'Signature can\'t be longer than 150 characters!'
|
||||||
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
next(null, true);
|
next(null, true);
|
||||||
}
|
}
|
||||||
@@ -216,7 +225,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
if (err)
|
if (err)
|
||||||
return next(err, null);
|
return next(err, null);
|
||||||
if (!available) {
|
if (!available) {
|
||||||
next({error:'Email not available!'}, false);
|
next({
|
||||||
|
error: 'Email not available!'
|
||||||
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
next(null, true);
|
next(null, true);
|
||||||
}
|
}
|
||||||
@@ -283,7 +294,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
User.changePassword = function(uid, data, callback) {
|
User.changePassword = function(uid, data, callback) {
|
||||||
if (!utils.isPasswordValid(data.newPassword)) {
|
if (!utils.isPasswordValid(data.newPassword)) {
|
||||||
return callback({error:'Invalid password!'});
|
return callback({
|
||||||
|
error: 'Invalid password!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
User.getUserField(uid, 'password', function(err, user_password) {
|
User.getUserField(uid, 'password', function(err, user_password) {
|
||||||
@@ -299,7 +312,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
callback(null);
|
callback(null);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback({error:'Your current password is not correct!'});
|
callback({
|
||||||
|
error: 'Your current password is not correct!'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -448,8 +463,12 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
if (meta.config['email:host'] && meta.config['email:port'] && meta.config['email:from']) {
|
if (meta.config['email:host'] && meta.config['email:port'] && meta.config['email:from']) {
|
||||||
var confirm_code = utils.generateUUID(),
|
var confirm_code = utils.generateUUID(),
|
||||||
confirm_link = nconf.get('url') + 'confirm/' + confirm_code,
|
confirm_link = nconf.get('url') + 'confirm/' + confirm_code,
|
||||||
confirm_email = global.templates['emails/header'] + global.templates['emails/email_confirm'].parse({'CONFIRM_LINK': confirm_link}) + global.templates['emails/footer'],
|
confirm_email = global.templates['emails/header'] + global.templates['emails/email_confirm'].parse({
|
||||||
confirm_email_plaintext = global.templates['emails/email_confirm_plaintext'].parse({ 'CONFIRM_LINK': confirm_link });
|
'CONFIRM_LINK': confirm_link
|
||||||
|
}) + global.templates['emails/footer'],
|
||||||
|
confirm_email_plaintext = global.templates['emails/email_confirm_plaintext'].parse({
|
||||||
|
'CONFIRM_LINK': confirm_link
|
||||||
|
});
|
||||||
|
|
||||||
// Email confirmation code
|
// Email confirmation code
|
||||||
var expiry_time = 60 * 60 * 2, // Expire after 2 hours
|
var expiry_time = 60 * 60 * 2, // Expire after 2 hours
|
||||||
@@ -467,12 +486,10 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
from: meta.config.mailer.from,
|
from: meta.config.mailer.from,
|
||||||
to: email,
|
to: email,
|
||||||
subject: '[NodeBB] Registration Email Verification',
|
subject: '[NodeBB] Registration Email Verification',
|
||||||
attachment: [
|
attachment: [{
|
||||||
{
|
|
||||||
data: confirm_email,
|
data: confirm_email,
|
||||||
alternative: true
|
alternative: true
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
emailjsServer.send(message, function(err, success) {
|
emailjsServer.send(message, function(err, success) {
|
||||||
@@ -612,7 +629,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
RDB.get('usercount', function(err, count) {
|
RDB.get('usercount', function(err, count) {
|
||||||
RDB.handle(err);
|
RDB.handle(err);
|
||||||
|
|
||||||
socket.emit('user.count', { count: count ? count : 0 });
|
socket.emit('user.count', {
|
||||||
|
count: count ? count : 0
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -622,7 +641,10 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
User.getUserFields(uid, ['username', 'userslug'], function(err, userData) {
|
User.getUserFields(uid, ['username', 'userslug'], function(err, userData) {
|
||||||
if (!err && userData)
|
if (!err && userData)
|
||||||
socket.emit('user.latest', {userslug: userData.userslug, username: userData.username});
|
socket.emit('user.latest', {
|
||||||
|
userslug: userData.userslug,
|
||||||
|
username: userData.username
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -771,7 +793,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
if (expiry >= +Date.now() / 1000 | 0) {
|
if (expiry >= +Date.now() / 1000 | 0) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
socket.emit('user:reset.valid', { valid: true });
|
socket.emit('user:reset.valid', {
|
||||||
|
valid: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(true);
|
callback(true);
|
||||||
}
|
}
|
||||||
@@ -780,7 +804,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
RDB.del('reset:' + code + ':uid');
|
RDB.del('reset:' + code + ':uid');
|
||||||
RDB.del('reset:' + code + ':expiry');
|
RDB.del('reset:' + code + ':expiry');
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
socket.emit('user:reset.valid', { valid: false });
|
socket.emit('user:reset.valid', {
|
||||||
|
valid: false
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
@@ -788,7 +814,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
socket.emit('user:reset.valid', { valid: false });
|
socket.emit('user:reset.valid', {
|
||||||
|
valid: false
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
@@ -804,20 +832,22 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
RDB.set('reset:' + reset_code + ':expiry', (60 * 60) + new Date() / 1000 | 0); // Active for one hour
|
RDB.set('reset:' + reset_code + ':expiry', (60 * 60) + new Date() / 1000 | 0); // Active for one hour
|
||||||
|
|
||||||
var reset_link = nconf.get('url') + 'reset/' + reset_code,
|
var reset_link = nconf.get('url') + 'reset/' + reset_code,
|
||||||
reset_email = global.templates['emails/reset'].parse({'RESET_LINK': reset_link}),
|
reset_email = global.templates['emails/reset'].parse({
|
||||||
reset_email_plaintext = global.templates['emails/reset_plaintext'].parse({ 'RESET_LINK': reset_link });
|
'RESET_LINK': reset_link
|
||||||
|
}),
|
||||||
|
reset_email_plaintext = global.templates['emails/reset_plaintext'].parse({
|
||||||
|
'RESET_LINK': reset_link
|
||||||
|
});
|
||||||
|
|
||||||
var message = emailjs.message.create({
|
var message = emailjs.message.create({
|
||||||
text: reset_email_plaintext,
|
text: reset_email_plaintext,
|
||||||
from: meta.config.mailer ? meta.config.mailer.from : 'localhost@example.org',
|
from: meta.config.mailer ? meta.config.mailer.from : 'localhost@example.org',
|
||||||
to: email,
|
to: email,
|
||||||
subject: 'Password Reset Requested',
|
subject: 'Password Reset Requested',
|
||||||
attachment: [
|
attachment: [{
|
||||||
{
|
|
||||||
data: reset_email,
|
data: reset_email,
|
||||||
alternative: true
|
alternative: true
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
emailjsServer.send(message, function(err, success) {
|
emailjsServer.send(message, function(err, success) {
|
||||||
@@ -860,7 +890,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
RDB.del('reset:' + code + ':uid');
|
RDB.del('reset:' + code + ':uid');
|
||||||
RDB.del('reset:' + code + ':expiry');
|
RDB.del('reset:' + code + ':expiry');
|
||||||
|
|
||||||
socket.emit('user:reset.commit', { status: 'ok' });
|
socket.emit('user:reset.commit', {
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -872,7 +904,9 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
User.get_uid_by_email(email, function(exists) {
|
User.get_uid_by_email(email, function(exists) {
|
||||||
exists = !! exists;
|
exists = !! exists;
|
||||||
if (typeof callback !== 'function') {
|
if (typeof callback !== 'function') {
|
||||||
socket.emit('user.email.exists', { exists: exists });
|
socket.emit('user.email.exists', {
|
||||||
|
exists: exists
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(exists);
|
callback(exists);
|
||||||
}
|
}
|
||||||
@@ -887,9 +921,13 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
if (email !== null) {
|
if (email !== null) {
|
||||||
RDB.set('email:' + email + ':confirm', true);
|
RDB.set('email:' + email + ':confirm', true);
|
||||||
RDB.del('confirm:' + code + ':email');
|
RDB.del('confirm:' + code + ':email');
|
||||||
callback({ status: 'ok' });
|
callback({
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback({ status: 'not_ok' });
|
callback({
|
||||||
|
status: 'not_ok'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
126
src/webserver.js
126
src/webserver.js
@@ -31,12 +31,19 @@ var express = require('express'),
|
|||||||
* accepts: metaTags
|
* accepts: metaTags
|
||||||
*/
|
*/
|
||||||
app.build_header = function(options, callback) {
|
app.build_header = function(options, callback) {
|
||||||
var defaultMetaTags = [
|
var defaultMetaTags = [{
|
||||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' },
|
name: 'viewport',
|
||||||
{ name: 'content-type', content: 'text/html; charset=UTF-8' },
|
content: 'width=device-width, initial-scale=1.0'
|
||||||
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
}, {
|
||||||
{ property: 'og:site_name', content: meta.config.title || 'NodeBB' },
|
name: 'content-type',
|
||||||
],
|
content: 'text/html; charset=UTF-8'
|
||||||
|
}, {
|
||||||
|
name: 'apple-mobile-web-app-capable',
|
||||||
|
content: 'yes'
|
||||||
|
}, {
|
||||||
|
property: 'og:site_name',
|
||||||
|
content: meta.config.title || 'NodeBB'
|
||||||
|
}, ],
|
||||||
metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),
|
metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),
|
||||||
templateValues = {
|
templateValues = {
|
||||||
cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',
|
cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',
|
||||||
@@ -58,7 +65,10 @@ var express = require('express'),
|
|||||||
|
|
||||||
// Middlewares
|
// Middlewares
|
||||||
app.use(express.favicon(path.join(__dirname, '../', 'public', 'favicon.ico')));
|
app.use(express.favicon(path.join(__dirname, '../', 'public', 'favicon.ico')));
|
||||||
app.use(require('less-middleware')({ src: path.join(__dirname, '../', 'public'), prefix:nconf.get('relative_path') }));
|
app.use(require('less-middleware')({
|
||||||
|
src: path.join(__dirname, '../', 'public'),
|
||||||
|
prefix: nconf.get('relative_path')
|
||||||
|
}));
|
||||||
app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public')));
|
app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public')));
|
||||||
app.use(express.bodyParser()); // Puts POST vars in request.body
|
app.use(express.bodyParser()); // Puts POST vars in request.body
|
||||||
|
|
||||||
@@ -138,7 +148,9 @@ var express = require('express'),
|
|||||||
|
|
||||||
// respond with json
|
// respond with json
|
||||||
if (req.accepts('json')) {
|
if (req.accepts('json')) {
|
||||||
res.send({ error: 'Not found' });
|
res.send({
|
||||||
|
error: 'Not found'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +167,9 @@ var express = require('express'),
|
|||||||
|
|
||||||
res.status(err.status || 500);
|
res.status(err.status || 500);
|
||||||
|
|
||||||
res.json('500', { error: err.message });
|
res.json('500', {
|
||||||
|
error: err.message
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +203,10 @@ var express = require('express'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route(route) + templates['footer']);
|
res.send(header + app.create_route(route) + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -204,12 +221,19 @@ var express = require('express'),
|
|||||||
app.build_header({
|
app.build_header({
|
||||||
req: req,
|
req: req,
|
||||||
res: res,
|
res: res,
|
||||||
metaTags: [
|
metaTags: [{
|
||||||
{ name: "title", content: meta.config.title || 'NodeBB' },
|
name: "title",
|
||||||
{ name: "description", content: meta.config.description || '' },
|
content: meta.config.title || 'NodeBB'
|
||||||
{ property: 'og:title', content: 'Index | ' + (meta.config.title || 'NodeBB') },
|
}, {
|
||||||
{ property: "og:type", content: 'website' }
|
name: "description",
|
||||||
]
|
content: meta.config.description || ''
|
||||||
|
}, {
|
||||||
|
property: 'og:title',
|
||||||
|
content: 'Index | ' + (meta.config.title || 'NodeBB')
|
||||||
|
}, {
|
||||||
|
property: "og:type",
|
||||||
|
content: 'website'
|
||||||
|
}]
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
"categories": function(next) {
|
"categories": function(next) {
|
||||||
@@ -275,16 +299,31 @@ var express = require('express'),
|
|||||||
app.build_header({
|
app.build_header({
|
||||||
req: req,
|
req: req,
|
||||||
res: res,
|
res: res,
|
||||||
metaTags: [
|
metaTags: [{
|
||||||
{ name: "title", content: topicData.topic_name },
|
name: "title",
|
||||||
{ property: 'og:title', content: topicData.topic_name + ' | ' + (meta.config.title || 'NodeBB') },
|
content: topicData.topic_name
|
||||||
{ property: "og:type", content: 'article' },
|
}, {
|
||||||
{ property: "og:url", content: nconf.get('url') + 'topic/' + topicData.slug },
|
property: 'og:title',
|
||||||
{ property: 'og:image', content: topicData.main_posts[0].picture },
|
content: topicData.topic_name + ' | ' + (meta.config.title || 'NodeBB')
|
||||||
{ property: "article:published_time", content: new Date(parseInt(topicData.main_posts[0].timestamp, 10)).toISOString() },
|
}, {
|
||||||
{ property: 'article:modified_time', content: new Date(lastMod).toISOString() },
|
property: "og:type",
|
||||||
{ property: 'article:section', content: topicData.category_name }
|
content: 'article'
|
||||||
]
|
}, {
|
||||||
|
property: "og:url",
|
||||||
|
content: nconf.get('url') + 'topic/' + topicData.slug
|
||||||
|
}, {
|
||||||
|
property: 'og:image',
|
||||||
|
content: topicData.main_posts[0].picture
|
||||||
|
}, {
|
||||||
|
property: "article:published_time",
|
||||||
|
content: new Date(parseInt(topicData.main_posts[0].timestamp, 10)).toISOString()
|
||||||
|
}, {
|
||||||
|
property: 'article:modified_time',
|
||||||
|
content: new Date(lastMod).toISOString()
|
||||||
|
}, {
|
||||||
|
property: 'article:section',
|
||||||
|
content: topicData.category_name
|
||||||
|
}]
|
||||||
}, function(err, header) {
|
}, function(err, header) {
|
||||||
next(err, {
|
next(err, {
|
||||||
header: header,
|
header: header,
|
||||||
@@ -344,11 +383,16 @@ var express = require('express'),
|
|||||||
app.build_header({
|
app.build_header({
|
||||||
req: req,
|
req: req,
|
||||||
res: res,
|
res: res,
|
||||||
metaTags: [
|
metaTags: [{
|
||||||
{ name: 'title', content: categoryData.category_name },
|
name: 'title',
|
||||||
{ name: 'description', content: categoryData.category_description },
|
content: categoryData.category_name
|
||||||
{ property: "og:type", content: 'website' }
|
}, {
|
||||||
]
|
name: 'description',
|
||||||
|
content: categoryData.category_description
|
||||||
|
}, {
|
||||||
|
property: "og:type",
|
||||||
|
content: 'website'
|
||||||
|
}]
|
||||||
}, function(err, header) {
|
}, function(err, header) {
|
||||||
next(err, {
|
next(err, {
|
||||||
header: header,
|
header: header,
|
||||||
@@ -370,7 +414,10 @@ var express = require('express'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/confirm/:code', function(req, res) {
|
app.get('/confirm/:code', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + '<script>templates.ready(function(){ajaxify.go("confirm/' + req.params.code + '");});</script>' + templates['footer']);
|
res.send(header + '<script>templates.ready(function(){ajaxify.go("confirm/' + req.params.code + '");});</script>' + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -421,7 +468,10 @@ var express = require('express'),
|
|||||||
app.get('/outgoing', function(req, res) {
|
app.get('/outgoing', function(req, res) {
|
||||||
if (!req.query.url) return res.redirect('/404');
|
if (!req.query.url) return res.redirect('/404');
|
||||||
|
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(
|
res.send(
|
||||||
header +
|
header +
|
||||||
'\n\t<script>templates.ready(function(){ajaxify.go("outgoing?url=' + encodeURIComponent(req.query.url) + '", null, null, true);});</script>' +
|
'\n\t<script>templates.ready(function(){ajaxify.go("outgoing?url=' + encodeURIComponent(req.query.url) + '", null, null, true);});</script>' +
|
||||||
@@ -431,13 +481,19 @@ var express = require('express'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/search', function(req, res) {
|
app.get('/search', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("search", null, "search") + templates['footer']);
|
res.send(header + app.create_route("search", null, "search") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/search/:term', function(req, res) {
|
app.get('/search/:term', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({
|
||||||
|
req: req,
|
||||||
|
res: res
|
||||||
|
}, function(err, header) {
|
||||||
res.send(header + app.create_route("search/" + req.params.term, null, "search") + templates['footer']);
|
res.send(header + app.create_route("search/" + req.params.term, null, "search") + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
var SocketIO = require('socket.io').listen(global.server, {
|
var SocketIO = require('socket.io').listen(global.server, {
|
||||||
log: false,
|
log: false,
|
||||||
transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket']
|
transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket']
|
||||||
@@ -58,7 +57,11 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
io.sockets. in ('global').emit('api:user.isOnline', isUserOnline(uid));
|
io.sockets. in ('global').emit('api:user.isOnline', isUserOnline(uid));
|
||||||
|
|
||||||
user.getUserField(uid, 'username', function(err, username) {
|
user.getUserField(uid, 'username', function(err, username) {
|
||||||
socket.emit('event:connect', {status: 1, username:username, uid:uid});
|
socket.emit('event:connect', {
|
||||||
|
status: 1,
|
||||||
|
username: username,
|
||||||
|
uid: uid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -191,13 +194,14 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
socket.emit('api:updateHeader', fields);
|
socket.emit('api:updateHeader', fields);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
socket.emit('api:updateHeader', {
|
socket.emit('api:updateHeader', {
|
||||||
uid: 0,
|
uid: 0,
|
||||||
username: "Anonymous User",
|
username: "Anonymous User",
|
||||||
email: '',
|
email: '',
|
||||||
picture: require('gravatar').url('', {s:'24'}, https=nconf.get('https'))
|
picture: require('gravatar').url('', {
|
||||||
|
s: '24'
|
||||||
|
}, https = nconf.get('https'))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +210,9 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
socket.on('user.exists', function(data) {
|
socket.on('user.exists', function(data) {
|
||||||
if (data.username) {
|
if (data.username) {
|
||||||
user.exists(utils.slugify(data.username), function(exists) {
|
user.exists(utils.slugify(data.username), function(exists) {
|
||||||
socket.emit('user.exists', {exists: exists});
|
socket.emit('user.exists', {
|
||||||
|
exists: exists
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -257,7 +263,10 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:user.isOnline', function(uid, callback) {
|
socket.on('api:user.isOnline', function(uid, callback) {
|
||||||
callback({online:isUserOnline(uid), timestamp:Date.now()});
|
callback({
|
||||||
|
online: isUserOnline(uid),
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:user.changePassword', function(data, callback) {
|
socket.on('api:user.changePassword', function(data, callback) {
|
||||||
@@ -483,7 +492,9 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
|
|
||||||
socket.on('api:posts.getRawPost', function(data) {
|
socket.on('api:posts.getRawPost', function(data) {
|
||||||
posts.getPostField(data.pid, 'content', function(raw) {
|
posts.getPostField(data.pid, 'content', function(raw) {
|
||||||
socket.emit('api:posts.getRawPost', { post: raw });
|
socket.emit('api:posts.getRawPost', {
|
||||||
|
post: raw
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -566,7 +577,12 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
numSockets = userSockets[touid].length;
|
numSockets = userSockets[touid].length;
|
||||||
|
|
||||||
for (var x = 0; x < numSockets; ++x) {
|
for (var x = 0; x < numSockets; ++x) {
|
||||||
userSockets[touid][x].emit('chatMessage', {fromuid:uid, username:username, message: finalMessage, timestamp: Date.now()});
|
userSockets[touid][x].emit('chatMessage', {
|
||||||
|
fromuid: uid,
|
||||||
|
username: username,
|
||||||
|
message: finalMessage,
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -575,7 +591,12 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
numSockets = userSockets[uid].length;
|
numSockets = userSockets[uid].length;
|
||||||
|
|
||||||
for (var x = 0; x < numSockets; ++x) {
|
for (var x = 0; x < numSockets; ++x) {
|
||||||
userSockets[uid][x].emit('chatMessage', {fromuid:touid, username:username, message:'You : ' + msg, timestamp: Date.now()});
|
userSockets[uid][x].emit('chatMessage', {
|
||||||
|
fromuid: touid,
|
||||||
|
username: username,
|
||||||
|
message: 'You : ' + msg,
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -590,7 +611,9 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
|
|
||||||
socket.on('api:config.set', function(data) {
|
socket.on('api:config.set', function(data) {
|
||||||
meta.configs.set(data.key, data.value, function(err) {
|
meta.configs.set(data.key, data.value, function(err) {
|
||||||
if (!err) socket.emit('api:config.set', { status: 'ok' });
|
if (!err) socket.emit('api:config.set', {
|
||||||
|
status: 'ok'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -692,7 +715,9 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
end = start + 9;
|
end = start + 9;
|
||||||
|
|
||||||
topics.getTopicPosts(data.tid, start, end, uid, function(posts) {
|
topics.getTopicPosts(data.tid, start, end, uid, function(posts) {
|
||||||
callback({posts:posts});
|
callback({
|
||||||
|
posts: posts
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -701,7 +726,9 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
end = start + 9;
|
end = start + 9;
|
||||||
|
|
||||||
categories.getCategoryTopics(data.cid, start, end, uid, function(topics) {
|
categories.getCategoryTopics(data.cid, start, end, uid, function(topics) {
|
||||||
callback({topics:topics});
|
callback({
|
||||||
|
topics: topics
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -731,7 +758,9 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
if (err) {
|
if (err) {
|
||||||
winston.err(err);
|
winston.err(err);
|
||||||
} else {
|
} else {
|
||||||
callback({users:data});
|
callback({
|
||||||
|
users: data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user