From fa1275c03a6fe6c2de3e96e4f88c74f49d166690 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 22 May 2014 14:41:11 -0400 Subject: [PATCH] closes #1557 --- public/src/modules/composer/tags.js | 2 +- src/controllers/api.js | 1 + src/topics/tags.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/src/modules/composer/tags.js b/public/src/modules/composer/tags.js index c9e26c6914..4f6a6294f4 100644 --- a/public/src/modules/composer/tags.js +++ b/public/src/modules/composer/tags.js @@ -13,7 +13,7 @@ define(function() { } tagEl.tagsinput({ - maxTags: 5 // TODO: make configurable + maxTags: config.tagsPerTopic }); addTags(postData.tags, tagEl); diff --git a/src/controllers/api.js b/src/controllers/api.js index 501cf0fe60..91accc05f0 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -32,6 +32,7 @@ apiController.getConfig = function(req, res, next) { config.disableSocialButtons = parseInt(meta.config.disableSocialButtons, 10) === 1; config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5; config.reconnectionDelay = meta.config.reconnectionDelay || 200; + config.tagsPerTopic = meta.config.tagsPerTopic || 5; config.topicsPerPage = meta.config.topicsPerPage || 20; config.postsPerPage = meta.config.postsPerPage || 20; config.maximumFileSize = meta.config.maximumFileSize; diff --git a/src/topics/tags.js b/src/topics/tags.js index 77cfc27451..492723f750 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -3,14 +3,16 @@ var async = require('async'), db = require('../database'), + meta = require('../meta'), utils = require('../../public/src/utils'); 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, 20); // TODO: make max length configurable + tag = utils.removePunctuation(tag.trim().toLowerCase()).substr(0, meta.config.maximumTagLength || 15); db.setAdd('topic:' + tid + ':tags', tag);