mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-13 08:00:43 +01:00
closes #1565
This commit is contained in:
@@ -13,7 +13,8 @@ define(function() {
|
||||
}
|
||||
|
||||
tagEl.tagsinput({
|
||||
maxTags: config.tagsPerTopic
|
||||
maxTags: config.tagsPerTopic,
|
||||
confirmKeys: [13, 188]
|
||||
});
|
||||
addTags(postData.tags, tagEl);
|
||||
|
||||
|
||||
@@ -11,9 +11,13 @@ module.exports = function(Topics) {
|
||||
Topics.createTags = function(tags, tid, timestamp, callback) {
|
||||
if(Array.isArray(tags)) {
|
||||
tags = tags.slice(0, meta.config.tagsPerTopic || 5);
|
||||
async.each(tags, function(tag, next) {
|
||||
tag = utils.removePunctuation(tag.trim().toLowerCase()).substr(0, meta.config.maximumTagLength || 15);
|
||||
|
||||
async.each(tags, function(tag, next) {
|
||||
tag = cleanUpTag(tag);
|
||||
|
||||
if (tag.length < (meta.config.minimumTagLength || 3)) {
|
||||
return next();
|
||||
}
|
||||
db.setAdd('topic:' + tid + ':tags', tag);
|
||||
|
||||
db.sortedSetAdd('tag:' + tag + ':topics', timestamp, tid, function(err) {
|
||||
@@ -26,6 +30,17 @@ module.exports = function(Topics) {
|
||||
}
|
||||
};
|
||||
|
||||
function cleanUpTag(tag) {
|
||||
tag = tag.trim().toLowerCase();
|
||||
var matches = tag.match(/^-*(.+?)-*$/);
|
||||
if (matches && matches.length > 1) {
|
||||
tag = matches[1];
|
||||
}
|
||||
tag = tag.replace(/[\.,\/#!$%\^&\*;:{}=_`<>'"~()?\|]/g, '');
|
||||
tag = tag.substr(0, meta.config.maximumTagLength || 15);
|
||||
return tag;
|
||||
}
|
||||
|
||||
function updateTagCount(tag) {
|
||||
Topics.getTagTopicCount(tag, function(err, count) {
|
||||
if (!err) {
|
||||
|
||||
Reference in New Issue
Block a user