mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
added error and success language files
removed some code from server side that was emitting alerts
This commit is contained in:
20
public/language/en_GB/error.json
Normal file
20
public/language/en_GB/error.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"invalid-data": "Invalid Data",
|
||||
|
||||
"not-logged-in": "You don't seem to be logged in, so you cannot reply.",
|
||||
|
||||
"invalid-cid": "Invalid Category ID",
|
||||
|
||||
"no-category": "Category doesn't exist",
|
||||
"no-topic": "Topic doesn't exist",
|
||||
"no-privileges": "You don't have enough privileges for this action.",
|
||||
|
||||
"topic-locked": "Topic Locked",
|
||||
|
||||
"still-uploading" : "Please wait for uploads to complete.",
|
||||
"content-too-short" : "Please enter a longer post. At least %1 characters.",
|
||||
"title-too-short" : "Please enter a longer title. At least %1 characters.",
|
||||
"title-too-long" : "Please enter a shorter title. Titles can't be longer than %1 characters.",
|
||||
"too-many-posts" : "You can only post every %1 seconds.'",
|
||||
"file-too-big" : "Maximum allowed file size is %1 kbs"
|
||||
}
|
||||
4
public/language/en_GB/success.json
Normal file
4
public/language/en_GB/success.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"topic-post": "You have successfully posted."
|
||||
|
||||
}
|
||||
@@ -168,12 +168,12 @@ define(['taskbar'], function(taskbar) {
|
||||
}
|
||||
}
|
||||
|
||||
function composerAlert(title, message) {
|
||||
function composerAlert(message) {
|
||||
$('.action-bar button').removeAttr('disabled');
|
||||
app.alert({
|
||||
type: 'danger',
|
||||
timeout: 2000,
|
||||
title: title,
|
||||
timeout: 3000,
|
||||
title: '',
|
||||
message: message,
|
||||
alert_id: 'post_error'
|
||||
});
|
||||
@@ -299,7 +299,7 @@ define(['taskbar'], function(taskbar) {
|
||||
|
||||
if(files[i].size > parseInt(config.maximumFileSize, 10) * 1024) {
|
||||
uploadForm[0].reset();
|
||||
return composerAlert('File too big', 'Maximum allowed file size is ' + config.maximumFileSize + 'kbs');
|
||||
return composerAlert('[[error:file-too-big, ' + config.maximumFileSize + ']]');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -896,13 +896,13 @@ define(['taskbar'], function(taskbar) {
|
||||
var checkTitle = parseInt(postData.cid, 10) || parseInt(postData.pid, 10);
|
||||
|
||||
if(postData.uploadsInProgress && postData.uploadsInProgress.length) {
|
||||
return composerAlert('Still uploading', 'Please wait for uploads to complete.');
|
||||
return composerAlert('[[error:still-uploading]]');
|
||||
} else if (checkTitle && titleEl.val().length < parseInt(config.minimumTitleLength, 10)) {
|
||||
return composerAlert('Title too short', 'Please enter a longer title. At least ' + config.minimumTitleLength+ ' characters.');
|
||||
return composerAlert('[[error:title-too-short, ' + config.minimumTitleLength + ']]');
|
||||
} else if (checkTitle && titleEl.val().length > parseInt(config.maximumTitleLength, 10)) {
|
||||
return composerAlert('Title too long', 'Please enter a shorter title. Titles can\'t be longer than ' + config.maximumTitleLength + ' characters.');
|
||||
return composerAlert('[[error:title-too-long, ' + config.maximumTitleLength + ']]');
|
||||
} else if (bodyEl.val().length < parseInt(config.minimumPostLength, 10)) {
|
||||
return composerAlert('Content too short', 'Please enter a longer post. At least ' + config.minimumPostLength + ' characters.');
|
||||
return composerAlert('[[error:content-too-short, ' + config.minimumPostLength + ']]');
|
||||
}
|
||||
|
||||
if (parseInt(postData.cid, 10) > 0) {
|
||||
@@ -929,11 +929,15 @@ define(['taskbar'], function(taskbar) {
|
||||
|
||||
function done(err) {
|
||||
$('.action-bar button').removeAttr('disabled');
|
||||
if(!err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
app.alertSuccess('[[success:topic-post]]');
|
||||
|
||||
composer.discard(post_uuid);
|
||||
removeDraft(postData.save_id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
composer.discard = function(post_uuid) {
|
||||
|
||||
@@ -18,42 +18,17 @@ var async = require('async'),
|
||||
SocketPosts.reply = function(socket, data, callback) {
|
||||
|
||||
if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Reply Unsuccessful',
|
||||
message: 'You don't seem to be logged in, so you cannot reply.',
|
||||
type: 'danger',
|
||||
timeout: 2000
|
||||
});
|
||||
return callback(new Error('not-logged-in'));
|
||||
return callback(new Error('[[error:not-logged-in]]'));
|
||||
}
|
||||
|
||||
if(!data || !data.tid || !data.content) {
|
||||
return callback(new Error('invalid data'));
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
data.uid = socket.uid;
|
||||
|
||||
topics.reply(data, function(err, postData) {
|
||||
if(err) {
|
||||
if (err.message === 'content-too-short') {
|
||||
module.parent.exports.emitContentTooShortAlert(socket);
|
||||
} else if (err.message === 'too-many-posts') {
|
||||
module.parent.exports.emitTooManyPostsAlert(socket);
|
||||
} else if (err.message === 'reply-error') {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Reply Unsuccessful',
|
||||
message: 'Your reply could not be posted at this time. Please try again later.',
|
||||
type: 'warning',
|
||||
timeout: 2000
|
||||
});
|
||||
} else if (err.message === 'no-privileges') {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Unable to post',
|
||||
message: 'You do not have posting privileges in this category.',
|
||||
type: 'danger',
|
||||
timeout: 7500
|
||||
});
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -61,12 +36,6 @@ SocketPosts.reply = function(socket, data, callback) {
|
||||
|
||||
module.parent.exports.emitTopicPostStats();
|
||||
|
||||
socket.emit('event:alert', {
|
||||
title: 'Reply Successful',
|
||||
message: 'You have successfully replied. Click here to view your reply.',
|
||||
type: 'success',
|
||||
timeout: 2000
|
||||
});
|
||||
var socketData = {
|
||||
posts: [postData]
|
||||
};
|
||||
|
||||
@@ -16,44 +16,15 @@ var topics = require('../topics'),
|
||||
SocketTopics.post = function(socket, data, callback) {
|
||||
|
||||
if(!data) {
|
||||
return callback(new Error('Invalid data'));
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Post Unsuccessful',
|
||||
message: 'You don't seem to be logged in, so you cannot reply.',
|
||||
type: 'danger',
|
||||
timeout: 2000
|
||||
});
|
||||
return callback(new Error('not-logged-in'));
|
||||
return callback(new Error('[[error:not-logged-in]]'));
|
||||
}
|
||||
|
||||
topics.post({uid: socket.uid, title: data.title, content: data.content, cid: data.category_id, thumb: data.topic_thumb}, function(err, result) {
|
||||
if(err) {
|
||||
if (err.message === 'title-too-short') {
|
||||
module.parent.exports.emitAlert(socket, 'Title too short', 'Please enter a longer title. At least ' + meta.config.minimumTitleLength + ' characters.');
|
||||
} else if (err.message === 'title-too-long') {
|
||||
module.parent.exports.emitAlert(socket, 'Title too long', 'Please enter a shorter title. Titles can\'t be longer than ' + meta.config.maximumTitleLength + ' characters.');
|
||||
} else if (err.message === 'content-too-short') {
|
||||
module.parent.exports.emitContentTooShortAlert(socket);
|
||||
} else if (err.message === 'too-many-posts') {
|
||||
module.parent.exports.emitTooManyPostsAlert(socket);
|
||||
} else if (err.message === 'no-privileges') {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Unable to post',
|
||||
message: 'You do not have posting privileges in this category.',
|
||||
type: 'danger',
|
||||
timeout: 7500
|
||||
});
|
||||
} else {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Error',
|
||||
message: err.message,
|
||||
type: 'warning',
|
||||
timeout: 7500
|
||||
});
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -71,12 +42,6 @@ SocketTopics.post = function(socket, data, callback) {
|
||||
|
||||
module.parent.exports.emitTopicPostStats();
|
||||
|
||||
socket.emit('event:alert', {
|
||||
title: 'Thank you for posting',
|
||||
message: 'You have successfully posted. Click here to view your post.',
|
||||
type: 'success',
|
||||
timeout: 2000
|
||||
});
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,21 +77,9 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
if (!title || title.length < parseInt(meta.config.minimumTitleLength, 10)) {
|
||||
return callback(new Error('title-too-short'));
|
||||
return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'));
|
||||
} else if(title.length > parseInt(meta.config.maximumTitleLength, 10)) {
|
||||
return callback(new Error('title-too-long'));
|
||||
}
|
||||
|
||||
if (content) {
|
||||
content = content.trim();
|
||||
}
|
||||
|
||||
if (!content || content.length < meta.config.miminumPostLength) {
|
||||
return callback(new Error('content-too-short'));
|
||||
}
|
||||
|
||||
if (!cid) {
|
||||
return callback(new Error('invalid-cid'));
|
||||
return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'));
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
@@ -100,13 +88,13 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function(categoryExists, next) {
|
||||
if (!categoryExists) {
|
||||
return next(new Error('category doesn\'t exist'));
|
||||
return next(new Error('[[error:no-category]]'));
|
||||
}
|
||||
categoryTools.privileges(cid, uid, next);
|
||||
},
|
||||
function(privileges, next) {
|
||||
if(!privileges.write) {
|
||||
return next(new Error('no-privileges'));
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
next();
|
||||
},
|
||||
@@ -129,7 +117,7 @@ module.exports = function(Topics) {
|
||||
return next(err);
|
||||
}
|
||||
if(!topicData || !topicData.length) {
|
||||
return next(new Error('no-topic'));
|
||||
return next(new Error('[[error:no-topic]]'));
|
||||
}
|
||||
topicData = topicData[0];
|
||||
topicData.unreplied = 1;
|
||||
@@ -157,14 +145,14 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function(topicExists, next) {
|
||||
if (!topicExists) {
|
||||
return next(new Error('topic doesn\'t exist'));
|
||||
return next(new Error('[[error:no-topic]]'));
|
||||
}
|
||||
|
||||
Topics.isLocked(tid, next);
|
||||
},
|
||||
function(locked, next) {
|
||||
if (locked) {
|
||||
return next(new Error('topic-locked'));
|
||||
return next(new Error('[[error:topic-locked]]'));
|
||||
}
|
||||
|
||||
threadTools.privileges(tid, uid, next);
|
||||
@@ -172,7 +160,7 @@ module.exports = function(Topics) {
|
||||
function(privilegesData, next) {
|
||||
privileges = privilegesData;
|
||||
if (!privileges.write) {
|
||||
return next(new Error('no-privileges'));
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
next();
|
||||
},
|
||||
@@ -184,8 +172,8 @@ module.exports = function(Topics) {
|
||||
content = content.trim();
|
||||
}
|
||||
|
||||
if (!content || content.length < meta.config.minimumPostLength) {
|
||||
return next(new Error('content-too-short'));
|
||||
if (!content || content.length < meta.config.miminumPostLength) {
|
||||
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
||||
}
|
||||
|
||||
posts.create({uid:uid, tid:tid, content:content, toPid:toPid}, next);
|
||||
|
||||
@@ -139,7 +139,7 @@ var bcrypt = require('bcryptjs'),
|
||||
}
|
||||
|
||||
if (Date.now() - parseInt(lastposttime, 10) < parseInt(meta.config.postDelay, 10) * 1000) {
|
||||
return callback(new Error('too-many-posts'));
|
||||
return callback(new Error('[[error:too-many-posts, ' + meta.config.postDelay + ']]'));
|
||||
}
|
||||
callback();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user