diff --git a/README.md b/README.md
index e28a0681c3..554097fb21 100644
--- a/README.md
+++ b/README.md
@@ -38,45 +38,4 @@ Lastly, we run the forum.
*(Optional)* Some server configurations may install the node binary as `nodejs` instead of `node`. You can re-map it (so as to not break compatibility with `node-supervisor`) by running the following command:
- # update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
-
-## Server Configuration
-
-The server configuration file (located at `/config.js`) contains default options required for the running of NodeBB. The following options are available:
-
-
-
- | Option |
- Description |
-
-
- | base_url |
- (Default: 'http://localhost') A web-accessible URL to your app, without the port |
-
-
- | upload_path |
- (Default: '/public/uploads') A relative path (relative to the application's web root) to the uploads folder. Please ensure that Node.js can write to this folder |
-
-
- | use_port |
- (Default: true) Whether or not to include the port number when constructing the url for use in NodeBB. If you are serving NodeBB via a proxy (i.e. nginx), switch this off.
- |
- | port |
- (Default: 4567) The default port that NodeBB runs on. Even if you are running NodeBB behind a proxy server, this port must be set. |
-
-
- | mailer |
-
- (Default: {
- host: 'localhost',
- port: '25',
- from: 'mailer@localhost.lan'
- })
- Settings for the outgoing mailer (for emails involving user registration/password resets)
- |
-
-
-
-## Client Configuration
-
-As the client will utilise web sockets to connect to the server, you'll need to customise the client configuration file (located at `/public/config.json`) to point to your server's publically accessible IP. The port will be identical to the port specified in the server-side configuration (defaulted to `4567`).
\ No newline at end of file
+ # update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
\ No newline at end of file
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 1ca7620180..158d22484d 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -58,6 +58,10 @@ define(function() {
composer.load(uuid);
});
+ socket.on('api:composer.editCheck', function(editCheck) {
+ if (editCheck.titleEditable === true) composer.postContainer.querySelector('input').readOnly = false;
+ });
+
// Posts bar events
$(composer.btnContainer).on('click', 'li', function() {
var uuid = this.getAttribute('data-uuid');
@@ -168,11 +172,11 @@ define(function() {
composer.postContainer.setAttribute('data-uuid', post_uuid);
if (parseInt(post_data.tid) > 0) {
titleEl.value = 'Replying to: ' + post_data.title;
- titleEl.readonly = true;
+ titleEl.readOnly = true;
} else if (parseInt(post_data.pid) > 0) {
- console.log(post_data);
- titleEl.value = 'Editing: ' + post_data.title;
- titleEl.readonly = true;
+ titleEl.value = post_data.title;
+ titleEl.readOnly = true;
+ socket.emit('api:composer.editCheck', post_data.pid);
} else {
titleEl.value = post_data.title;
}
diff --git a/src/postTools.js b/src/postTools.js
index 74cce37873..c8a975aad4 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -10,6 +10,12 @@ marked.setOptions({
});
(function(PostTools) {
+ PostTools.isMain = function(pid, tid, callback) {
+ RDB.lrange('tid:' + tid + ':posts', 0, 0, function(err, pids) {
+ if (pids[0] === pid) callback(true);
+ else callback(false);
+ })
+ }
PostTools.privileges = function(pid, uid, callback) {
//todo: break early if one condition is true
@@ -48,17 +54,19 @@ marked.setOptions({
PostTools.edit = function(uid, pid, title, content) {
var success = function() {
-
RDB.set('pid:' + pid + ':content', content);
RDB.set('pid:' + pid + ':edited', new Date().getTime());
RDB.set('pid:' + pid + ':editor', uid);
posts.get_tid_by_pid(pid, function(tid) {
- RDB.set('tid:' + tid + ':title', title);
- io.sockets.in('topic_' + tid).emit('event:post_edited', {
- pid: pid,
- title: title,
- content: marked(content || '')
+ PostTools.isMain(pid, tid, function(isMainPost) {
+ if (isMainPost) RDB.set('tid:' + tid + ':title', title);
+
+ io.sockets.in('topic_' + tid).emit('event:post_edited', {
+ pid: pid,
+ title: title,
+ content: marked(content || '')
+ });
});
});
};
diff --git a/src/posts.js b/src/posts.js
index 5882f846d6..0920d045af 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -13,7 +13,6 @@ marked.setOptions({
});
(function(Posts) {
-
Posts.getPostsByTid = function(tid, current_user, start, end, callback) {
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
RDB.handle(err);
diff --git a/src/topics.js b/src/topics.js
index 1a0a44ab0f..3ec79478be 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -194,6 +194,12 @@ marked.setOptions({
});
}
+ Topics.getTitle = function(tid, callback) {
+ RDB.get('tid:' + tid + ':title', function(err, title) {
+ callback(title);
+ });
+ }
+
Topics.markAsRead = function(tid, uid) {
// there is an issue with this fn. if you read a topic that is previously read you will mark the category as read anyways - there is no check
RDB.sadd(schema.topics(tid).read_by_uid, uid);
diff --git a/src/websockets.js b/src/websockets.js
index 3f254b7a27..c8e7017833 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -323,15 +323,36 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
});
});
} else if (parseInt(data.pid) > 0) {
- posts.getRawContent(data.pid, function(raw) {
+ async.parallel([
+ function(next) {
+ posts.getRawContent(data.pid, function(raw) {
+ next(null, raw);
+ });
+ },
+ function(next) {
+ topics.getTitle(data.pid, function(title) {
+ next(null, title);
+ });
+ }
+ ], function(err, results) {
socket.emit('api:composer.push', {
- title: 'asdf',
+ title: results[1],
pid: data.pid,
- body: raw
+ body: results[0]
});
});
}
});
+
+ socket.on('api:composer.editCheck', function(pid) {
+ posts.get_tid_by_pid(pid, function(tid) {
+ postTools.isMain(pid, tid, function(isMain) {
+ socket.emit('api:composer.editCheck', {
+ titleEditable: isMain
+ });
+ })
+ })
+ });
});
}(SocketIO));