mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-01 20:30:07 +01:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
@@ -23,8 +23,7 @@ var ajaxify = {};
|
||||
|
||||
|
||||
window.onpopstate = function (event) {
|
||||
// "quiet": If set to true, will not call pushState
|
||||
if (event !== null && event.state && event.state.url !== undefined) {
|
||||
if (event !== null && event.state && event.state.url !== undefined && !ajaxify.initialLoad) {
|
||||
ajaxify.go(event.state.url, null, true);
|
||||
}
|
||||
};
|
||||
@@ -32,13 +31,10 @@ var ajaxify = {};
|
||||
var pagination, paginator_bar;
|
||||
|
||||
ajaxify.currentPage = null;
|
||||
ajaxify.initialLoad = false;
|
||||
|
||||
ajaxify.go = function (url, callback, quiet) {
|
||||
if ($('#content').hasClass('ajaxifying')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
jQuery('#footer, #content').addClass('ajaxifying');
|
||||
// "quiet": If set to true, will not call pushState
|
||||
|
||||
// start: the following should be set like so: ajaxify.onchange(function(){}); where the code actually belongs
|
||||
$(window).off('scroll');
|
||||
@@ -54,6 +50,9 @@ var ajaxify = {};
|
||||
window.onscroll = null;
|
||||
// end
|
||||
|
||||
if ($('#content').hasClass('ajaxifying')) {
|
||||
templates.cancelRequest();
|
||||
}
|
||||
|
||||
// Remove trailing slash
|
||||
url = url.replace(/\/$/, "");
|
||||
@@ -101,12 +100,11 @@ var ajaxify = {};
|
||||
|
||||
translator.load(tpl_url);
|
||||
|
||||
jQuery('#footer, #content').removeClass('hide');
|
||||
jQuery('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
||||
|
||||
templates.flush();
|
||||
templates.load_template(function () {
|
||||
exec_body_scripts(content);
|
||||
|
||||
require(['forum/' + tpl_url], function(script) {
|
||||
if (script && script.init) {
|
||||
script.init();
|
||||
@@ -176,6 +174,7 @@ var ajaxify = {};
|
||||
var url = this.href.replace(rootUrl + '/', '');
|
||||
|
||||
if (ajaxify.go(url)) {
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
} else if (window.location.pathname !== '/outgoing') {
|
||||
|
||||
@@ -366,7 +366,6 @@ define(['composer'], function(composer) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$('.topic').on('click', '.post_reply', function() {
|
||||
var selectionText = '',
|
||||
selection = window.getSelection() || document.getSelection();
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<script src="{relative_path}/vendor/requirejs/require.js"></script>
|
||||
<script src="{relative_path}/vendor/bootbox/bootbox.min.js"></script>
|
||||
<script src="{relative_path}/vendor/colorpicker/colorpicker.js"></script>
|
||||
<script src="{relative_path}/vendor/xregexp/xregexp.js"></script>
|
||||
<script src="{relative_path}/vendor/xregexp/unicode/unicode-base.js"></script>
|
||||
|
||||
<script>
|
||||
require.config({
|
||||
|
||||
@@ -27,7 +27,7 @@ var utils = require('../../public/src/utils'),
|
||||
UserAdmin.makeAdmin = function(uid, theirid, socket) {
|
||||
user.isAdministrator(uid, function(err, isAdmin) {
|
||||
if (isAdmin) {
|
||||
groups.getGidFromName('Administrators', function(err, gid) {
|
||||
groups.getGidFromName('administrators', function(err, gid) {
|
||||
groups.join(gid, theirid, function(err) {
|
||||
if (!err) {
|
||||
socket.emit('event:alert', {
|
||||
@@ -53,7 +53,7 @@ var utils = require('../../public/src/utils'),
|
||||
UserAdmin.removeAdmin = function(uid, theirid, socket) {
|
||||
user.isAdministrator(uid, function(err, isAdmin) {
|
||||
if (isAdmin) {
|
||||
groups.getGidFromName('Administrators', function(err, gid) {
|
||||
groups.getGidFromName('administrators', function(err, gid) {
|
||||
groups.leave(gid, theirid, function(err) {
|
||||
if (!err) {
|
||||
|
||||
|
||||
@@ -28,6 +28,18 @@
|
||||
});
|
||||
};
|
||||
|
||||
Groups.listSystemGroups = function(options, callback) {
|
||||
var systemGroups = ['administrators', 'registered-users'],
|
||||
humanNames = ['Administrators', 'Registered Users'];
|
||||
|
||||
async.map(systemGroups, function(groupName, next) {
|
||||
Groups.getByGroupName(groupName, options, function(err, groupObj) {
|
||||
groupObj['name'] = humanNames[systemGroups.indexOf(groupObj['name'])];
|
||||
next(err, groupObj);
|
||||
});
|
||||
}, callback);
|
||||
};
|
||||
|
||||
Groups.get = function(gid, options, callback) {
|
||||
async.parallel({
|
||||
base: function (next) {
|
||||
@@ -199,7 +211,26 @@
|
||||
Groups.update = function(gid, values, callback) {
|
||||
db.exists('gid:' + gid, function (err, exists) {
|
||||
if (!err && exists) {
|
||||
db.setObject('gid:' + gid, values, callback);
|
||||
// If the group was renamed, check for dupes, fix the assoc. hash
|
||||
if (values['name']) {
|
||||
Groups.exists(values['name'], function(err, exists) {
|
||||
if (!exists) {
|
||||
Groups.get(gid, {}, function(err, groupObj) {
|
||||
if (err) {
|
||||
return callback(new Error('group-not-found'));
|
||||
}
|
||||
|
||||
db.deleteObjectField('group:gid', groupObj['name']);
|
||||
db.setObjectField('group:gid', values['name'], gid);
|
||||
db.setObject('gid:' + gid, values, callback);
|
||||
});
|
||||
} else {
|
||||
callback(new Error('group-exists'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
db.setObject('gid:' + gid, values, callback);
|
||||
}
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(new Error('gid-not-found'));
|
||||
|
||||
@@ -282,7 +282,7 @@ var async = require('async'),
|
||||
// Check if an administrator needs to be created
|
||||
var Groups = require('./groups');
|
||||
|
||||
Groups.getGidFromName('Administrators', function (err, gid) {
|
||||
Groups.getGidFromName('administrators', function (err, gid) {
|
||||
if (err) {
|
||||
return next(err.message);
|
||||
}
|
||||
@@ -410,11 +410,11 @@ var async = require('async'),
|
||||
return callback(new Error('invalid-values'));
|
||||
}
|
||||
|
||||
Groups.getGidFromName('Administrators', function (err, gid) {
|
||||
Groups.getGidFromName('administrators', function (err, gid) {
|
||||
if (gid) {
|
||||
Groups.join(gid, uid, callback);
|
||||
} else {
|
||||
Groups.create('Administrators', 'Forum Administrators', function (err, groupObj) {
|
||||
Groups.create('administrators', 'Forum Administrators', function (err, groupObj) {
|
||||
Groups.join(groupObj.gid, uid, callback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -211,11 +211,20 @@ SocketAdmin.categories.setGroupPrivilege = function(socket, data, callback) {
|
||||
};
|
||||
|
||||
SocketAdmin.categories.groupsList = function(socket, cid, callback) {
|
||||
groups.list({expand:false}, function(err, data){
|
||||
async.parallel({
|
||||
groups: function(next) {
|
||||
groups.list({expand:false}, next);
|
||||
},
|
||||
system: function(next) {
|
||||
groups.listSystemGroups({expand: false}, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var data = results.groups.concat(results.system);
|
||||
|
||||
async.map(data, function(groupObj, next) {
|
||||
CategoryTools.groupPrivileges(cid, groupObj.gid, function(err, privileges) {
|
||||
if(err) {
|
||||
|
||||
@@ -17,7 +17,7 @@ var db = require('./database'),
|
||||
|
||||
Upgrade.check = function(callback) {
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
var latestSchema = new Date(2014, 0, 19, 22, 19).getTime();
|
||||
var latestSchema = new Date(2014, 0, 23, 16, 5).getTime();
|
||||
|
||||
db.get('schemaDate', function(err, value) {
|
||||
if (parseInt(value, 10) >= latestSchema) {
|
||||
@@ -299,6 +299,25 @@ Upgrade.upgrade = function(callback) {
|
||||
winston.info('[2014/1/19] Remove user search from Reds -- skipped');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = new Date(2014, 0, 23, 16, 5).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
|
||||
Groups.getByGroupName('Administrators', {}, function(err, groupObj) {
|
||||
Groups.update(groupObj.gid, {
|
||||
name: 'administrators',
|
||||
hidden: '1'
|
||||
}, function() {
|
||||
winston.info('[2014/1/23] Updating Administrators Group');
|
||||
next();
|
||||
});
|
||||
})
|
||||
} else {
|
||||
winston.info('[2014/1/23] Updating Administrators Group -- skipped');
|
||||
next();
|
||||
}
|
||||
}
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!
|
||||
|
||||
@@ -780,7 +780,7 @@ var bcrypt = require('bcrypt'),
|
||||
};
|
||||
|
||||
User.isAdministrator = function(uid, callback) {
|
||||
groups.getGidFromName('Administrators', function(err, gid) {
|
||||
groups.getGidFromName('administrators', function(err, gid) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -400,7 +400,12 @@ if(nconf.get('ssl')) {
|
||||
};
|
||||
|
||||
app.create_route = function (url, tpl) { // to remove
|
||||
return '<script>templates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '", true);});</script>';
|
||||
var routerScript = '<script> \
|
||||
ajaxify.initialLoad = true; \
|
||||
templates.ready(function(){ajaxify.go("' + url + '", null, true);}); \
|
||||
</script>';
|
||||
|
||||
return routerScript;
|
||||
};
|
||||
|
||||
app.namespace(nconf.get('relative_path'), function () {
|
||||
@@ -648,8 +653,7 @@ if(nconf.get('ssl')) {
|
||||
res.send(
|
||||
data.header +
|
||||
'\n\t<noscript>\n' + templates['noscript/header'] + templates['noscript/topic'].parse(data.topics) + '\n\t</noscript>' +
|
||||
'\n\t<script>templates.ready(function(){ajaxify.go("topic/' + topic_url + '", undefined, undefined, true);});</script>' +
|
||||
templates.footer
|
||||
'\n\t' + app.create_route('topic/' + topic_url) + templates.footer
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -763,8 +767,7 @@ if(nconf.get('ssl')) {
|
||||
res.send(
|
||||
data.header +
|
||||
'\n\t<noscript>\n' + templates['noscript/header'] + templates['noscript/category'].parse(data.categories) + '\n\t</noscript>' +
|
||||
'\n\t<script>templates.ready(function(){ajaxify.go("category/' + category_url + '", undefined, undefined, true);});</script>' +
|
||||
templates.footer
|
||||
'\n\t' + app.create_route('category/' + category_url) + templates.footer
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -774,7 +777,7 @@ if(nconf.get('ssl')) {
|
||||
req: req,
|
||||
res: res
|
||||
}, function (err, header) {
|
||||
res.send(header + '<script>templates.ready(function(){ajaxify.go("confirm/' + req.params.code + '", undefined, undefined, true);});</script>' + templates.footer);
|
||||
res.send(header + app.create_route('confirm/' + req.params.code) + templates.footer);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -845,11 +848,7 @@ if(nconf.get('ssl')) {
|
||||
req: req,
|
||||
res: res
|
||||
}, function (err, header) {
|
||||
res.send(
|
||||
header +
|
||||
'\n\t<script>templates.ready(function(){ajaxify.go("outgoing?url=' + encodeURIComponent(req.query.url) + '", null, null, true);});</script>' +
|
||||
templates.footer
|
||||
);
|
||||
res.send(header + app.create_route('outgoing?url=' + encodeURIComponent(req.query.url)) + templates.footer);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// this test currently needs to talk to the redis database.
|
||||
// get the redis config info from root directory's config.json:
|
||||
|
||||
var winston = require('winston');
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
@@ -59,4 +58,4 @@ describe('Categories', function() {
|
||||
db.delete('category:' + categoryObj.cid);
|
||||
db.listRemoveLast('categories:cid');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user