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