added a screening page for external links. removed forced target = _blank on external links for UX consideration

used http://www.deviantart.com/users/outgoing?http://www.nodebb.org/ for
inspiration
This commit is contained in:
psychobunny
2013-07-23 03:07:27 +08:00
parent d9fa78a866
commit e66cab23cf
4 changed files with 38 additions and 3 deletions

View File

@@ -148,9 +148,19 @@ var RDB = require('./redis.js'),
if (md.length > 0) {
var parsedContentDOM = cheerio.load(marked(md));
parsedContentDOM('a').attr('rel', 'nofollow').attr('target', '_blank');
parsedContentDOM('a').attr('rel', 'nofollow');
var href = parsedContentDOM('a').attr('href'),
domain = global.nconf.get('url');
if (href && !href.match(domain)) {
parsedContentDOM('a').attr('href', domain + 'outgoing?' + href);
}
html = parsedContentDOM.html();
} else html = '<p></p>';
} else {
html = '<p></p>';
}
return html;
}