Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit 9c55b202e7

@ -44,11 +44,18 @@ var nconf = require('nconf'),
nconf.argv(); nconf.argv();
// Start the daemon!
if (nconf.get('d')) { if (nconf.get('d')) {
// Check for a still-active NodeBB process // Check for a still-active NodeBB process
if (fs.existsSync(pidFilePath)) { if (fs.existsSync(pidFilePath)) {
console.log('\n Error: Another NodeBB is already running!'); try {
process.exit(); var pid = fs.readFileSync(pidFilePath, { encoding: 'utf-8' });
process.kill(pid, 0);
console.log('\n Error: Another NodeBB is already running!');
process.exit();
} catch (e) {
fs.unlinkSync(pidFilePath);
}
} }
// Initialise logging streams // Initialise logging streams

@ -303,7 +303,9 @@ define(['uploader'], function(uploader) {
} }
var numResults = results.length, var numResults = results.length,
trEl, trEl,
resultObj; resultObj;
groupsResultsEl.empty();
for(var x = 0; x < numResults; x++) { for(var x = 0; x < numResults; x++) {
resultObj = results[x]; resultObj = results[x];

@ -24,9 +24,9 @@ define(function() {
createSubmitBtn.on('click', function() { createSubmitBtn.on('click', function() {
var submitObj = { var submitObj = {
name: createNameEl.val(), name: createNameEl.val(),
description: $('#create-group-desc').val() description: $('#create-group-desc').val()
}, },
errorEl = $('#create-modal-error'), errorEl = $('#create-modal-error'),
errorText; errorText;
@ -91,8 +91,9 @@ define(function() {
groupMembersEl.empty(); groupMembersEl.empty();
for (x = 0; x < numMembers; x++) { for (x = 0; x < numMembers; x++) {
var memberIcon = $('<li />') var memberIcon = $('<li />')
.attr('data-uid', groupObj.members[x].uid)
.append($('<img />').attr('src', groupObj.members[x].picture)) .append($('<img />').attr('src', groupObj.members[x].picture))
.append($('<span />').attr('data-uid', groupObj.members[x].uid).html(groupObj.members[x].username)); .append($('<span />').html(groupObj.members[x].username));
groupMembersEl.append(memberIcon); groupMembersEl.append(memberIcon);
} }
} }
@ -127,7 +128,7 @@ define(function() {
.append($('<img />').attr('src', results.users[x].picture)) .append($('<img />').attr('src', results.users[x].picture))
.append($('<span />').html(results.users[x].username)); .append($('<span />').html(results.users[x].username));
resultsEl.appendChild(foundUser); resultsEl.append(foundUser);
} }
} else { } else {
resultsEl.html('<li>No Users Found</li>'); resultsEl.html('<li>No Users Found</li>');
@ -152,7 +153,7 @@ define(function() {
uid: uid uid: uid
}, function(err, data) { }, function(err, data) {
if (!err) { if (!err) {
groupMembersEl.append(userLabel.cloneNode(true)); groupMembersEl.append(userLabel.clone(true));
} }
}); });
} }
@ -164,10 +165,6 @@ define(function() {
socket.emit('admin.groups.get', gid, function(err, groupObj){ socket.emit('admin.groups.get', gid, function(err, groupObj){
if (!err){ if (!err){
if (groupObj.name == 'Administrators' && uid == yourid){
bootbox.alert('You cannot remove yourself from the Administrator Group');
return;
}
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) { bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
if (confirm){ if (confirm){
socket.emit('admin.groups.leave', { socket.emit('admin.groups.leave', {

@ -17,8 +17,6 @@ define(function() {
return pagination.loadPage(pagination.currentPage - 1); return pagination.loadPage(pagination.currentPage - 1);
}).on('click', '.next', function() { }).on('click', '.next', function() {
return pagination.loadPage(pagination.currentPage + 1); return pagination.loadPage(pagination.currentPage + 1);
}).on('click', '.page', function() {
return pagination.loadPage($(this).attr('data-page'));
}).on('click', '.select_page', function(e) { }).on('click', '.select_page', function(e) {
e.preventDefault(); e.preventDefault();
bootbox.prompt('Enter page number:', function(pageNum) { bootbox.prompt('Enter page number:', function(pageNum) {
@ -77,7 +75,11 @@ define(function() {
return false; return false;
} }
ajaxify.go(window.location.pathname.slice(1) + '?page=' + page); ajaxify.go(window.location.pathname.slice(1) + '?page=' + page, function() {
if (typeof callback === 'function') {
callback();
}
});
return true; return true;
} }

@ -309,7 +309,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
var bookmark = localStorage.getItem('topic:' + tid + ':bookmark'); var bookmark = localStorage.getItem('topic:' + tid + ':bookmark');
if (window.location.hash) { if (window.location.hash) {
Topic.scrollToPost(window.location.hash.substr(1), true); Topic.scrollToPost(window.location.hash.substr(1), true);
} else if (bookmark) { } else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1))) {
app.alert({ app.alert({
alert_id: 'bookmark', alert_id: 'bookmark',
message: '[[topic:bookmark_instructions]]', message: '[[topic:bookmark_instructions]]',
@ -324,7 +324,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
}); });
} }
updateHeader(); if (!window.location.hash && !config.usePagination) {
updateHeader();
}
$('#post-container').on('mouseenter', '.favourite-tooltip', function(e) { $('#post-container').on('mouseenter', '.favourite-tooltip', function(e) {
if (!$(this).data('users-loaded')) { if (!$(this).data('users-loaded')) {
@ -1037,26 +1039,29 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
if(index > Topic.postCount) { if(index > Topic.postCount) {
index = Topic.postCount; index = Topic.postCount;
} }
$('#pagination').html(index + ' out of ' + Topic.postCount); $('#pagination').html(index + ' out of ' + Topic.postCount);
$('.progress-bar').width((index / Topic.postCount * 100) + '%'); $('.progress-bar').width((index / Topic.postCount * 100) + '%');
if(!parseInt(el.attr('data-index'), 10)) { var currentBookmark = localStorage.getItem('topic:' + templates.get('topic_id') + ':bookmark');
localStorage.removeItem('topic:' + templates.get('topic_id') + ':bookmark'); if (!currentBookmark || parseInt(el.attr('data-pid'), 10) > parseInt(currentBookmark, 10)) {
} else {
localStorage.setItem('topic:' + templates.get('topic_id') + ':bookmark', el.attr('data-pid')); localStorage.setItem('topic:' + templates.get('topic_id') + ':bookmark', el.attr('data-pid'));
}
if (!scrollingToPost) { if (!scrollingToPost) {
var newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid')
if (newUrl !== currentUrl) { var newUrl = window.location.href.replace(window.location.hash, '') + '#' + el.attr('data-pid');
if (history.replaceState) {
history.replaceState({ if (newUrl !== currentUrl) {
url: window.location.pathname.slice(1) + '#' + el.attr('data-pid') if (history.replaceState) {
}, null, newUrl); history.replaceState({
} url: window.location.pathname.slice(1) + (window.location.search ? window.location.search : '' ) + '#' + el.attr('data-pid')
currentUrl = newUrl; }, null, newUrl);
} }
currentUrl = newUrl;
} }
} }
return false; return false;
} }
}); });
@ -1090,7 +1095,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
return; return;
} }
if(parseInt(page, 10) !== pagination.currentPage) { if(parseInt(page, 10) !== pagination.currentPage) {
pagination.loadPage(page); pagination.loadPage(page, function() {
scrollToPid(pid);
});
} else { } else {
scrollToPid(pid); scrollToPid(pid);
} }
@ -1106,6 +1113,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
if(after < 0) { if(after < 0) {
after = 0; after = 0;
} }
loadMorePosts(tid, after, function() { loadMorePosts(tid, after, function() {
scrollToPid(pid); scrollToPid(pid);
}); });
@ -1123,6 +1131,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
scrollTop: (scrollTo.offset().top - $('#header-menu').height() - offset) + "px" scrollTop: (scrollTo.offset().top - $('#header-menu').height() - offset) + "px"
}, duration !== undefined ? duration : 400, function() { }, duration !== undefined ? duration : 400, function() {
scrollingToPost = false; scrollingToPost = false;
updateHeader();
if (highlight) { if (highlight) {
scrollTo.parent().find('.topic-item').addClass('highlight'); scrollTo.parent().find('.topic-item').addClass('highlight');
setTimeout(function() { setTimeout(function() {

@ -115,7 +115,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<!-- BEGIN ips --> <!-- BEGIN ips -->
{ips.ip} <div>{ips.ip}</div>
<!-- END ips --> <!-- END ips -->
</div> </div>
</div> </div>

@ -28,6 +28,7 @@
<script> <script>
var RELATIVE_PATH = "{relative_path}"; var RELATIVE_PATH = "{relative_path}";
</script> </script>
<script src="{relative_path}/socket.io/socket.io.js"></script>
<!-- BEGIN clientScripts --> <!-- BEGIN clientScripts -->
<script src="{relative_path}/{clientScripts.script}?{cache-buster}"></script> <script src="{relative_path}/{clientScripts.script}?{cache-buster}"></script>
<!-- END clientScripts --> <!-- END clientScripts -->

@ -261,7 +261,10 @@ var fs = require('fs'),
}).filter(function(a) { return a; }); }).filter(function(a) { return a; });
if (matches.length) { if (matches.length) {
var relPath = jsPath.slice(new String('plugins/' + matches[0]).length); var relPath = jsPath.slice(new String('plugins/' + matches[0]).length),
pluginId = matches[0].split(path.sep)[0];
winston.warn('[meta.scripts.get (' + pluginId + ')] filter:scripts.get is deprecated, consider using "scripts" in plugin.json');
return plugins.staticDirs[matches[0]] + relPath; return plugins.staticDirs[matches[0]] + relPath;
} else { } else {
winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?'); winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
@ -275,9 +278,6 @@ var fs = require('fs'),
// Remove scripts that could not be found (remove this line at v0.5.0) // Remove scripts that could not be found (remove this line at v0.5.0)
Meta.js.scripts = jsPaths.filter(function(path) { return path !== null }); Meta.js.scripts = jsPaths.filter(function(path) { return path !== null });
// Add socket.io client library
Meta.js.scripts.push(path.join(__dirname, '../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js'));
// Add plugin scripts // Add plugin scripts
Meta.js.scripts = Meta.js.scripts.concat(plugins.clientScripts); Meta.js.scripts = Meta.js.scripts.concat(plugins.clientScripts);
@ -288,32 +288,34 @@ var fs = require('fs'),
}, },
minify: function (callback) { minify: function (callback) {
var uglifyjs = require('uglify-js'), var uglifyjs = require('uglify-js'),
jsPaths = this.scripts,
minified; minified;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
winston.info('Minifying client-side libraries'); winston.info('Minifying client-side libraries');
} }
minified = uglifyjs.minify(jsPaths); minified = uglifyjs.minify(this.scripts);
this.cache = minified.code; this.cache = minified.code;
callback(); callback();
}, },
compress: function(callback) { concatenate: function(callback) {
var uglifyjs = require('uglify-js'),
jsPaths = this.scripts,
compressed;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
winston.info('Compressing client-side libraries into one file'); winston.info('Concatenating client-side libraries into one file');
} }
minified = uglifyjs.minify(jsPaths, { async.map(this.scripts, function(path, next) {
mangle: false, fs.readFile(path, { encoding: 'utf-8' }, next);
compress: false }, function(err, contents) {
if (err) {
winston.error('[meta.js.concatenate] Could not minify javascript! Error: ' + err.message);
process.exit();
}
Meta.js.cache = contents.reduce(function(output, src) {
return output.length ? output + ';\n' + src : src;
}, '');
callback();
}); });
this.cache = minified.code;
callback();
} }
}; };

@ -233,7 +233,7 @@ var fs = require('fs'),
} }
Plugins.clientScripts = Plugins.clientScripts.concat(pluginData.scripts.map(function(file) { Plugins.clientScripts = Plugins.clientScripts.concat(pluginData.scripts.map(function(file) {
return path.join(pluginData.id, file); return path.join(__dirname, '../node_modules/', pluginData.id, file);
})); }));
} }

@ -57,7 +57,7 @@ var path = require('path'),
}); });
} else { } else {
// Compress only // Compress only
meta.js.compress(function() { meta.js.concatenate(function() {
sendCached(); sendCached();
}); });
} }

@ -864,6 +864,12 @@ Upgrade.upgrade = function(callback) {
if(err) { if(err) {
return next(err); return next(err);
} }
// If there was no order present, put it at the end
if (!order) {
order = cids.length;
}
db.sortedSetAdd('categories:cid', order, cid, next); db.sortedSetAdd('categories:cid', order, cid, next);
}); });
}, function(err) { }, function(err) {

Loading…
Cancel
Save