mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user