mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-04 12:08:00 +02:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -278,6 +278,20 @@ var express = require('express'),
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/outgoing', function(req, res) {
|
||||
var url = req.url.split('?');
|
||||
|
||||
if (url[1]) {
|
||||
res.send(app.build_header(res) + templates['outgoing'].parse({
|
||||
url: url[1],
|
||||
home: global.nconf.get('url')
|
||||
}) + templates['footer']);
|
||||
} else {
|
||||
res.status(404);
|
||||
res.redirect(global.nconf.get('relative_path') + '/404');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// These functions are called via ajax once the initial page is loaded to populate templates with data
|
||||
|
||||
Reference in New Issue
Block a user