Node.js based forum software built for the modern web
added a screening page for external links. removed forced target = _blank on external links for UX consideration
psychobunnye66cab23cfea
diff --git a/app.js b/app.jsindex dd8d160a7e..c6eba9ba56 100644--- a/app.js+++ b/app.js@@ -70,7 +70,7 @@ if (!nconf.get('setup') && nconf.get('base_url')) {config['ROOT_DIRECTORY'] = __dirname;templates.init([- 'header', 'footer', 'logout', 'admin/header', 'admin/footer', 'admin/index',+ 'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index','emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext','emails/header', 'emails/footer', 'install/header', 'install/footer', 'install/redis',diff --git a/public/templates/outgoing.tpl b/public/templates/outgoing.tplnew file mode 100644index 0000000000..c4c6a065ae--- /dev/null+++ b/public/templates/outgoing.tpl@@ -0,0 +1,11 @@+<div class="hero-unit">+ <h2 class="form-signin-heading">Now Leaving NodeBB</h2>+ <p>+ You are now leaving NodeBB.+ </p>+ <br />+ <p>+ <button class="btn btn-large" type="button" onclick="window.location='{url}'">Continue to {url}</button>+ <button class="btn btn-large btn-inverse" type="button" onclick="history.go(-1); window.location='{home}'">Return to NodeBB</button>+ </p>+</div>\ No newline at end of filediff --git a/src/postTools.js b/src/postTools.jsindex c8a982bbc6..2850b666bf 100644--- a/src/postTools.js+++ b/src/postTools.js@@ -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;}diff --git a/src/webserver.js b/src/webserver.jsindex 1733afaea5..fae657791f 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -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