mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
Add minimum tags per topic setting.
This commit is contained in:
@@ -497,6 +497,8 @@ define('composer', [
|
|||||||
return composerAlert(post_uuid, '[[error:title-too-long, ' + config.maximumTitleLength + ']]');
|
return composerAlert(post_uuid, '[[error:title-too-long, ' + config.maximumTitleLength + ']]');
|
||||||
} else if (checkTitle && !utils.slugify(titleEl.val()).length) {
|
} else if (checkTitle && !utils.slugify(titleEl.val()).length) {
|
||||||
return composerAlert(post_uuid, '[[error:invalid-title]]');
|
return composerAlert(post_uuid, '[[error:invalid-title]]');
|
||||||
|
} else if (checkTitle && tags.getTags(post_uuid) && tags.getTags(post_uuid).length < parseInt(config.minimumTagsPerTopic, 10)) {
|
||||||
|
return composerAlert(post_uuid, '[[error:not-enough-tags]]');
|
||||||
} else if (bodyEl.val().length < parseInt(config.minimumPostLength, 10)) {
|
} else if (bodyEl.val().length < parseInt(config.minimumPostLength, 10)) {
|
||||||
return composerAlert(post_uuid, '[[error:content-too-short, ' + config.minimumPostLength + ']]');
|
return composerAlert(post_uuid, '[[error:content-too-short, ' + config.minimumPostLength + ']]');
|
||||||
} else if (bodyEl.val().length > parseInt(config.maximumPostLength, 10)) {
|
} else if (bodyEl.val().length > parseInt(config.maximumPostLength, 10)) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ define('composer/tags', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tagEl.tagsinput({
|
tagEl.tagsinput({
|
||||||
|
minTags: config.minimumTagsPerTopic,
|
||||||
maxTags: config.tagsPerTopic,
|
maxTags: config.tagsPerTopic,
|
||||||
maxChars: config.maximumTagLength,
|
maxChars: config.maximumTagLength,
|
||||||
confirmKeys: [13, 44],
|
confirmKeys: [13, 44],
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ apiController.getConfig = function(req, res, next) {
|
|||||||
config.disableChat = parseInt(meta.config.disableChat, 10) === 1;
|
config.disableChat = parseInt(meta.config.disableChat, 10) === 1;
|
||||||
config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5;
|
config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5;
|
||||||
config.reconnectionDelay = meta.config.reconnectionDelay || 1500;
|
config.reconnectionDelay = meta.config.reconnectionDelay || 1500;
|
||||||
|
config.minimumTagsPerTopic = meta.config.minimumTagsPerTopic || 0;
|
||||||
config.tagsPerTopic = meta.config.tagsPerTopic || 5;
|
config.tagsPerTopic = meta.config.tagsPerTopic || 5;
|
||||||
config.minimumTagLength = meta.config.minimumTagLength || 3;
|
config.minimumTagLength = meta.config.minimumTagLength || 3;
|
||||||
config.maximumTagLength = meta.config.maximumTagLength || 15;
|
config.maximumTagLength = meta.config.maximumTagLength || 15;
|
||||||
|
|||||||
@@ -284,6 +284,8 @@ SocketPosts.edit = function(socket, data, callback) {
|
|||||||
return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'));
|
return callback(new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]'));
|
||||||
} else if (data.title && data.title.length > parseInt(meta.config.maximumTitleLength, 10)) {
|
} else if (data.title && data.title.length > parseInt(meta.config.maximumTitleLength, 10)) {
|
||||||
return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'));
|
return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]'));
|
||||||
|
} else if (data.title && data.tags && data.tags.length < parseInt(meta.config.minimumTagsPerTopic, 10)) {
|
||||||
|
return callback(new Error('[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]'));
|
||||||
} else if (!data.content || data.content.length < parseInt(meta.config.minimumPostLength, 10)) {
|
} else if (!data.content || data.content.length < parseInt(meta.config.minimumPostLength, 10)) {
|
||||||
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
||||||
} else if (data.content.length > parseInt(meta.config.maximumPostLength, 10)) {
|
} else if (data.content.length > parseInt(meta.config.maximumPostLength, 10)) {
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ module.exports = function(Topics) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
checkTitleLength(title, next);
|
checkTitleLength(title, next);
|
||||||
},
|
},
|
||||||
|
function(next) {
|
||||||
|
checkTagsLength(data.tags, next);
|
||||||
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
checkContentLength(data.content, next);
|
checkContentLength(data.content, next);
|
||||||
},
|
},
|
||||||
@@ -290,6 +293,13 @@ module.exports = function(Topics) {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkTagsLength(tags, callback) {
|
||||||
|
if (!tags || tags.length < parseInt(meta.config.minimumTagsPerTopic, 10)) {
|
||||||
|
return callback(new Error('[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]'));
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
function checkContentLength(content, callback) {
|
function checkContentLength(content, callback) {
|
||||||
if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) {
|
if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) {
|
||||||
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
||||||
|
|||||||
@@ -10,7 +10,11 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="tagsPerTopics">Tags per Topic</label>
|
<label for="minimumTagsPerTopics">Minimum Tags per Topic</label>
|
||||||
|
<input id="minimumTagsPerTopics" type="text" class="form-control" value="0" data-field="minimumTagsPerTopic">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="tagsPerTopics">Maximum Tags per Topic</label>
|
||||||
<input id="tagsPerTopics" type="text" class="form-control" value="5" data-field="tagsPerTopic">
|
<input id="tagsPerTopics" type="text" class="form-control" value="5" data-field="tagsPerTopic">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user