Dynamic asset paths everywhere
* Use asset pipeline aware helpers in CSS files * Add js_image_paths to push image asset names to the client side JS
This commit is contained in:
parent
31328e4722
commit
462198799b
18 changed files with 44 additions and 52 deletions
|
|
@ -12,6 +12,8 @@ Rails.application.config.secret_token = '***********...'
|
||||||
Diaspora::Application.config.secret_key_base = '*************...'
|
Diaspora::Application.config.secret_key_base = '*************...'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You also need to take care to set `RAILS_ENV` while precompiling assets: `RAILS_ENV=production bundle exec rake assets:precompile`
|
||||||
|
|
||||||
## Change in defaults.yml
|
## Change in defaults.yml
|
||||||
The default for including jQuery from a CDN has changed. If you want to continue to include it from a CDN, please explicitly set the `jquery_cdn` setting to `true` in diaspora.yml.
|
The default for including jQuery from a CDN has changed. If you want to continue to include it from a CDN, please explicitly set the `jquery_cdn` setting to `true` in diaspora.yml.
|
||||||
|
|
||||||
|
|
|
||||||
1
Gemfile
1
Gemfile
|
|
@ -79,6 +79,7 @@ gem 'entypo-rails', '2.2.2'
|
||||||
gem 'backbone-on-rails', '1.1.1'
|
gem 'backbone-on-rails', '1.1.1'
|
||||||
gem 'handlebars_assets', '0.12.0'
|
gem 'handlebars_assets', '0.12.0'
|
||||||
gem 'jquery-rails', '3.0.4'
|
gem 'jquery-rails', '3.0.4'
|
||||||
|
gem 'js_image_paths', '0.0.1'
|
||||||
|
|
||||||
# jQuery plugins
|
# jQuery plugins
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,8 @@ GEM
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
jquery-ui-rails (4.2.1)
|
jquery-ui-rails (4.2.1)
|
||||||
railties (>= 3.2.16)
|
railties (>= 3.2.16)
|
||||||
|
js_image_paths (0.0.1)
|
||||||
|
rails (~> 4.0)
|
||||||
json (1.8.1)
|
json (1.8.1)
|
||||||
jwt (1.0.0)
|
jwt (1.0.0)
|
||||||
kaminari (0.16.1)
|
kaminari (0.16.1)
|
||||||
|
|
@ -535,6 +537,7 @@ DEPENDENCIES
|
||||||
jasmine (= 2.0.2)
|
jasmine (= 2.0.2)
|
||||||
jasmine-jquery-rails (= 2.0.3)
|
jasmine-jquery-rails (= 2.0.3)
|
||||||
jquery-rails (= 3.0.4)
|
jquery-rails (= 3.0.4)
|
||||||
|
js_image_paths (= 0.0.1)
|
||||||
json (= 1.8.1)
|
json (= 1.8.1)
|
||||||
markerb (= 1.0.2)
|
markerb (= 1.0.2)
|
||||||
messagebus_ruby_api (= 1.0.3)
|
messagebus_ruby_api (= 1.0.3)
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,6 @@ var app = {
|
||||||
return this._user || false
|
return this._user || false
|
||||||
},
|
},
|
||||||
|
|
||||||
baseImageUrl: function(baseUrl){
|
|
||||||
if(baseUrl) { return this._baseImageUrl = baseUrl }
|
|
||||||
return this._baseImageUrl || "assets/"
|
|
||||||
},
|
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
app.router = new app.Router();
|
app.router = new app.Router();
|
||||||
|
|
||||||
|
|
@ -91,8 +86,8 @@ var app = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setupFacebox: function() {
|
setupFacebox: function() {
|
||||||
$.facebox.settings.closeImage = app.baseImageUrl()+'facebox/closelabel.png';
|
$.facebox.settings.closeImage = ImagePaths.get('facebox/closelabel.png');
|
||||||
$.facebox.settings.loadingImage = app.baseImageUrl()+'facebox/loading.gif';
|
$.facebox.settings.loadingImage = ImagePaths.get('facebox/loading.gif');
|
||||||
$.facebox.settings.opacity = 0.75;
|
$.facebox.settings.opacity = 0.75;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ Handlebars.registerHelper('t', function(scope, values) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Handlebars.registerHelper('imageUrl', function(path){
|
Handlebars.registerHelper('imageUrl', function(path){
|
||||||
return app.baseImageUrl() + path;
|
return ImagePaths.get(path);
|
||||||
});
|
});
|
||||||
|
|
||||||
Handlebars.registerHelper('linkToPerson', function(context, block) {
|
Handlebars.registerHelper('linkToPerson', function(context, block) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ app.views.Location = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(){
|
render: function(){
|
||||||
$(this.el).append('<img alt="delete location" src="/assets/ajax-loader.gif">');
|
$(this.el).append('<img alt="delete location" src="'+ImagePaths.get('ajax-loader.gif')+'">');
|
||||||
},
|
},
|
||||||
|
|
||||||
getLocation: function(e){
|
getLocation: function(e){
|
||||||
|
|
@ -18,7 +18,7 @@ app.views.Location = Backbone.View.extend({
|
||||||
locator.getAddress(function(address, latlng){
|
locator.getAddress(function(address, latlng){
|
||||||
$(element).html('<input id="location_address" type="text" class="input-block-level" value="' + address + '"/>');
|
$(element).html('<input id="location_address" type="text" class="input-block-level" value="' + address + '"/>');
|
||||||
$('#location_coords').val(latlng.latitude + "," + latlng.longitude);
|
$('#location_coords').val(latlng.latitude + "," + latlng.longitude);
|
||||||
$(element).append('<a id="hide_location"><img alt="delete location" src="/assets/deletelabel.png"></a>');
|
$(element).append('<a id="hide_location"><img alt="delete location" src="'+ImagePaths.get('deletelabel.png')+'"></a>');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ $(document).ready(function(){
|
||||||
debug: false,
|
debug: false,
|
||||||
donetext: "no more.",
|
donetext: "no more.",
|
||||||
loadingText: "",
|
loadingText: "",
|
||||||
loadingImg: '/assets/ajax-loader.gif'
|
loadingImg: ImagePaths.get('ajax-loader.gif')
|
||||||
}, function(){
|
}, function(){
|
||||||
$('.conversation-wrapper', '.stream').bind('mousedown', function(){
|
$('.conversation-wrapper', '.stream').bind('mousedown', function(){
|
||||||
bindIt($(this));
|
bindIt($(this));
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
* licensed under the Affero General Public License version 3 or later. See
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
|
//= require js_image_paths
|
||||||
//= require underscore
|
//= require underscore
|
||||||
//= require backbone
|
//= require backbone
|
||||||
//= require jquery.hotkeys
|
//= require jquery.hotkeys
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ function createUploader(){
|
||||||
$('#publisher_textarea_wrapper').addClass("with_attachments");
|
$('#publisher_textarea_wrapper').addClass("with_attachments");
|
||||||
$('#photodropzone').append(
|
$('#photodropzone').append(
|
||||||
"<li class='publisher_photo loading' style='position:relative;'>" +
|
"<li class='publisher_photo loading' style='position:relative;'>" +
|
||||||
"<img alt='Ajax-loader2' src='/assets/ajax-loader2.gif' />" +
|
"<img alt='Ajax-loader2' src='"+ImagePaths.get('ajax-loader2.gif')+"' />" +
|
||||||
"</li>"
|
"</li>"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ var View = {
|
||||||
|
|
||||||
avatars: {
|
avatars: {
|
||||||
fallback: function(evt) {
|
fallback: function(evt) {
|
||||||
$(this).attr("src", "/assets/user/default.png");
|
$(this).attr("src", ImagePaths.get("user/default.png"));
|
||||||
},
|
},
|
||||||
selector: "img.avatar"
|
selector: "img.avatar"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
debug: false,
|
debug: false,
|
||||||
donetext: Diaspora.I18n.t("infinite_scroll.no_more"),
|
donetext: Diaspora.I18n.t("infinite_scroll.no_more"),
|
||||||
loadingText: "",
|
loadingText: "",
|
||||||
loadingImg: "/assets/ajax-loader.gif",
|
loadingImg: ImagePaths.get("ajax-loader.gif"),
|
||||||
navSelector: "#pagination",
|
navSelector: "#pagination",
|
||||||
nextSelector: ".paginate",
|
nextSelector: ".paginate",
|
||||||
itemSelector: ".stream_element",
|
itemSelector: ".stream_element",
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ jQuery.fn.center = (function() {
|
||||||
this.resetLightbox = function() {
|
this.resetLightbox = function() {
|
||||||
self.lightbox.hide();
|
self.lightbox.hide();
|
||||||
self.body.removeClass("lightboxed");
|
self.body.removeClass("lightboxed");
|
||||||
self.image.attr("src", "assets/ajax-loader2.gif");
|
self.image.attr("src", ImagePaths.get("ajax-loader2.gif"));
|
||||||
self.imageset.html("");
|
self.imageset.html("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
body > header {
|
body > header {
|
||||||
@include box-shadow(0,1px,3px,rgba(0,0,0,0.9));
|
@include box-shadow(0,1px,3px,rgba(0,0,0,0.9));
|
||||||
background: url('header-bg.png') rgb(40,35,35);
|
background: image-url('header-bg.png') rgb(40,35,35);
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
padding: 6px 0;
|
padding: 6px 0;
|
||||||
color: #CCC;
|
color: #CCC;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ header {
|
||||||
height: 45px;
|
height: 45px;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
background: url('../header-bg-long.jpg') rgb(40,35,35);
|
background: image-url('header-bg-long.jpg') rgb(40,35,35);
|
||||||
@include box-shadow(0, 1px, 2px, #333);
|
@include box-shadow(0, 1px, 2px, #333);
|
||||||
border-bottom: 1px solid #222;
|
border-bottom: 1px solid #222;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ ul.as-selections {
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.as-selections.loading {
|
ul.as-selections.loading {
|
||||||
background: url("/assets/ajax-loader.gif") right center no-repeat;
|
background: url('<%= image_path("ajax-loader.gif") %>') right center no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.as-selections li {
|
ul.as-selections li {
|
||||||
|
|
@ -19,15 +19,6 @@ module LayoutHelper
|
||||||
pod_name
|
pod_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_asset_host
|
|
||||||
path = AppConfig.environment.assets.host.to_s + '/assets/'
|
|
||||||
content_tag(:script) do
|
|
||||||
<<-JS.html_safe
|
|
||||||
if(window.app) app.baseImageUrl("#{path}")
|
|
||||||
JS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def load_javascript_locales(section = 'javascripts')
|
def load_javascript_locales(section = 'javascripts')
|
||||||
content_tag(:script) do
|
content_tag(:script) do
|
||||||
<<-JS.html_safe
|
<<-JS.html_safe
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ class Profile < ActiveRecord::Base
|
||||||
else
|
else
|
||||||
self[:image_url]
|
self[:image_url]
|
||||||
end
|
end
|
||||||
result || '/assets/user/default.png'
|
result || ActionController::Base.helpers.image_path('user/default.png')
|
||||||
end
|
end
|
||||||
|
|
||||||
def from_omniauth_hash(omniauth_user_hash)
|
def from_omniauth_hash(omniauth_user_hash)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
= javascript_include_tag :main, :templates
|
= javascript_include_tag :main, :templates
|
||||||
= load_javascript_locales
|
= load_javascript_locales
|
||||||
|
|
||||||
= set_asset_host
|
|
||||||
= translation_missing_warnings
|
= translation_missing_warnings
|
||||||
= current_user_atom_tag
|
= current_user_atom_tag
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue