From 56bbeb9950102f18d81c7546a36663fd7a6c21a0 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 26 Feb 2014 17:16:55 -0500 Subject: [PATCH 01/26] use disableSocialButtons from config --- public/templates/category.tpl | 4 ++-- public/templates/topic.tpl | 4 ++-- src/categories.js | 1 - src/routes/api.js | 1 + src/topics.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/templates/category.tpl b/public/templates/category.tpl index d536a201cb..25bc8c0a31 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -17,13 +17,13 @@ - +
     
- +
diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 3b6cfa72e8..6b58c9f8a8 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -99,11 +99,11 @@ diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 4a5aa70794..decbae43da 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -18,6 +18,13 @@ + + diff --git a/src/routes/admin.js b/src/routes/admin.js index d04ac78b80..1741f62c6f 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -109,20 +109,22 @@ var nconf = require('nconf'), return res.redirect('/403'); } - var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']; - var params = null; + var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'], + params = null, er; try { params = JSON.parse(req.body.params); } catch (e) { - return res.send({ + er = { error: 'Error uploading file! Error :' + e.message - }); + }; + return res.send(req.xhr ? er : JSON.stringify(er)); } if (allowedTypes.indexOf(req.files.userPhoto.type) === -1) { - res.send({ + er = { error: 'Allowed image types are png, jpg and gif!' - }); + }; + res.send(req.xhr ? er : JSON.stringify(er)); return; } @@ -136,12 +138,12 @@ var nconf = require('nconf'), return res.redirect('/403'); } - var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon']; + var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon'], + er; if (allowedTypes.indexOf(req.files.userPhoto.type) === -1) { - res.send({ - error: 'You can only upload icon file type!' - }); + er = {error: 'You can only upload icon file type!'}; + res.send(req.xhr ? er : JSON.stringify(er)); return; } @@ -149,14 +151,12 @@ var nconf = require('nconf'), fs.unlink(req.files.userPhoto.path); if(err) { - return res.send({ - error: err.message - }); + er = {error: err.message}; + return res.send(req.xhr ? er : JSON.stringify(er)); } - res.json({ - path: image.url - }); + var rs = {path: image.url}; + res.send(req.xhr ? rs : JSON.stringify(rs)); }); }); @@ -166,12 +166,12 @@ var nconf = require('nconf'), return res.redirect('/403'); } - var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']; + var allowedTypes = ['image/png', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/gif'], + er; if (allowedTypes.indexOf(req.files.userPhoto.type) === -1) { - res.send({ - error: 'Allowed image types are png, jpg and gif!' - }); + er = {error: 'Allowed image types are png, jpg and gif!'}; + res.send(req.xhr ? er : JSON.stringify(er)); return; } @@ -191,17 +191,16 @@ var nconf = require('nconf'), function uploadImage(filename, req, res) { function done(err, image) { + var er, rs; fs.unlink(req.files.userPhoto.path); if(err) { - return res.send({ - error: err.message - }); + er = {error: err.message}; + return res.send(req.xhr ? er : JSON.stringify(er)); } - res.json({ - path: image.url - }); + rs = {path: image.url}; + res.send(req.xhr ? rs : JSON.stringify(rs)); } if(plugins.hasListeners('filter:uploadImage')) { diff --git a/src/routes/api.js b/src/routes/api.js index 7cdd7a8589..df7cd85488 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -455,16 +455,25 @@ var path = require('path'), async.map(files, filesIterator, function(err, images) { deleteTempFiles(); + if(err) { - return res.json(500, err.message); + return res.send(500, err.message); } - res.json(200, images); + + // if this was not a XMLHttpRequest (hence the req.xhr check http://expressjs.com/api.html#req.xhr) + // then most likely it's submit via the iFrame workaround, via the jquery.form plugin's ajaxSubmit() + // we need to send it as text/html so IE8 won't trigger a file download for the json response + // malsup.com/jquery/form/#file-upload + + // Also, req.send is safe for both types, if the response was an object, res.send will automatically submit as application/json + // expressjs.com/api.html#res.send + res.send(200, req.xhr ? images : JSON.stringify(images)); }); } app.post('/post/upload', function(req, res, next) { upload(req, res, function(file, next) { - if(file.type.match('image.*')) { + if(file.type.match(/image./)) { posts.uploadPostImage(file, next); } else { posts.uploadPostFile(file, next); @@ -474,7 +483,7 @@ var path = require('path'), app.post('/topic/thumb/upload', function(req, res, next) { upload(req, res, function(file, next) { - if(file.type.match('image.*')) { + if(file.type.match(/image./)) { topics.uploadTopicThumb(file, next); } else { res.json(500, {message: 'Invalid File'}); From d87034b131f9cca080a14a7b71b144e1330c6b60 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 26 Feb 2014 21:58:04 -0500 Subject: [PATCH 11/26] use alert for bookmark --- public/language/en_GB/topic.json | 2 + public/src/app.js | 63 ++++++++++++++++++-------------- public/src/forum/topic.js | 21 ++++++++--- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/public/language/en_GB/topic.json b/public/language/en_GB/topic.json index e03bada393..085f8df821 100644 --- a/public/language/en_GB/topic.json +++ b/public/language/en_GB/topic.json @@ -22,6 +22,8 @@ "tools": "Tools", "flag": "Flag", + "bookmark_instructions" : "Click here to return to your last position or close to discard.", + "flag_title": "Flag this post for moderation", "deleted_message": "This thread has been deleted. Only users with thread management privileges can see it.", diff --git a/public/src/app.js b/public/src/app.js index 39cfc8e7b3..9e7b1af06a 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -175,23 +175,27 @@ var socket, var alert = $('#' + alert_id); var title = params.title || ''; - function startTimeout(div, timeout) { + function fadeOut() { + alert.fadeOut(500, function () { + $(this).remove(); + }); + } + + function startTimeout(timeout) { var timeoutId = setTimeout(function () { - $(div).fadeOut(1000, function () { - $(this).remove(); - }); + fadeOut(); }, timeout); - $(div).attr('timeoutId', timeoutId); + alert.attr('timeoutId', timeoutId); } if (alert.length > 0) { alert.find('strong').html(title); alert.find('p').html(params.message); - alert.attr('class', "alert alert-dismissable alert-" + params.type); + alert.attr('class', 'alert alert-dismissable alert-' + params.type); clearTimeout(alert.attr('timeoutId')); - startTimeout(alert, params.timeout); + startTimeout(params.timeout); alert.children().fadeOut('100'); translator.translate(alert.html(), function(translatedHTML) { @@ -199,42 +203,45 @@ var socket, alert.html(translatedHTML); }); } else { - var div = $('
'), - button = $(''), - strong = $('' + title + ''), - p = $('

' + params.message + '

'); + alert = $('
'); - div.append(button) - .append(strong) - .append(p); + alert.append($('')) + .append($('' + title + '')) + .append($('

' + params.message + '

')); - button.on('click', function () { - div.remove(); - }); - - if (params.location == null) + if (params.location == null) { params.location = 'alert_window'; + } - translator.translate(div.html(), function(translatedHTML) { - div.html(translatedHTML); - $('#' + params.location).prepend(div.fadeIn('100')); + translator.translate(alert.html(), function(translatedHTML) { + alert.html(translatedHTML); + $('#' + params.location).prepend(alert.fadeIn('100')); + + if(typeof params.closefn === 'function') { + alert.find('button').on('click', function () { + params.closefn(); + fadeOut(); + }); + } }); if (params.timeout) { - startTimeout(div, params.timeout); + startTimeout(params.timeout); } - if (params.clickfn) { - div.on('click', function () { + if (typeof params.clickfn === 'function') { + alert.on('click', function () { params.clickfn(); - div.fadeOut(500, function () { - $(this).remove(); - }); + fadeOut(); }); } } }; + app.removeAlert = function(id) { + $('#' + 'alert_button_' + id).remove(); + } + app.alertSuccess = function (message, timeout) { if (!timeout) timeout = 2000; diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index f10839ec0e..d220494b86 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -14,6 +14,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { if(data.url.indexOf('topic') !== 0) { $('.pagination-block').addClass('hide'); $('#header-topic-title').html('').hide(); + app.removeAlert('bookmark'); } }); @@ -310,7 +311,18 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { if (window.location.hash) { Topic.scrollToPost(window.location.hash.substr(1), true); } else if (bookmark) { - Topic.scrollToPost(parseInt(bookmark, 10), true); + app.alert({ + alert_id: 'bookmark', + message: '[[topic:bookmark_instructions]]', + timeout: 0, + type: 'info', + clickfn : function() { + Topic.scrollToPost(parseInt(bookmark, 10), true); + }, + closefn : function() { + localStorage.removeItem('topic:' + tid + ':bookmark'); + } + }); } else { updateHeader(); } @@ -1023,11 +1035,10 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { var el = $(this); if (elementInView(el)) { - var index = parseInt(el.attr('data-index'), 10) + 1; - if(index === 0) { - localStorage.removeItem("topic:" + templates.get('topic_id') + ":bookmark"); + if(!parseInt(el.attr('data-index'), 10)) { + localStorage.removeItem('topic:' + templates.get('topic_id') + ':bookmark'); } 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) { var newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid') From 72aa22d8243d6403cc3706c2e4d8017be4345079 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 26 Feb 2014 22:19:01 -0500 Subject: [PATCH 12/26] removed unused timestamp --- public/src/templates.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 2ac8f0b7fb..f3b239866d 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -199,8 +199,6 @@ var template_data = null; - var timestamp = new Date().getTime(); //debug - if (!templates[tpl_url]) { templates.preload_template(tpl_url, function() { parse_template(); From 0070e1158e0539d20da19ad965ce6bd251da9718 Mon Sep 17 00:00:00 2001 From: akhoury Date: Wed, 26 Feb 2014 22:32:09 -0500 Subject: [PATCH 13/26] removing a boolean left out from the addEventListener definition --- public/src/forum/admin/groups.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/forum/admin/groups.js b/public/src/forum/admin/groups.js index 2e68c929f6..c5b69e8743 100644 --- a/public/src/forum/admin/groups.js +++ b/public/src/forum/admin/groups.js @@ -20,7 +20,7 @@ define(function() { setTimeout(function() { createNameEl.focus(); }, 250); - }, false); + }); createSubmitBtn.on('click', function() { var submitObj = { From 2209a55afc1dd6666759ce929ef062070260cbef Mon Sep 17 00:00:00 2001 From: akhoury Date: Wed, 26 Feb 2014 23:34:03 -0500 Subject: [PATCH 14/26] - changes per PR conversation --- public/src/ajaxify.js | 1 + public/src/forum/topic.js | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 03ea7f1a1d..8681ceec1b 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -125,6 +125,7 @@ var ajaxify = {}; if (!renderedWidgets.length) { $('body [no-widget-class]').each(function() { var $this = $(this); + $this.removeClass(); $this.addClass($this.attr('no-widget-class')); }); } diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index d92e5ba58f..5c59f20ffa 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -1034,11 +1034,6 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { history.replaceState({ url: window.location.pathname.slice(1) + '#' + el.attr('data-pid') }, null, newUrl); - } else { - // this is very slugish on IE8/9, it causes the browser to adjust its scroll on its own, - // it can be fixed, but too much work for a very little return just so ie8/9 users can have the hash updated - // commenting it out, sorry - // location.hash = '#' + el.attr('data-pid'); } currentUrl = newUrl; } From dcd3975933a66df6862e3a2593926a7541866f6c Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Thu, 27 Feb 2014 00:45:29 -0500 Subject: [PATCH 15/26] closes #1135 --- public/templates/admin/header.tpl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl index 6e04b32dc5..66a6f87187 100644 --- a/public/templates/admin/header.tpl +++ b/public/templates/admin/header.tpl @@ -7,7 +7,9 @@ var RELATIVE_PATH = "{relative_path}"; + + @@ -34,7 +36,7 @@ } }); - + From fb1313ec90ff093dd28aed205f9b7882ee82bd06 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Thu, 27 Feb 2014 01:32:20 -0500 Subject: [PATCH 16/26] load config change --- app.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index 8ad89c8ade..665944644b 100644 --- a/app.js +++ b/app.js @@ -82,8 +82,7 @@ if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf displayHelp(); }; - -function start() { +function loadConfig() { nconf.file({ file: configFile }); @@ -92,13 +91,18 @@ function start() { themes_path: path.join(__dirname, 'node_modules') }); + // Ensure themes_path is a full filepath + nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path'))); +} + + +function start() { + loadConfig(); + nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path')); nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep)); nconf.set('base_dir', __dirname); - // Ensure themes_path is a full filepath - nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path'))); - winston.info('Time: ' + new Date()); winston.info('Initializing NodeBB v' + pkg.version); winston.info('* using configuration stored in: ' + configFile); @@ -157,16 +161,14 @@ function start() { } function setup() { + loadConfig(); + if (nconf.get('setup')) { winston.info('NodeBB Setup Triggered via Command Line'); } else { winston.warn('Configuration not found, starting NodeBB setup'); } - nconf.file({ - file: __dirname + '/config.json' - }); - var install = require('./src/install'); winston.info('Welcome to NodeBB!'); @@ -185,9 +187,7 @@ function setup() { } function upgrade() { - nconf.file({ - file: __dirname + '/config.json' - }); + loadConfig(); var meta = require('./src/meta'); @@ -199,9 +199,7 @@ function upgrade() { } function reset() { - nconf.file({ - file: __dirname + '/config.json' - }); + loadConfig(); var meta = require('./src/meta'), db = require('./src/database'), From b8c089cfaa33a94dcd29bc33217fe58ab601c8b9 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Thu, 27 Feb 2014 01:43:24 -0500 Subject: [PATCH 17/26] added check for invalid tags --- src/webserver.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/webserver.js b/src/webserver.js index 58ea6ae479..f4869b4cbf 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -148,6 +148,11 @@ process.on('uncaughtException', function(err) { // Meta Tags templateValues.metaTags = defaultMetaTags.concat(options.metaTags || []).map(function(tag) { + if(!tag || !tag.content) { + winston.warn('Invalid meta tag. ' + tag); + return tag; + } + tag.content = tag.content.replace(/[&<>'"]/g, function(tag) { return escapeList[tag] || tag; }); From 38e4a6c8b068dbcc9126c92636ec04e09838f02b Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Thu, 27 Feb 2014 01:51:33 -0500 Subject: [PATCH 18/26] better check --- src/webserver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webserver.js b/src/webserver.js index f4869b4cbf..b7028efc5c 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -148,8 +148,8 @@ process.on('uncaughtException', function(err) { // Meta Tags templateValues.metaTags = defaultMetaTags.concat(options.metaTags || []).map(function(tag) { - if(!tag || !tag.content) { - winston.warn('Invalid meta tag. ' + tag); + if(!tag || typeof tag.content !== 'string') { + winston.warn('Invalid meta tag. ', tag); return tag; } From 5b301772bb0a1b6c9cc4fd5ba72371a23a9b5cf8 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Feb 2014 10:06:31 -0500 Subject: [PATCH 19/26] added daemon capability to ./nodebb start, npm start/stop scripts --- loader.js | 77 ++++++++++++++++++++++++++++++++++++------------ logs/.gitignore | 1 + nodebb | 14 ++++++++- package.json | 5 +++- src/webserver.js | 2 +- 5 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 logs/.gitignore diff --git a/loader.js b/loader.js index 2263955ef9..3bb103d417 100644 --- a/loader.js +++ b/loader.js @@ -1,26 +1,65 @@ -var fork = require('child_process').fork, - start = function() { - nbb = fork('./app', process.argv.slice(2), { - env: { - 'NODE_ENV': process.env.NODE_ENV - } - }); +"use strict"; - nbb.on('message', function(cmd) { - if (cmd === 'nodebb:restart') { - nbb.on('exit', function() { - start(); +var nconf = require('nconf'), + fs = require('fs'), + pidFilePath = __dirname + '/pidfile', + start = function() { + var fork = require('child_process').fork, + nbb_start = function() { + nbb = fork('./app', process.argv.slice(2), { + env: { + 'NODE_ENV': process.env.NODE_ENV + } + }); + + nbb.on('message', function(cmd) { + if (cmd === 'nodebb:restart') { + nbb.on('exit', function() { + nbb_start(); + }); + nbb.kill(); + } }); + }, + nbb_stop = function() { nbb.kill(); - } - }); - }, - stop = function() { - nbb.kill(); + if (fs.existsSync(pidFilePath)) { + var pid = parseInt(fs.readFileSync(pidFilePath, { encoding: 'utf-8' }), 10); + if (process.pid === pid) { + fs.unlinkSync(pidFilePath); + } + } + }; + + process.on('SIGINT', nbb_stop); + process.on('SIGTERM', nbb_stop); + + nbb_start(); }, nbb; -process.on('SIGINT', stop); -process.on('SIGTERM', stop); +nconf.argv(); -start(); \ No newline at end of file +if (nconf.get('d')) { + // Check for a still-active NodeBB process + if (fs.existsSync(pidFilePath)) { + console.log('\n Error: Another NodeBB is already running!'); + process.exit(); + } + + // Initialise logging streams + var outputStream = fs.createWriteStream(__dirname + '/logs/output.log'); + outputStream.on('open', function(fd) { + // Daemonize + require('daemon')({ + stdout: fd + }); + + // Write its pid to a pidfile + fs.writeFile(__dirname + '/pidfile', process.pid); + + start(); + }); +} else { + start(); +} \ No newline at end of file diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 0000000000..397b4a7624 --- /dev/null +++ b/logs/.gitignore @@ -0,0 +1 @@ +*.log diff --git a/nodebb b/nodebb index 0ea67b0a69..3e4d0e20a7 100755 --- a/nodebb +++ b/nodebb @@ -6,7 +6,19 @@ case "$1" in start) - node loader "$@" + echo "Starting NodeBB"; + echo " \"./nodebb stop\" to stop the NodeBB server"; + echo " \"./nodebb log\" to view server output"; + node loader -d "$@" + ;; + + stop) + echo "Stopping NodeBB. Goodbye!"; + kill `cat pidfile`; + ;; + + log) + tail -F ./logs/output.log; ;; upgrade) diff --git a/package.json b/package.json index 221a6a781a..fec5bc2bab 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ }, "main": "app.js", "scripts": { + "start": "./nodebb start", + "stop": "./nodebb stop", "test": "mocha ./tests" }, "dependencies": { @@ -43,7 +45,8 @@ "nodebb-theme-vanilla": "~0.0.14", "nodebb-theme-cerulean": "~0.0.13", "nodebb-theme-lavender": "~0.0.22", - "less": "^1.6.3" + "less": "^1.6.3", + "daemon": "~1.1.0" }, "optionalDependencies": { "redis": "0.8.3", diff --git a/src/webserver.js b/src/webserver.js index b7028efc5c..b4d5afe7b6 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -52,7 +52,7 @@ var shutdown = function(code) { db.close(); winston.info('[app] Database connection closed.'); - winston.info('[app] Goodbye!'); + winston.info('[app] Shutdown complete.'); process.exit(); }, restart = function() { From 4567e5fbd00c816d3f9b0ac1496b49e96e6f1211 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Feb 2014 10:13:36 -0500 Subject: [PATCH 20/26] updated help blurb in executable --- nodebb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nodebb b/nodebb index 3e4d0e20a7..324594356e 100755 --- a/nodebb +++ b/nodebb @@ -54,13 +54,15 @@ case "$1" in *) echo "Welcome to NodeBB" - echo $"Usage: $0 {start|dev|watch|upgrade}" + echo $"Usage: $0 {start|stop|log|upgrade|dev|watch}" echo '' column -s ' ' -t <<< ' - start Start NodeBB in production mode - dev Start NodeBB in development mode - watch Start NodeBB in development mode and watch for changes + start Start the NodeBB server + stop Stops the NodeBB server + log Opens the logging interface (useful for debugging) upgrade Run NodeBB upgrade scripts, ensure packages are up-to-date + dev Start NodeBB in interactive development mode + watch Start NodeBB in development mode and watch for changes ' exit 1 esac From c7274e11d02f4a6a8aa57c80796b33349ae771d0 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Feb 2014 10:28:49 -0500 Subject: [PATCH 21/26] removing the bit of code that disables plugins if the minver does not satisfy (too annoying imo)... now that we have ./nodebb reset, this is moot --- src/plugins.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/plugins.js b/src/plugins.js index 5dad12632a..30731712e8 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -114,20 +114,7 @@ var fs = require('fs'), if (pluginData.minver && semver.validRange(pluginData.minver)) { if (!semver.satisfies(pkg.version, pluginData.minver)) { // If NodeBB is not new enough to run this plugin - if (process.env.NODE_ENV === 'development') { - // Throw a warning in development, but do nothing else - winston.warn('[plugins/' + pluginData.id + '] This plugin may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing.'); - } else { - if (nconf.get('check-plugins') !== false) { - // Refuse to load this plugin... - winston.error('[plugins/' + pluginData.id + '] This plugin is reportedly incompatible with your version of NodeBB, so it has been disabled.'); - winston.error('[plugins/' + pluginData.id + '] Use `--no-check-plugins` if you wish to live dangerously.'); - - // ... and disable it, too - Plugins.toggleActive(pluginData.id); - return callback(); - } - } + winston.warn('[plugins/' + pluginData.id + '] This plugin may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing.'); } } From a7c53519b65fcc2448ea92e84158b5ddf1fc8157 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Feb 2014 10:30:09 -0500 Subject: [PATCH 22/26] updated executable help --- nodebb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodebb b/nodebb index 324594356e..107d96259e 100755 --- a/nodebb +++ b/nodebb @@ -54,12 +54,14 @@ case "$1" in *) echo "Welcome to NodeBB" - echo $"Usage: $0 {start|stop|log|upgrade|dev|watch}" + echo $"Usage: $0 {start|stop|log|setup|reset|upgrade|dev|watch}" echo '' column -s ' ' -t <<< ' start Start the NodeBB server stop Stops the NodeBB server log Opens the logging interface (useful for debugging) + setup Runs the NodeBB setup script + reset Disables all plugins, restores the default theme. upgrade Run NodeBB upgrade scripts, ensure packages are up-to-date dev Start NodeBB in interactive development mode watch Start NodeBB in development mode and watch for changes From 1a85d455672fcd9f9206a18ac155272a04885b7a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Feb 2014 10:41:59 -0500 Subject: [PATCH 23/26] portuguese and slovak translations --- .gitignore | 2 + public/language/pt_BR/global.json | 10 +++-- public/language/pt_BR/notifications.json | 4 +- public/language/pt_BR/pages.json | 2 +- public/language/pt_BR/recent.json | 2 +- public/language/pt_BR/topic.json | 54 ++++++++++++++---------- public/language/pt_BR/user.json | 20 ++++----- public/language/sk/global.json | 2 + public/language/sk/pages.json | 2 +- public/language/sk/topic.json | 10 ++++- 10 files changed, 65 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index e743a14466..58bdac0c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ feeds/recent.rss # winston? error.log events.log + +pidfile diff --git a/public/language/pt_BR/global.json b/public/language/pt_BR/global.json index 26d5525a81..efb6b78f23 100644 --- a/public/language/pt_BR/global.json +++ b/public/language/pt_BR/global.json @@ -10,14 +10,16 @@ "500.message": "Oops! deu algo errado!", "register": "Cadastrar", "login": "Logar", - "welcome_back": "Welcome Back ", - "you_have_successfully_logged_in": "You have successfully logged in", + "please_log_in": "Por favor efetue o login", + "posting_restriction_info": "Postagens esta restritas para membros registrados. clique aqui para logar", + "welcome_back": "Bem vindo de volta", + "you_have_successfully_logged_in": "Você logou com sucesso", "logout": "Logout", "logout.title": "Logout com sucesso.", "logout.message": "Logado com Sucesso!", "save_changes": "Salvar Alterações", "close": "Fechar", - "pagination": "Pagination", + "pagination": "Paginação", "header.admin": "Admin", "header.recent": "Recente", "header.unread": "Não Lido", @@ -52,5 +54,5 @@ "dnd": "Não Perturbe", "invisible": "Invisível", "offline": "Offline", - "privacy": "Privacy" + "privacy": "Privacidade" } \ No newline at end of file diff --git a/public/language/pt_BR/notifications.json b/public/language/pt_BR/notifications.json index fa7441b08d..253ec3cfdd 100644 --- a/public/language/pt_BR/notifications.json +++ b/public/language/pt_BR/notifications.json @@ -1,7 +1,7 @@ { "title": "Notificações", - "no_notifs": "You have no new notifications", - "see_all": "See all Notifications", + "no_notifs": "Você não tem nenhuma notificação nova", + "see_all": "Visualizar todas as Notificações", "back_to_home": "voltar para home", "outgoing_link": "Link Externo", "outgoing_link_message": "Você está; saindo para um link externo", diff --git a/public/language/pt_BR/pages.json b/public/language/pt_BR/pages.json index 8f6d6f08e8..313eee0d2c 100644 --- a/public/language/pt_BR/pages.json +++ b/public/language/pt_BR/pages.json @@ -1,7 +1,7 @@ { "home": "Home", "unread": "Tópicos Não Lidos", - "popular": "Popular Topics", + "popular": "Tópicos Populares", "recent": "Tópicos Recentes", "users": "Usuários Registrados", "notifications": "Notificações", diff --git a/public/language/pt_BR/recent.json b/public/language/pt_BR/recent.json index b67b2e88b4..9adf191ed6 100644 --- a/public/language/pt_BR/recent.json +++ b/public/language/pt_BR/recent.json @@ -3,5 +3,5 @@ "day": "Dia", "week": "Semana", "month": "Mês", - "no_recent_topics": "There are no recent topics." + "no_recent_topics": "Nenhum tópico recente." } \ No newline at end of file diff --git a/public/language/pt_BR/topic.json b/public/language/pt_BR/topic.json index a20ea66672..0e01e879f4 100644 --- a/public/language/pt_BR/topic.json +++ b/public/language/pt_BR/topic.json @@ -2,7 +2,7 @@ "topic": "Tópico", "topics": "Tópicos", "no_topics_found": "Nenhum tópico encontrado!", - "no_posts_found": "No posts found!", + "no_posts_found": "Nenhum post encontrado!", "profile": "Profile", "posted_by": "Postado por", "chat": "Bate Papo", @@ -19,19 +19,24 @@ "tools": "Ferramentas", "flag": "Marcar", "flag_title": "Marcar este post para moderação", - "deleted_message": "This thread has been deleted. Only users with thread management privileges can see it.", - "watch": "Watch", - "share_this_post": "Share this Post", + "deleted_message": "Esta Thread foi deletada. Somente usuários com privilégios administrativos podem ver.", + "following_topic.title": "Seguir Tópico", + "following_topic.message": "Você receberá notificações quando alguém responder este tópico.", + "not_following_topic.title": "Não está seguindo Tópico", + "not_following_topic.message": "Você não irá mais receber notificações deste tópico.", + "login_to_subscribe": "Por favor registre ou logue para poder assinar este tópico", + "watch": "Acompanhar", + "share_this_post": "Compartilhar este Post", "thread_tools.title": "Ferramentas da Thread", "thread_tools.markAsUnreadForAll": "Marcar como não lido", - "thread_tools.pin": "Pin Topic", - "thread_tools.unpin": "Unpin Topic", - "thread_tools.lock": "Lock Topic", - "thread_tools.unlock": "Unlock Topic", - "thread_tools.move": "Move Topic", - "thread_tools.fork": "Fork Topic", - "thread_tools.delete": "Delete Topic", - "thread_tools.restore": "Restore Topic", + "thread_tools.pin": "Fixar Tópico", + "thread_tools.unpin": "Remover Fixação do Tópico", + "thread_tools.lock": "Trancar Tópico", + "thread_tools.unlock": "Destrancar Tópico", + "thread_tools.move": "Mover Tópico", + "thread_tools.fork": "Fork Tópico", + "thread_tools.delete": "Deletar Tópico", + "thread_tools.restore": "Restaurar Tópico", "load_categories": "Carregando Categorias", "disabled_categories_note": "Categorias desabilitadas estão em cinza", "confirm_move": "Mover", @@ -41,10 +46,10 @@ "favourites.not_logged_in.title": "Não Logado", "favourites.not_logged_in.message": "Por Favor logar para favoritar o tópico", "favourites.has_no_favourites": "Você não tem nenhum item favoritado!", - "vote.not_logged_in.title": "Not Logged In", - "vote.not_logged_in.message": "Please log in in order to vote", - "vote.cant_vote_self.title": "Invalid Vote", - "vote.cant_vote_self.message": "You cannot vote for your own post", + "vote.not_logged_in.title": "Não está logado", + "vote.not_logged_in.message": "Por favor efetuar login para votar", + "vote.cant_vote_self.title": "Voto inválido", + "vote.cant_vote_self.message": "Você não pode votar o seu próprio post", "loading_more_posts": "Carregando mais posts", "move_topic": "Mover Tó;pico", "move_post": "Mover Post", @@ -55,11 +60,14 @@ "fork_success": "Fork realizado com sucesso!", "reputation": "Reputação", "posts": "Posts", - "composer.title_placeholder": "Enter your topic title here...", - "composer.write": "Write", - "composer.preview": "Preview", - "composer.discard": "Discard", - "composer.submit": "Submit", - "composer.replying_to": "Replying to", - "composer.new_topic": "New Topic" + "composer.title_placeholder": "Digite seu tópico aqui...", + "composer.write": "Escreva", + "composer.preview": "Pré Visualização", + "composer.discard": "Descartar", + "composer.submit": "Enviar", + "composer.replying_to": "Respondendo para", + "composer.new_topic": "Novo Tópico", + "composer.drag_and_drop_images": "Clique e arraste imagens aqui", + "composer.content_is_parsed_with": "Conteúdo está separado com", + "composer.upload_instructions": "Mande suas imagens arrastando e soltando." } \ No newline at end of file diff --git a/public/language/pt_BR/user.json b/public/language/pt_BR/user.json index 09270bb6d8..6991971504 100644 --- a/public/language/pt_BR/user.json +++ b/public/language/pt_BR/user.json @@ -9,7 +9,7 @@ "age": "Idade", "joined": "Cadastrou", "lastonline": "Última vez online", - "profile": "Profile", + "profile": "Perfil", "profile_views": "Visualizações de Profile", "reputation": "Reputação", "posts": "Posts", @@ -19,29 +19,29 @@ "signature": "Assinatura", "gravatar": "Gravatar", "birthday": "Aniversário", - "chat": "Chat", - "follow": "Follow", - "unfollow": "Unfollow", + "chat": "Bate Papo", + "follow": "Seguir", + "unfollow": "Deixar de Seguir", "change_picture": "Alterar Foto", "edit": "Editar", "uploaded_picture": "Foto Carregada", "upload_new_picture": "Carregar novo Foto", - "current_password": "Current Password", + "current_password": "Senha Atual", "change_password": "Alterar Senha", "confirm_password": "Confirmar Senha", "password": "Senha", "upload_picture": "Carregar Foto", "upload_a_picture": "Carregar Foto", - "image_spec": "You may only upload PNG, JPG, or GIF files", + "image_spec": "Você pode usar somente arquivos PNG, JPG ou GIF", "max": "max.", "settings": "Configurações", "show_email": "Mostrar meu email", "has_no_follower": "Ninguém está seguindo esse usuário :(", "follows_no_one": "Este usuário não está seguindo ninguém :(", - "has_no_posts": "This user didn't post anything yet.", + "has_no_posts": "Este usuário não postou nada ainda.", "email_hidden": "Email Escondido", "hidden": "Escondido", - "paginate_description": "Paginate topics and posts instead of using infinite scroll.", - "topics_per_page": "Topics per Page", - "posts_per_page": "Posts per Page" + "paginate_description": "Paginação de tópicos e posts ao invés de usar \"scroll infinito\"", + "topics_per_page": "Tópicos por Página", + "posts_per_page": "Posts por Página" } \ No newline at end of file diff --git a/public/language/sk/global.json b/public/language/sk/global.json index 6fa7361dca..cf17eb234d 100644 --- a/public/language/sk/global.json +++ b/public/language/sk/global.json @@ -10,6 +10,8 @@ "500.message": "Jejda, vyzerá, že sa niečo pokazilo.", "register": "Registrovať", "login": "Prihlásiť sa", + "please_log_in": "Prosím Prihláste sa", + "posting_restriction_info": "Prispievanie je obmedzené len pre registrovaných, kliknite pre Prihlásenie sa ", "welcome_back": "Vitaj naspäť", "you_have_successfully_logged_in": "Úspešne si sa prihlásil", "logout": "Odhlásiť sa", diff --git a/public/language/sk/pages.json b/public/language/sk/pages.json index d60e0a0a9b..4fa2659252 100644 --- a/public/language/sk/pages.json +++ b/public/language/sk/pages.json @@ -1,7 +1,7 @@ { "home": "Home", "unread": "Unread Topics", - "popular": "Popular Topics", + "popular": "Populárne Témy", "recent": "Recent Topics", "users": "Registered Users", "notifications": "Notifications", diff --git a/public/language/sk/topic.json b/public/language/sk/topic.json index 4bf7ffe6cd..b7a2bac591 100644 --- a/public/language/sk/topic.json +++ b/public/language/sk/topic.json @@ -20,6 +20,11 @@ "flag": "Označiť", "flag_title": "Označiť príspevok pre moderáciu", "deleted_message": "Toto vlákno bolo vymazané. Iba užívatelia s privilégiami ho môžu vidieť.", + "following_topic.title": "Sledovať Tému", + "following_topic.message": "Budete teraz príjimať notifikácie, ked niekto prispeje do témy.", + "not_following_topic.title": "Nesledujete Tému", + "not_following_topic.message": "Nebudete už dostávať notifikácie z tejto Témy", + "login_to_subscribe": "Prosím Zaregistrujte sa alebo sa Prihláste, aby ste mohli odoberať túto Tému", "watch": "Sledovať", "share_this_post": "Zdielaj tento príspevok", "thread_tools.title": "Nástroje", @@ -61,5 +66,8 @@ "composer.discard": "Zahodiť", "composer.submit": "Poslať", "composer.replying_to": "Odpovedáš ", - "composer.new_topic": "Nová téma" + "composer.new_topic": "Nová téma", + "composer.drag_and_drop_images": "Pretiahni a Pusť Obrázky Sem", + "composer.content_is_parsed_with": "Obsah je vybraný s", + "composer.upload_instructions": "Nahraj obrázky pretiahnutím a pustením ich." } \ No newline at end of file From 0ca6c58ded6b61a872a7a2e8a49837b77b834806 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Thu, 27 Feb 2014 12:15:26 -0500 Subject: [PATCH 24/26] closes #1137 --- public/language/en_GB/topic.json | 4 +++- public/src/forum/topic.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/language/en_GB/topic.json b/public/language/en_GB/topic.json index 085f8df821..dc47458923 100644 --- a/public/language/en_GB/topic.json +++ b/public/language/en_GB/topic.json @@ -32,7 +32,9 @@ "not_following_topic.title": "Not Following Topic", "not_following_topic.message": "You will no longer receive notifications from this topic.", - "login_to_subscribe": "Please register or log in in order to subscribe to this topic", + "login_to_subscribe": "Please register or log in in order to subscribe to this topic.", + + "markAsUnreadForAll.success" : "Topic marked as unread for all.", "watch": "Watch", "share_this_post": "Share this Post", diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index d220494b86..f603ca4aba 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -108,6 +108,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { if(err) { return app.alertError(err.message); } + app.alertSuccess('[[topic:markAsUnreadForAll.success]]'); btn.parents('.thread-tools.open').find('.dropdown-toggle').trigger('click'); }); return false; @@ -323,6 +324,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { localStorage.removeItem('topic:' + tid + ':bookmark'); } }); + updateHeader(); } else { updateHeader(); } From 44ac7ec2627b5698b535c197bd4cd3ebe74238ef Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Feb 2014 14:05:31 -0500 Subject: [PATCH 25/26] added new hooks for rendering help messages in composer, removed markdown text from translation --- package.json | 2 +- public/language/en_GB/topic.json | 1 - public/src/modules/composer.js | 7 +++++++ public/templates/composer.tpl | 5 ++++- src/socket.io/modules.js | 6 +++++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fec5bc2bab..9024cc068b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "socket.io-wildcard": "~0.1.1", "bcryptjs": "~0.7.10", "nodebb-plugin-mentions": "~0.4", - "nodebb-plugin-markdown": "~0.3", + "nodebb-plugin-markdown": "~0.4", "nodebb-widget-essentials": "~0.0", "nodebb-theme-vanilla": "~0.0.14", "nodebb-theme-cerulean": "~0.0.13", diff --git a/public/language/en_GB/topic.json b/public/language/en_GB/topic.json index 085f8df821..d92093720d 100644 --- a/public/language/en_GB/topic.json +++ b/public/language/en_GB/topic.json @@ -91,6 +91,5 @@ "composer.thumb_file_label": "Or upload a file", "composer.thumb_remove": "Clear fields", "composer.drag_and_drop_images": "Drag and Drop Images Here", - "composer.content_is_parsed_with": "Content is parsed with", "composer.upload_instructions": "Upload images by dragging & dropping them." } diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index 45b8c2b974..1862092834 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -638,6 +638,13 @@ define(['taskbar'], function(taskbar) { } }); + socket.emit('modules.composer.renderHelp', function(err, html) { + if (html && html.length > 0) { + postContainer.find('.help').html(html); + postContainer.find('[data-pane=".tab-help"]').parent().removeClass('hidden'); + } + }); + $(window).trigger('action:composer.loaded', { post_uuid: post_uuid }); diff --git a/public/templates/composer.tpl b/public/templates/composer.tpl index 584ba48153..7302c9a040 100644 --- a/public/templates/composer.tpl +++ b/public/templates/composer.tpl @@ -58,6 +58,7 @@