mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
closes #4378
This commit is contained in:
@@ -92,6 +92,23 @@
|
|||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanUpTag: function(tag, maxLength) {
|
||||||
|
if (typeof tag !== 'string' || !tag.length ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
tag = tag.trim().toLowerCase();
|
||||||
|
// see https://github.com/NodeBB/NodeBB/issues/4378
|
||||||
|
tag = tag.replace(/\u202E/gi, '');
|
||||||
|
tag = tag.replace(/[,\/#!$%\^\*;:{}=_`<>'"~()?\|]/g, '');
|
||||||
|
tag = tag.substr(0, maxLength || 15).trim();
|
||||||
|
var matches = tag.match(/^[.-]*(.+?)[.-]*$/);
|
||||||
|
if (matches && matches.length > 1) {
|
||||||
|
tag = matches[1];
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
},
|
||||||
|
|
||||||
removePunctuation: function(str) {
|
removePunctuation: function(str) {
|
||||||
return str.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`<>'"~()?]/g, '');
|
return str.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`<>'"~()?]/g, '');
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* bootstrap-tagsinput v0.8.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
.bootstrap-tagsinput {
|
.bootstrap-tagsinput {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 4px 6px;
|
padding: 4px 6px;
|
||||||
margin-bottom: 10px;
|
|
||||||
color: #555;
|
color: #555;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@@ -17,11 +21,21 @@
|
|||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
padding: 0;
|
padding: 0 6px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: auto !important;
|
width: auto;
|
||||||
max-width: inherit;
|
max-width: inherit;
|
||||||
}
|
}
|
||||||
|
.bootstrap-tagsinput.form-control input::-moz-placeholder {
|
||||||
|
color: #777;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.bootstrap-tagsinput.form-control input:-ms-input-placeholder {
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
.bootstrap-tagsinput.form-control input::-webkit-input-placeholder {
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
.bootstrap-tagsinput input:focus {
|
.bootstrap-tagsinput input:focus {
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
@@ -43,4 +57,4 @@
|
|||||||
}
|
}
|
||||||
.bootstrap-tagsinput .tag [data-role="remove"]:hover:active {
|
.bootstrap-tagsinput .tag [data-role="remove"]:hover:active {
|
||||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
|
|
||||||
db = require('../database'),
|
var db = require('../database');
|
||||||
meta = require('../meta'),
|
var meta = require('../meta');
|
||||||
_ = require('underscore'),
|
var _ = require('underscore');
|
||||||
plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
|
var utils = require('../../public/src/utils');
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(Topics) {
|
module.exports = function(Topics) {
|
||||||
@@ -24,7 +25,9 @@ module.exports = function(Topics) {
|
|||||||
},
|
},
|
||||||
function (data, next) {
|
function (data, next) {
|
||||||
tags = data.tags.slice(0, meta.config.maximumTagsPerTopic || 5);
|
tags = data.tags.slice(0, meta.config.maximumTagsPerTopic || 5);
|
||||||
tags = tags.map(Topics.cleanUpTag).filter(function(tag, index, array) {
|
tags = tags.map(function(tag) {
|
||||||
|
return utils.cleanUpTag(tag, meta.config.maximumTagLength);
|
||||||
|
}).filter(function(tag, index, array) {
|
||||||
return tag && tag.length >= (meta.config.minimumTagLength || 3) && array.indexOf(tag) === index;
|
return tag && tag.length >= (meta.config.minimumTagLength || 3) && array.indexOf(tag) === index;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,20 +48,6 @@ module.exports = function(Topics) {
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.cleanUpTag = function(tag) {
|
|
||||||
if (typeof tag !== 'string' || !tag.length ) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
tag = tag.trim().toLowerCase();
|
|
||||||
tag = tag.replace(/[,\/#!$%\^\*;:{}=_`<>'"~()?\|]/g, '');
|
|
||||||
tag = tag.substr(0, meta.config.maximumTagLength || 15).trim();
|
|
||||||
var matches = tag.match(/^[.-]*(.+?)[.-]*$/);
|
|
||||||
if (matches && matches.length > 1) {
|
|
||||||
tag = matches[1];
|
|
||||||
}
|
|
||||||
return tag;
|
|
||||||
};
|
|
||||||
|
|
||||||
Topics.updateTag = function(tag, data, callback) {
|
Topics.updateTag = function(tag, data, callback) {
|
||||||
db.setObject('tag:' + tag, data, callback);
|
db.setObject('tag:' + tag, data, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user