mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
closes #669
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
define(function () {
|
||||
define(['composer'], function(composer) {
|
||||
var Category = {},
|
||||
loadingMoreTopics = false;
|
||||
|
||||
@@ -27,9 +27,7 @@ define(function () {
|
||||
});
|
||||
|
||||
$('#new_post').on('click', function () {
|
||||
require(['composer'], function (cmp) {
|
||||
cmp.push(0, cid);
|
||||
});
|
||||
composer.newTopic(cid);
|
||||
});
|
||||
|
||||
ajaxify.register_events([
|
||||
|
||||
@@ -274,7 +274,7 @@ define(['composer'], function(composer) {
|
||||
}
|
||||
|
||||
if (thread_state.locked !== '1') {
|
||||
composer.push(tid, null, null, selectionText.length > 0 ? selectionText + '\n\n' + username : '' + username);
|
||||
composer.newReply(tid, topic_name, selectionText.length > 0 ? selectionText + '\n\n' + username : '' + username);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -286,7 +286,7 @@ define(['composer'], function(composer) {
|
||||
|
||||
quoted = '> ' + data.post.replace(/\n/g, '\n> ') + '\n\n';
|
||||
|
||||
composer.push(tid, null, null, quoted);
|
||||
composer.newReply(tid, topic_name, quoted);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -337,8 +337,7 @@ define(['composer'], function(composer) {
|
||||
$('#post-container').delegate('.edit', 'click', function(e) {
|
||||
var pid = $(this).parents('li').attr('data-pid');
|
||||
|
||||
|
||||
composer.push(null, null, pid);
|
||||
composer.editPost(pid);
|
||||
});
|
||||
|
||||
$('#post-container').delegate('.delete', 'click', function(e) {
|
||||
|
||||
@@ -4,16 +4,8 @@ define(['taskbar'], function(taskbar) {
|
||||
posts: {}
|
||||
};
|
||||
|
||||
composer.push = function(tid, cid, pid, text) {
|
||||
|
||||
socket.emit('api:composer.push', {
|
||||
tid: tid, // Replying
|
||||
cid: cid, // Posting
|
||||
pid: pid, // Editing
|
||||
body: text // Predefined text
|
||||
}, function(threadData) {
|
||||
|
||||
if(threadData.error) {
|
||||
function allowed() {
|
||||
if(!(parseInt(app.uid, 10) > 0 || parseInt(config.allowGuestPosting, 10) === 1)) {
|
||||
app.alert({
|
||||
type: 'danger',
|
||||
timeout: 5000,
|
||||
@@ -24,27 +16,60 @@ define(['taskbar'], function(taskbar) {
|
||||
ajaxify.go('login');
|
||||
}
|
||||
});
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
composer.newTopic = function(cid) {
|
||||
if(allowed()) {
|
||||
push({
|
||||
cid: cid,
|
||||
title: '',
|
||||
body: '',
|
||||
modified: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
composer.newReply = function(tid, title, text) {
|
||||
if(allowed()) {
|
||||
push({
|
||||
tid: tid,
|
||||
title: title,
|
||||
body: text,
|
||||
modified: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
composer.editPost = function(pid) {
|
||||
if(allowed()) {
|
||||
socket.emit('api:composer.push', {
|
||||
pid: pid
|
||||
}, function(threadData) {
|
||||
console.log(threadData);
|
||||
push({
|
||||
pid: pid,
|
||||
title: threadData.title,
|
||||
body: threadData.body,
|
||||
modified: false
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function push(post) {
|
||||
var uuid = utils.generateUUID();
|
||||
|
||||
taskbar.push('composer', uuid, {
|
||||
title: (!threadData.cid ? (threadData.title || '') : 'New Topic'),
|
||||
icon: threadData.picture
|
||||
title: post.title ? post.title : 'New Topic',
|
||||
icon: post.picture
|
||||
});
|
||||
|
||||
composer.posts[uuid] = {
|
||||
tid: threadData.tid,
|
||||
cid: threadData.cid,
|
||||
pid: threadData.pid,
|
||||
title: threadData.title || '',
|
||||
body: threadData.body || '',
|
||||
modified: false
|
||||
};
|
||||
composer.posts[uuid] = post;
|
||||
|
||||
composer.load(uuid);
|
||||
});
|
||||
}
|
||||
|
||||
composer.load = function(post_uuid) {
|
||||
@@ -470,7 +495,9 @@ define(['taskbar'], function(taskbar) {
|
||||
}
|
||||
|
||||
return {
|
||||
push: composer.push,
|
||||
newTopic: composer.newTopic,
|
||||
newReply: composer.newReply,
|
||||
editPost: composer.editPost,
|
||||
load: composer.load,
|
||||
minimize: composer.minimize
|
||||
};
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
|
||||
templates.preload_template = function(tpl_name, callback) {
|
||||
|
||||
if(templates[tpl_name]) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
// TODO: This should be "load_template", and the current load_template
|
||||
// should be named something else
|
||||
// TODO: The "Date.now()" in the line below is only there for development purposes.
|
||||
|
||||
@@ -36,6 +36,7 @@ var path = require('path'),
|
||||
config.minimumPasswordLength = meta.config.minimumPasswordLength;
|
||||
config.maximumSignatureLength = meta.config.maximumSignatureLength;
|
||||
config.useOutgoingLinksPage = meta.config.useOutgoingLinksPage;
|
||||
config.allowGuestPosting = meta.config.allowGuestPosting;
|
||||
config.emailSetup = !!meta.config['email:from'];
|
||||
|
||||
res.json(200, config);
|
||||
|
||||
@@ -803,32 +803,9 @@ websockets.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:composer.push', function(data, callback) {
|
||||
if (parseInt(uid, 10) > 0 || parseInt(meta.config.allowGuestPosting, 10) === 1) {
|
||||
if (parseInt(data.tid) > 0) {
|
||||
topics.getTopicData(data.tid, function(err, topicData) {
|
||||
if (data.body) {
|
||||
topicData.body = data.body;
|
||||
}
|
||||
|
||||
callback({
|
||||
tid: data.tid,
|
||||
title: topicData.title,
|
||||
body: topicData.body
|
||||
});
|
||||
});
|
||||
} else if (parseInt(data.cid) > 0) {
|
||||
user.getUserFields(uid, ['username', 'picture'], function(err, userData) {
|
||||
if (!err && userData) {
|
||||
callback({
|
||||
tid: 0,
|
||||
cid: data.cid,
|
||||
username: userData.username,
|
||||
picture: userData.picture,
|
||||
title: undefined
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (parseInt(data.pid) > 0) {
|
||||
if (parseInt(uid, 10) > 0 || parseInt(meta.config.allowGuestPosting, 10) === 1) {
|
||||
if (parseInt(data.pid) > 0) {
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
|
||||
Reference in New Issue
Block a user