renamed "toHTML" method to "parse"

This commit is contained in:
Julian Lam
2013-09-22 13:54:21 -04:00
parent c940ce3329
commit 5f00f1e18e
4 changed files with 10 additions and 27 deletions

View File

@@ -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);
});
}