Commit 38d774c0 authored by 杨翌文's avatar 杨翌文

1

parent c23eac24
...@@ -11,7 +11,7 @@ var async = require('async'); ...@@ -11,7 +11,7 @@ var async = require('async');
var then = require('thenjs'); var then = require('thenjs');
var threadFields = { var threadFields = {
'content':0, 'content':1,
'type':1, 'type':1,
'title':1, 'title':1,
'pid':1, 'pid':1,
...@@ -28,6 +28,36 @@ var threadFields = { ...@@ -28,6 +28,36 @@ var threadFields = {
}; };
/**
* 过滤 html 标签正则
* @type {RegExp}
*/
var htmlElReg = /<[^>]*>/ig;
/**
* 过滤表情正则
* @type {RegExp}
*/
var emElReg = /\【em_([0-9]*)\】/ig;
/**
* 帖子内容处理函数
* @param {String} content 原始帖子内容
* @return {String} 处理完的帖子
*/
function handleContent(content) {
content = content || "";
content = content
.replace(htmlElReg, "")
.replace(emElReg, "");
if (content.length > threadsConf.contentLength) {
content = content.substr(0, threadsConf.contentLength) + "……";
}
return content.trim();
}
//根据发帖者分页查询话题列表 //根据发帖者分页查询话题列表
exports.findThreadByPage = function(pageNo, pageSize, q, callback) { exports.findThreadByPage = function(pageNo, pageSize, q, callback) {
then(function(cont) { then(function(cont) {
...@@ -686,6 +716,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) { ...@@ -686,6 +716,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
docs.forEach(function(doc) { docs.forEach(function(doc) {
// console.log(doc); // console.log(doc);
doc.content = handleContent(doc.content);
if (doc.type === 1 || doc.level !== 1) { //非照片墙或文章时获取评论 if (doc.type === 1 || doc.level !== 1) { //非照片墙或文章时获取评论
asyncTasks.push(function(callback) { asyncTasks.push(function(callback) {
populateComment(doc, callback); populateComment(doc, callback);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment