revert - FIX: use CDN for user card/profile background and user avatars

This commit is contained in:
Régis Hanol 2015-01-29 20:42:05 +01:00
parent 07d5d8faac
commit 22adb682d8
6 changed files with 12 additions and 18 deletions

View File

@ -24,12 +24,6 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
return u + url;
},
getURLWithCDN: function(url) {
url = this.getURL(url);
if (Discourse.CDN) { url = Discourse.CDN + url; }
return url;
},
Resolver: DiscourseResolver,
_titleChanged: function() {

View File

@ -1,5 +1,4 @@
var esc = Handlebars.Utils.escapeExpression;
Discourse.BBCode.register('quote', {noWrap: true, singlePara: true}, function(contents, bbParams, options) {
var params = {'class': 'quote'},
username = null;

View File

@ -51,7 +51,7 @@ Discourse.Utilities = {
var classes = "avatar" + (options.extraClasses ? " " + options.extraClasses : "");
var title = (options.title) ? " title='" + Handlebars.Utils.escapeExpression(options.title || "") + "'" : "";
return "<img width='" + size + "' height='" + size + "' src='" + Discourse.getURLWithCDN(url) + "' class='" + classes + "'" + title + ">";
return "<img width='" + size + "' height='" + size + "' src='" + url + "' class='" + classes + "'" + title + ">";
},
tinyAvatar: function(avatarTemplate, options) {

View File

@ -72,9 +72,10 @@ Discourse.User = Discourse.Model.extend({
@type {String}
**/
profileBackground: function() {
var url = this.get('profile_background');
if (Em.isEmpty(url) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
return 'background-image: url(' + Discourse.getURLWithCDN(url) + ')';
var background = this.get('profile_background');
if(Em.isEmpty(background) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
return 'background-image: url(' + background + ')';
}.property('profile_background'),
/**
@ -441,7 +442,6 @@ Discourse.User.reopenClass(Discourse.Singleton, {
avatarTemplate: function(username, uploadedAvatarId) {
var url;
if (uploadedAvatarId) {
url = "/user_avatar/" +
Discourse.BaseUrl +
@ -456,7 +456,11 @@ Discourse.User.reopenClass(Discourse.Singleton, {
Discourse.LetterAvatarVersion + ".png";
}
return Discourse.getURLWithCDN(url);
url = Discourse.getURL(url);
if (Discourse.CDN) {
url = Discourse.CDN + url;
}
return url;
},
/**

View File

@ -11,7 +11,6 @@ export default Discourse.View.extend(CleansUp, {
addBackground: function() {
var url = this.get('controller.user.card_background');
if (!this.get('allowBackgrounds')) { return; }
var $this = this.$();
@ -20,7 +19,7 @@ export default Discourse.View.extend(CleansUp, {
if (Ember.isEmpty(url)) {
$this.css('background-image', '').addClass('no-bg');
} else {
$this.css('background-image', "url(" + Discourse.getURLWithCDN(url) + ")").removeClass('no-bg');
$this.css('background-image', "url(" + url + ")").removeClass('no-bg');
}
}.observes('controller.user.card_background'),

View File

@ -128,9 +128,7 @@ module PrettyText
context.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
context.eval("Discourse.BaseUrl = 'http://#{RailsMultisite::ConnectionManagement.current_hostname}';")
context.eval("Discourse.getURL = function(url) { return '#{Discourse::base_uri}' + url };")
context.eval("Discourse.getURLWithCDN = function(url) { url = Discourse.getURL(url); if (Discourse.CDN) { url = Discourse.CDN + url; } return url; };")
context.eval("Discourse.getURL = function(url) {return '#{Discourse::base_uri}' + url};")
end
def self.markdown(text, opts=nil)