Node.js based forum software built for the modern web
renamed "toHTML" method to "parse"
Julian Lam5f00f1e18e84
diff --git a/src/postTools.js b/src/postTools.jsindex cbe2df1931..8913a1e787 100644--- a/src/postTools.js+++ b/src/postTools.js@@ -87,7 +87,7 @@ var RDB = require('./redis.js'),});},function(next) {- PostTools.toHTML(content, next);+ PostTools.parse(content, next);}], function(err, results) {io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', {@@ -190,28 +190,11 @@ var RDB = require('./redis.js'),});}- PostTools.toHTML = function(raw, callback) {+ PostTools.parse = function(raw, callback) {raw = raw || '';- plugins.fireHook('filter:post.parse', raw, function(parsed) {- var cheerio = require('cheerio');-- if (parsed && parsed.length > 0) {- var parsedContentDOM = cheerio.load(parsed);- var domain = nconf.get('url');-- parsedContentDOM('a').each(function() {- this.attr('rel', 'nofollow');- var href = this.attr('href');-- if (href && !href.match(domain) && !utils.isRelativeUrl(href)) {- this.attr('href', domain + 'outgoing?url=' + encodeURIComponent(href));- }- });- callback(null, parsedContentDOM.html());- } else {- callback(null, '<p></p>');- }+ plugins.fireHook('filter:post.parse', raw, function(parsed) {+ callback(null, parsed);});}diff --git a/src/posts.js b/src/posts.jsindex dee76c0474..6ecc0db2f3 100644--- a/src/posts.js+++ b/src/posts.js@@ -36,7 +36,7 @@ var RDB = require('./redis.js'),user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {if (err) return callback();- postTools.toHTML(userData.signature, function(err, signature) {+ postTools.parse(userData.signature, function(err, signature) {post.username = userData.username || 'anonymous';post.userslug = userData.userslug || '';post.user_rep = userData.reputation || 0;@@ -91,7 +91,7 @@ var RDB = require('./redis.js'),},function(postData, next) {if (postData.content) {- postTools.toHTML(postData.content, function(err, content) {+ postTools.parse(postData.content, function(err, content) {if (!err) postData.content = utils.strip_tags(content);next(err, postData);});@@ -164,7 +164,7 @@ var RDB = require('./redis.js'),postData['edited-class'] = postData.editor !== '' ? '' : 'none';postData['relativeEditTime'] = postData.edited !== '0' ? (new Date(parseInt(postData.edited,10)).toISOString()) : '';- postTools.toHTML(postData.content, function(err, content) {+ postTools.parse(postData.content, function(err, content) {postData.content = content;posts.push(postData);callback(null);@@ -321,7 +321,7 @@ var RDB = require('./redis.js'),async.parallel({content: function(next) {plugins.fireHook('filter:post.get', postData, function(postData) {- postTools.toHTML(postData.content, function(err, content) {+ postTools.parse(postData.content, function(err, content) {next(null, content);});});diff --git a/src/routes/user.js b/src/routes/user.jsindex 78cd6da6c6..3af6aa17e9 100644--- a/src/routes/user.js+++ b/src/routes/user.js@@ -418,7 +418,7 @@ var user = require('./../user.js'),if (callerUID !== userData.uid)user.incrementUserFieldBy(userData.uid, 'profileviews', 1);- postTools.toHTML(userData.signature, function(err, signature) {+ postTools.parse(userData.signature, function(err, signature) {userData.signature = signature;res.json(userData);});diff --git a/src/topics.js b/src/topics.jsindex f6d21ae186..e3b8bfc98d 100644--- a/src/topics.js+++ b/src/topics.js@@ -590,7 +590,7 @@ schema = require('./schema.js'),if (postData.content) {stripped = postData.content.replace(/>.+\n\n/, '');- postTools.toHTML(stripped, function(err, stripped) {+ postTools.parse(stripped, function(err, stripped) {returnObj.text = utils.strip_tags(stripped);callback(null, returnObj);});