v1.18.x
barisusakli 11 years ago
parent 4ca04067f0
commit dbf07f786d

@ -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);
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) {

Loading…
Cancel
Save