mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
renamed "toHTML" method to "parse"
This commit is contained in:
@@ -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>');
|
||||
}
|
||||
callback(null, parsed);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user