From e035d8f1deb592dca3dac450dea97dfbad9a55ee Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 30 May 2014 15:22:52 -0400 Subject: [PATCH] closes #1497 fixes user images in subfolder installs, if user image has https dont append relative_path, also removes relative_path in ajaxify.loadData so it doesnt call /forum/api/forum/category etc. --- public/src/ajaxify.js | 16 ++++++++++++---- src/user.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index a1780099cb..fe2dad2faf 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -60,9 +60,8 @@ var ajaxify = ajaxify || {}; // Remove trailing slash url = url.replace(/\/$/, ""); - if (url.indexOf(RELATIVE_PATH.slice(1)) !== -1) { - url = url.slice(RELATIVE_PATH.length); - } + url = removeRelativePath(url); + var tpl_url = ajaxify.getTemplateMapping(url); var hash = ''; @@ -124,6 +123,13 @@ var ajaxify = ajaxify || {}; return false; }; + function removeRelativePath(url) { + if (url.indexOf(RELATIVE_PATH.slice(1)) !== -1) { + url = url.slice(RELATIVE_PATH.length); + } + return url; + } + ajaxify.refresh = function() { ajaxify.go(ajaxify.currentPage); }; @@ -181,6 +187,8 @@ var ajaxify = ajaxify || {}; }; ajaxify.loadData = function(url, callback) { + url = removeRelativePath(url); + $(window).trigger('action:ajaxify.loadingData', {url: url}); if (ajaxify.preloader && ajaxify.preloader[url]) { @@ -295,7 +303,7 @@ var ajaxify = ajaxify || {}; // Internal link var url = this.href.replace(rootUrl + '/', ''), currentTime = (new Date()).getTime(); - + if (!ajaxify.preloader[url] || currentTime - ajaxify.preloader[url].lastFetched > PRELOADER_RATE_LIMIT) { ajaxify.preloader[url] = null; ajaxify.loadData(url, function(err, data) { diff --git a/src/user.js b/src/user.js index c676267363..c7fec2596a 100644 --- a/src/user.js +++ b/src/user.js @@ -122,7 +122,7 @@ var bcrypt = require('bcryptjs'), if (user.picture) { if (user.picture === user.uploadedpicture) { - user.picture = nconf.get('relative_path') + user.picture; + user.picture = user.picture.indexOf('http') === -1 ? nconf.get('relative_path') + user.picture : user.picture; } else { user.picture = User.createGravatarURLFromEmail(user.email); }