mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +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 + ']]');
|
||||
} else if (checkTitle && !utils.slugify(titleEl.val()).length) {
|
||||
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)) {
|
||||
return composerAlert(post_uuid, '[[error:content-too-short, ' + config.minimumPostLength + ']]');
|
||||
} else if (bodyEl.val().length > parseInt(config.maximumPostLength, 10)) {
|
||||
|
||||
@@ -13,6 +13,7 @@ define('composer/tags', function() {
|
||||
}
|
||||
|
||||
tagEl.tagsinput({
|
||||
minTags: config.minimumTagsPerTopic,
|
||||
maxTags: config.tagsPerTopic,
|
||||
maxChars: config.maximumTagLength,
|
||||
confirmKeys: [13, 44],
|
||||
|
||||
@@ -55,6 +55,7 @@ apiController.getConfig = function(req, res, next) {
|
||||
config.disableChat = parseInt(meta.config.disableChat, 10) === 1;
|
||||
config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5;
|
||||
config.reconnectionDelay = meta.config.reconnectionDelay || 1500;
|
||||
config.minimumTagsPerTopic = meta.config.minimumTagsPerTopic || 0;
|
||||
config.tagsPerTopic = meta.config.tagsPerTopic || 5;
|
||||
config.minimumTagLength = meta.config.minimumTagLength || 3;
|
||||
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 + ']]'));
|
||||
} else if (data.title && data.title.length > parseInt(meta.config.maximumTitleLength, 10)) {
|
||||
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)) {
|
||||
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
||||
} else if (data.content.length > parseInt(meta.config.maximumPostLength, 10)) {
|
||||
|
||||
@@ -96,6 +96,9 @@ module.exports = function(Topics) {
|
||||
function(next) {
|
||||
checkTitleLength(title, next);
|
||||
},
|
||||
function(next) {
|
||||
checkTagsLength(data.tags, next);
|
||||
},
|
||||
function(next) {
|
||||
checkContentLength(data.content, next);
|
||||
},
|
||||
@@ -290,6 +293,13 @@ module.exports = function(Topics) {
|
||||
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) {
|
||||
if (!content || content.length < parseInt(meta.config.miminumPostLength, 10)) {
|
||||
return callback(new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]'));
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
</label>
|
||||
</div>
|
||||
<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">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user