diff --git a/app.js b/app.js index 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/css/style.less b/public/css/style.less index ffa6357a27..4ea31d8a9d 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -389,7 +389,7 @@ body .navbar .nodebb-inline-block { .post-signature { color: #666; - font-size: 12.5px; + font-size: 12px; border-top: 1px solid #ddd; display: inline-block; diff --git a/public/templates/outgoing.tpl b/public/templates/outgoing.tpl new file mode 100644 index 0000000000..c4c6a065ae --- /dev/null +++ b/public/templates/outgoing.tpl @@ -0,0 +1,11 @@ +
+

Now Leaving NodeBB

+

+ You are now leaving NodeBB. +

+
+

+ + +

+
\ No newline at end of file diff --git a/src/postTools.js b/src/postTools.js index 4a00f897b6..940c39d256 100644 --- a/src/postTools.js +++ b/src/postTools.js @@ -147,14 +147,24 @@ var RDB = require('./redis.js'), }); if (md.length > 0) { - var parsedContentDOM = cheerio.load(marked(md)), - anchorText = parsedContentDOM.text(); + var parsedContentDOM = cheerio.load(marked(md)); + var domain = global.nconf.get('url'); + parsedContentDOM('a').each(function() { - this.attr('rel', 'nofollow').attr('target', '_blank'); - this.append(' '); + this.attr('rel', 'nofollow'); + var href = this.attr('href'); + + if (href && !href.match(domain)) { + this.attr('href', domain + 'outgoing?' + href); + this.append(' '); + } }); + + html = parsedContentDOM.html(); - } else html = '

'; + } else { + html = '

'; + } return html; } diff --git a/src/user.js b/src/user.js index 3ba4e7381f..d741fe3b87 100644 --- a/src/user.js +++ b/src/user.js @@ -141,7 +141,7 @@ var utils = require('./../public/src/utils.js'), User.getMultipleUserFields = function(uids, fields, callback) { if(uids.length === 0) { - callback([]); + callback({}); return; } diff --git a/src/webserver.js b/src/webserver.js index 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