From 0481fbae8cbec486a720d12eaf66f80a57945bab Mon Sep 17 00:00:00 2001 From: Wojciech Kocjan Date: Fri, 5 Apr 2013 12:46:14 +0200 Subject: [PATCH] Fix for reply to user avatar and picture uploading not working when editing post with discourse running in a prefix --- app/assets/javascripts/discourse/components/utilities.js | 2 +- app/assets/javascripts/discourse/views/composer_view.js | 2 +- app/models/upload.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/utilities.js b/app/assets/javascripts/discourse/components/utilities.js index 673ad474727..05926e764ce 100644 --- a/app/assets/javascripts/discourse/components/utilities.js +++ b/app/assets/javascripts/discourse/components/utilities.js @@ -53,7 +53,7 @@ Discourse.Utilities = { if (template) { return template.replace(/\{size\}/g, rawSize); } - return "/users/" + (username.toLowerCase()) + "/avatar/" + rawSize + "?__ws=" + (encodeURIComponent(Discourse.BaseUrl || "")); + return Discourse.getURL("/users/") + (username.toLowerCase()) + "/avatar/" + rawSize + "?__ws=" + (encodeURIComponent(Discourse.BaseUrl || "")); }, avatarImg: function(options) { diff --git a/app/assets/javascripts/discourse/views/composer_view.js b/app/assets/javascripts/discourse/views/composer_view.js index 91264658fa8..0ad1a7136c5 100644 --- a/app/assets/javascripts/discourse/views/composer_view.js +++ b/app/assets/javascripts/discourse/views/composer_view.js @@ -270,7 +270,7 @@ Discourse.ComposerView = Discourse.View.extend({ $uploadTarget.off(); $uploadTarget.fileupload({ - url: '/uploads', + url: Discourse.getURL('/uploads'), dataType: 'json', timeout: 20000, formData: { topic_id: 1234 } diff --git a/app/models/upload.rb b/app/models/upload.rb index f59d2082efb..1e70e7539e2 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -48,7 +48,7 @@ class Upload < ActiveRecord::Base File.open("#{path}/#{clean_name}", "wb") do |f| f.write File.read(file.tempfile) end - upload.url = "#{url_root}/#{clean_name}" + upload.url = Discourse::base_uri + "#{url_root}/#{clean_name}" upload.save upload