Permalink
Browse files

[Rails] image_url() now integrates with the rails asset handling code…

… when stylesheets are generated within the rails container.

This causes your rails configuration for cache busting and asset hosts
to be picked up when generating your stylesheets. Unfortunately, all
that code runs within the context of a controller, so the stylesheets
have to be generated during first request to use this functionality.
  • Loading branch information...
chriseppstein committed May 23, 2009
1 parent ccc2823 commit 998168160b11c8702ded0a32820ea15b70d51e83
View
@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{compass}
s.version = "0.6.15"
s.version = "0.6.16"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Chris Eppstein"]
s.date = %q{2009-06-05}
s.date = %q{2009-06-11}
s.default_executable = %q{compass}
s.description = %q{Compass is a Sass-based Stylesheet Framework that streamlines the creation and maintainance of CSS.}
s.email = %q{chris@eppsteins.net}
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
"examples/blueprint_default/parts/test.jpg",
"examples/blueprint_default/parts/valid.png",
"examples/blueprint_default/src/ie.sass",
"examples/blueprint_default/src/images/grid.png",
"examples/blueprint_default/src/print.sass",
"examples/blueprint_default/src/screen.sass",
"examples/blueprint_plugins/config.rb",
@@ -55,6 +56,7 @@ Gem::Specification.new do |s|
"examples/blueprint_plugins/plugins/rtl.html.haml",
"examples/blueprint_plugins/src/buttons.sass",
"examples/blueprint_plugins/src/ie.sass",
"examples/blueprint_plugins/src/images/grid.png",
"examples/blueprint_plugins/src/link_icons.sass",
"examples/blueprint_plugins/src/print.sass",
"examples/blueprint_plugins/src/rtl_screen.sass",
@@ -74,13 +76,15 @@ Gem::Specification.new do |s|
"examples/blueprint_semantic/parts/test.jpg",
"examples/blueprint_semantic/parts/valid.png",
"examples/blueprint_semantic/src/ie.sass",
"examples/blueprint_semantic/src/images/grid.png",
"examples/blueprint_semantic/src/liquid.sass",
"examples/blueprint_semantic/src/print.sass",
"examples/blueprint_semantic/src/screen.sass",
"examples/compass/compass.html.haml",
"examples/compass/config.rb",
"examples/compass/images/blue_arrow.gif",
"examples/compass/src/compass.sass",
"examples/compass/src/images/blue_arrow.gif",
"examples/compass/src/sticky_footer.sass",
"examples/compass/src/utilities.sass",
"examples/compass/sticky_footer.html.haml",
@@ -179,6 +183,12 @@ Gem::Specification.new do |s|
"frameworks/yui/templates/project/screen.sass",
"lib/compass.rb",
"lib/compass/actions.rb",
"lib/compass/app_integration.rb",
"lib/compass/app_integration/merb.rb",
"lib/compass/app_integration/rails.rb",
"lib/compass/app_integration/rails/action_controller.rb",
"lib/compass/app_integration/rails/image_url.rb",
"lib/compass/app_integration/rails/sass_plugin.rb",
"lib/compass/commands/base.rb",
"lib/compass/commands/create_project.rb",
"lib/compass/commands/generate_grid_background.rb",
@@ -205,16 +215,22 @@ Gem::Specification.new do |s|
"lib/compass/installers/rails.rb",
"lib/compass/installers/stand_alone.rb",
"lib/compass/logger.rb",
"lib/compass/merb.rb",
"lib/compass/sass_extensions.rb",
"lib/compass/sass_extensions/functions.rb",
"lib/compass/sass_extensions/functions/enumerate.rb",
"lib/compass/sass_extensions/functions/image_url.rb",
"lib/compass/sass_extensions/functions/nest.rb",
"lib/compass/sass_extensions/monkey_patches.rb",
"lib/compass/sass_extensions/monkey_patches/stylesheet_updating.rb",
"lib/compass/test_case.rb",
"lib/compass/validator.rb",
"lib/compass/version.rb",
"lib/sass_extensions.rb",
"test/command_line_test.rb",
"test/compass_test.rb",
"test/configuration_test.rb",
"test/fixtures/stylesheets/blueprint/config.rb",
"test/fixtures/stylesheets/blueprint/css/typography.css",
"test/fixtures/stylesheets/blueprint/images/grid.png",
"test/fixtures/stylesheets/blueprint/sass/ie.sass",
"test/fixtures/stylesheets/blueprint/sass/print.sass",
"test/fixtures/stylesheets/blueprint/sass/screen.sass",
@@ -235,7 +251,9 @@ Gem::Specification.new do |s|
"test/fixtures/stylesheets/yui/sass/grids.sass",
"test/fixtures/stylesheets/yui/sass/mixins.sass",
"test/sass_extensions_test.rb",
"test/test_helper.rb"
"test/test_case_helper.rb",
"test/test_helper.rb",
"test/test_rails_helper.rb"
]
s.homepage = %q{http://compass-style.org}
s.rdoc_options = ["--charset=UTF-8"]
@@ -249,6 +267,7 @@ Gem::Specification.new do |s|
"test/configuration_test.rb",
"test/fixtures/stylesheets/blueprint/config.rb",
"test/fixtures/stylesheets/blueprint/css/typography.css",
"test/fixtures/stylesheets/blueprint/images/grid.png",
"test/fixtures/stylesheets/blueprint/sass/ie.sass",
"test/fixtures/stylesheets/blueprint/sass/print.sass",
"test/fixtures/stylesheets/blueprint/sass/screen.sass",
@@ -269,7 +288,9 @@ Gem::Specification.new do |s|
"test/fixtures/stylesheets/yui/sass/grids.sass",
"test/fixtures/stylesheets/yui/sass/mixins.sass",
"test/sass_extensions_test.rb",
"test/test_helper.rb"
"test/test_case_helper.rb",
"test/test_helper.rb",
"test/test_rails_helper.rb"
]
if s.respond_to? :specification_version then
@@ -1,3 +1,5 @@
# If we're running inside Rails
require File.join(File.dirname(__FILE__), 'app_integration', 'rails') if defined?(ActionController::Base)
# If we're running inside Merb
require File.join(File.dirname(__FILE__), 'app_integration', 'merb') if defined?(Merb::Plugins)
@@ -0,0 +1,12 @@
unless defined?(Compass::RAILS_LOADED)
Compass::RAILS_LOADED = true
require File.join(File.dirname(__FILE__), 'rails', 'action_controller')
require File.join(File.dirname(__FILE__), 'rails', 'sass_plugin')
require File.join(File.dirname(__FILE__), 'rails', 'image_url')
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
class Sass::Script::Functions::EvaluationContext
include Sass::Script::Functions
private
include ActionView::Helpers::AssetTagHelper
end
end
@@ -0,0 +1,15 @@
# :stopdoc:
module ActionController
class Base
def process_with_compass(*args)
Sass::Plugin.rails_controller = self
begin
process_without_compass(*args)
ensure
Sass::Plugin.rails_controller = nil
end
end
alias_method_chain :process, :compass
end
end
# :startdoc:
@@ -0,0 +1,14 @@
module Compass::SassExtensions::Functions::ImageUrl
def image_url_with_rails_integration(path)
if @controller = Sass::Plugin.rails_controller
begin
Sass::Script::String.new "url(#{image_path(path.value)})"
ensure
@controller = nil
end
else
image_url_without_rails_integration(path)
end
end
alias_method_chain :image_url, :rails_integration
end
@@ -0,0 +1,5 @@
module Sass::Plugin
class << self
attr_accessor :rails_controller
end
end
View
@@ -0,0 +1,20 @@
# XXX This file isn't in use at the moment, but will be used to help test
# XXX deep rails integration of compass features.
need_gems = false
# allows testing with edge Rails by creating a test/rails symlink
RAILS_ROOT = linked_rails = File.dirname(__FILE__) + '/rails'
RAILS_ENV = 'test'
if File.exists?(linked_rails) && !$:.include?(linked_rails + '/activesupport/lib')
puts "[ using linked Rails ]"
$:.unshift linked_rails + '/activesupport/lib'
$:.unshift linked_rails + '/actionpack/lib'
else
need_gems = true
end
require 'rubygems' if need_gems
require 'action_controller'
require 'action_view'

0 comments on commit 9981681

Please sign in to comment.