removed rails integration files
This commit is contained in:
parent
986714a013
commit
829d44f581
@ -1,83 +0,0 @@
|
|||||||
%w(configuration_defaults installer).each do |lib|
|
|
||||||
require "compass/app_integration/rails/#{lib}"
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'compass/app_integration/rails/runtime' if defined?(ActionController::Base)
|
|
||||||
|
|
||||||
|
|
||||||
module Compass
|
|
||||||
module AppIntegration
|
|
||||||
module Rails
|
|
||||||
|
|
||||||
extend self
|
|
||||||
|
|
||||||
def booted!
|
|
||||||
Compass::AppIntegration::Rails.const_set(:BOOTED, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def booted?
|
|
||||||
defined?(Compass::AppIntegration::Rails::BOOTED) && Compass::AppIntegration::Rails::BOOTED
|
|
||||||
end
|
|
||||||
|
|
||||||
def installer(*args)
|
|
||||||
Installer.new(*args)
|
|
||||||
end
|
|
||||||
|
|
||||||
def configuration
|
|
||||||
config = Compass::Configuration::Data.new('rails')
|
|
||||||
config.extend(ConfigurationDefaults)
|
|
||||||
config.extend(ConfigurationDefaultsWithAssetPipeline) if Sass::Util.ap_geq?('3.1.0') || Sass::Util.ap_geq?('3.1.0.rc') || Sass::Util.ap_geq?('3.1.0.beta')
|
|
||||||
config
|
|
||||||
end
|
|
||||||
|
|
||||||
def env
|
|
||||||
env_production? ? :production : :development
|
|
||||||
end
|
|
||||||
|
|
||||||
def env_production?
|
|
||||||
if defined?(::Rails) && ::Rails.respond_to?(:env)
|
|
||||||
::Rails.env.production?
|
|
||||||
elsif defined?(RAILS_ENV)
|
|
||||||
RAILS_ENV == "production"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def root
|
|
||||||
if defined?(::Rails) && ::Rails.respond_to?(:root)
|
|
||||||
::Rails.root
|
|
||||||
elsif defined?(RAILS_ROOT)
|
|
||||||
RAILS_ROOT
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_for_double_boot!
|
|
||||||
if booted?
|
|
||||||
Compass::Util.compass_warn("Warning: Compass was booted twice. Compass has a Railtie now; please remove your initializer.")
|
|
||||||
else
|
|
||||||
booted!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def sass_plugin_enabled?
|
|
||||||
unless Sass::Util.ap_geq?('3.1.0.beta')
|
|
||||||
defined?(Sass::Plugin) && !Sass::Plugin.options[:never_update]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def rails_compilation_enabled?
|
|
||||||
Sass::Util.ap_geq?('3.1.0.beta') && defined?(Sass::Rails) # XXX check if there's some other way(s) to disable the asset pipeline.
|
|
||||||
end
|
|
||||||
|
|
||||||
# Rails 2.x projects use this in their compass initializer.
|
|
||||||
def initialize!(config = nil)
|
|
||||||
check_for_double_boot!
|
|
||||||
config ||= Compass.detect_configuration_file(root)
|
|
||||||
Compass.add_project_configuration(config, :project_type => :rails)
|
|
||||||
Compass.discover_extensions!
|
|
||||||
Compass.configure_sass_plugin!
|
|
||||||
Compass.handle_configuration_change! if sass_plugin_enabled? || rails_compilation_enabled?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
%w(action_controller sass_plugin urls).each do |lib|
|
|
||||||
require "compass/app_integration/rails/actionpack2x/#{lib}"
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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
|
|
@ -1,15 +0,0 @@
|
|||||||
# :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:
|
|
@ -1,5 +0,0 @@
|
|||||||
module Sass::Plugin
|
|
||||||
class << self
|
|
||||||
attr_accessor :rails_controller
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
module Compass::SassExtensions::Functions::Urls::ImageUrl
|
|
||||||
def image_url_with_rails_integration(path, only_path = Sass::Script::Bool.new(false), cache_buster = Sass::Script::Bool.new(true))
|
|
||||||
if (@controller = Sass::Plugin.rails_controller) && @controller.respond_to?(:request) && @controller.request
|
|
||||||
begin
|
|
||||||
if only_path.to_bool
|
|
||||||
Sass::Script::String.new image_path(path.value)
|
|
||||||
else
|
|
||||||
Sass::Script::String.new "url(#{image_path(path.value)})"
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
@controller = nil
|
|
||||||
end
|
|
||||||
else
|
|
||||||
image_url_without_rails_integration(path, only_path, cache_buster)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
alias_method_chain :image_url, :rails_integration
|
|
||||||
end
|
|
@ -1,11 +0,0 @@
|
|||||||
# TODO figure something out so image_path works with rails integration
|
|
||||||
%w(railtie).each do |lib|
|
|
||||||
require "compass/app_integration/rails/actionpack30/#{lib}"
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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
|
|
@ -1,46 +0,0 @@
|
|||||||
require 'compass'
|
|
||||||
require 'rails'
|
|
||||||
|
|
||||||
class Rails::Railtie::Configuration
|
|
||||||
# Adds compass configuration accessor to the application configuration.
|
|
||||||
#
|
|
||||||
# If a configuration file for compass exists, it will be read in and
|
|
||||||
# the project's configuration values will already be set on the config
|
|
||||||
# object.
|
|
||||||
#
|
|
||||||
# For example:
|
|
||||||
#
|
|
||||||
# module MyApp
|
|
||||||
# class Application < Rails::Application
|
|
||||||
# config.compass.line_comments = !Rails.env.production?
|
|
||||||
# config.compass.fonts_dir = "app/assets/fonts"
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# It is suggested that you create a compass configuration file if you
|
|
||||||
# want a quicker boot time when using the compass command line tool.
|
|
||||||
#
|
|
||||||
# For more information on available configuration options see:
|
|
||||||
# http://compass-style.org/help/tutorials/configuration-reference/
|
|
||||||
def compass
|
|
||||||
@compass ||= begin
|
|
||||||
data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
|
|
||||||
config_data
|
|
||||||
else
|
|
||||||
Compass::Configuration::Data.new("project")
|
|
||||||
end
|
|
||||||
data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
|
|
||||||
data
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Compass
|
|
||||||
class Railtie < Rails::Railtie
|
|
||||||
initializer "compass.initialize_rails" do |app|
|
|
||||||
# Configure compass for use within rails, and provide the project configuration
|
|
||||||
# that came via the rails boot process.
|
|
||||||
Compass::AppIntegration::Rails.initialize!(app.config.compass)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,5 +0,0 @@
|
|||||||
# TODO figure something out so image_path works with rails integration
|
|
||||||
%w(railtie helpers).each do |lib|
|
|
||||||
require "compass/app_integration/rails/actionpack31/#{lib}"
|
|
||||||
end
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
module Sass::Script::Functions
|
|
||||||
def generated_image_url(path, only_path = nil)
|
|
||||||
asset_url(path, Sass::Script::String.new("image"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
module Compass::RailsImageFunctionPatch
|
|
||||||
private
|
|
||||||
|
|
||||||
def image_path_for_size(image_file)
|
|
||||||
begin
|
|
||||||
file = ::Rails.application.assets.find_asset(image_file)
|
|
||||||
return file
|
|
||||||
rescue ::Sprockets::FileOutsidePaths
|
|
||||||
return super(image_file)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Sass::Script::Functions
|
|
||||||
include Compass::RailsImageFunctionPatch
|
|
||||||
end
|
|
||||||
|
|
||||||
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
|
|
||||||
class Sass::Script::Functions::EvaluationContext
|
|
||||||
include Sass::Script::Functions
|
|
||||||
end
|
|
@ -1,87 +0,0 @@
|
|||||||
require 'compass'
|
|
||||||
require 'rails'
|
|
||||||
|
|
||||||
class Rails::Railtie::Configuration
|
|
||||||
# Adds compass configuration accessor to the application configuration.
|
|
||||||
#
|
|
||||||
# If a configuration file for compass exists, it will be read in and
|
|
||||||
# the project's configuration values will already be set on the config
|
|
||||||
# object.
|
|
||||||
#
|
|
||||||
# For example:
|
|
||||||
#
|
|
||||||
# module MyApp
|
|
||||||
# class Application < Rails::Application
|
|
||||||
# config.compass.line_comments = !Rails.env.production?
|
|
||||||
# config.compass.fonts_dir = "app/assets/fonts"
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# It is suggested that you create a compass configuration file if you
|
|
||||||
# want a quicker boot time when using the compass command line tool.
|
|
||||||
#
|
|
||||||
# For more information on available configuration options see:
|
|
||||||
# http://compass-style.org/help/tutorials/configuration-reference/
|
|
||||||
def compass
|
|
||||||
@compass ||= begin
|
|
||||||
data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
|
|
||||||
config_data
|
|
||||||
else
|
|
||||||
Compass::Configuration::Data.new("rails_config")
|
|
||||||
end
|
|
||||||
data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
|
|
||||||
Compass.add_project_configuration(data)
|
|
||||||
Compass.configuration.on_sprite_saved do |filename|
|
|
||||||
# This is a huge hack based on reading through the sprockets internals.
|
|
||||||
# Sprockets needs an API for adding assets during precompilation.
|
|
||||||
# At a minimum sprockets should provide this API:
|
|
||||||
#
|
|
||||||
# #filename is a path in the asset source directory
|
|
||||||
# Rails.application.assets.new_asset!(filename)
|
|
||||||
#
|
|
||||||
# # logical_path is how devs refer to it, data is the contents of it.
|
|
||||||
# Rails.application.assets.new_asset!(logical_path, data)
|
|
||||||
#
|
|
||||||
# I would also like to select one of the above calls based on whether
|
|
||||||
# the user is precompiling or not:
|
|
||||||
#
|
|
||||||
# Rails.application.assets.precompiling? #=> true or false
|
|
||||||
#
|
|
||||||
# But even the above is not an ideal API. The issue is that compass sprites need to
|
|
||||||
# avoid generation if the sprite file is already generated (which can be quite time
|
|
||||||
# consuming). To do this, compass has it's own uniqueness hash based on the user's
|
|
||||||
# inputs instead of being based on the file contents. So if we could provide our own
|
|
||||||
# hash or some metadata that is opaque to sprockets that could be read from the
|
|
||||||
# asset's attributes, we could avoid cluttering the assets directory with generated
|
|
||||||
# sprites and always just use the logical_path + data version of the api.
|
|
||||||
if Rails.application.config.assets.digests.try(:any?)
|
|
||||||
asset = Rails.application.assets.find_asset(filename)
|
|
||||||
pathname = Pathname.new(filename)
|
|
||||||
logical_path = filename[(Compass.configuration.generated_images_path.length+1)..-1]
|
|
||||||
# Force the asset into the cache so find_asset will find it.
|
|
||||||
cached_assets = Rails.application.assets.instance_variable_get("@assets")
|
|
||||||
cached_assets[logical_path] = cached_assets[filename] = asset
|
|
||||||
|
|
||||||
target = Pathname.new(File.join(Rails.public_path, Rails.application.config.assets.prefix))
|
|
||||||
asset = Rails.application.assets.find_asset(logical_path)
|
|
||||||
filename = target.join(asset.digest_path)
|
|
||||||
asset.write_to(filename)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
data
|
|
||||||
end
|
|
||||||
@compass
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Compass
|
|
||||||
class Railtie < Rails::Railtie
|
|
||||||
initializer "compass.initialize_rails", :group => :all do |app|
|
|
||||||
# Configure compass for use within rails, and provide the project configuration
|
|
||||||
# that came via the rails boot process.
|
|
||||||
Compass::AppIntegration::Rails.check_for_double_boot!
|
|
||||||
Compass.discover_extensions!
|
|
||||||
Compass.configure_rails!(app)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,123 +0,0 @@
|
|||||||
module Compass
|
|
||||||
module AppIntegration
|
|
||||||
module Rails
|
|
||||||
|
|
||||||
module ConfigurationDefaultsWithAssetPipeline
|
|
||||||
# These methods overwrite the old rails defaults
|
|
||||||
# when rails 3.1 is detected.
|
|
||||||
|
|
||||||
def default_sass_dir
|
|
||||||
File.join("app", "assets", "stylesheets")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_images_dir
|
|
||||||
File.join("app", "assets", "images")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_fonts_dir
|
|
||||||
File.join("app", "assets", "fonts")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_javascripts_dir
|
|
||||||
File.join("app", "assets", "javascripts")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_path
|
|
||||||
::Rails.application.config.assets.prefix
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_images_path
|
|
||||||
"#{top_level.http_path}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_generated_images_path
|
|
||||||
"#{top_level.http_path}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_javascripts_path
|
|
||||||
"#{top_level.http_path}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_fonts_path
|
|
||||||
"#{top_level.http_path}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_stylesheets_path
|
|
||||||
"#{top_level.http_path}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module ConfigurationDefaults
|
|
||||||
|
|
||||||
def project_type_without_default
|
|
||||||
:rails
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_sass_dir
|
|
||||||
File.join("app", "stylesheets")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_css_dir
|
|
||||||
File.join("public", "stylesheets")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_images_dir
|
|
||||||
File.join("public", "images")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_fonts_dir
|
|
||||||
File.join("public", "fonts")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_javascripts_dir
|
|
||||||
File.join("public", "javascripts")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_images_path
|
|
||||||
# Relies on the fact that this will be loaded after the "normal"
|
|
||||||
# defaults, so that method_missing finds http_root_relative
|
|
||||||
http_root_relative "images"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_generated_images_path
|
|
||||||
# Relies on the fact that this will be loaded after the "normal"
|
|
||||||
# defaults, so that method_missing finds http_root_relative
|
|
||||||
http_root_relative "images"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_javascripts_path
|
|
||||||
http_root_relative "javascripts"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_fonts_path
|
|
||||||
http_root_relative "fonts"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_stylesheets_path
|
|
||||||
http_root_relative "stylesheets"
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_extensions_dir
|
|
||||||
File.join("vendor", "plugins", "compass_extensions")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_cache_dir
|
|
||||||
File.join("tmp", "sass-cache")
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_project_path
|
|
||||||
project_path = Compass::AppIntegration::Rails.root
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_http_path
|
|
||||||
"/" # XXX Where is/was this stored in the Rails config?
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_environment
|
|
||||||
Compass::AppIntegration::Rails.env
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,182 +0,0 @@
|
|||||||
module Compass
|
|
||||||
module Installers
|
|
||||||
class Base
|
|
||||||
end
|
|
||||||
class ManifestInstaller < Base
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module AppIntegration
|
|
||||||
module Rails
|
|
||||||
class Installer < Compass::Installers::ManifestInstaller
|
|
||||||
|
|
||||||
def completed_configuration
|
|
||||||
config = {}
|
|
||||||
config[:sass_dir] = prompt_sass_dir unless sass_dir_without_default
|
|
||||||
config[:css_dir] = prompt_css_dir unless css_dir_without_default
|
|
||||||
config unless config.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def write_configuration_files(config_file = nil)
|
|
||||||
config_file ||= targetize('config/compass.rb')
|
|
||||||
unless File.exists?(config_file)
|
|
||||||
directory File.dirname(config_file)
|
|
||||||
write_file config_file, config_contents
|
|
||||||
end
|
|
||||||
unless rails3?
|
|
||||||
directory File.dirname(targetize('config/initializers/compass.rb'))
|
|
||||||
write_file targetize('config/initializers/compass.rb'), initializer_contents
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def rails3?
|
|
||||||
File.exists?(targetize('config/application.rb'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def prepare
|
|
||||||
write_configuration_files
|
|
||||||
end
|
|
||||||
|
|
||||||
def gem_config_instructions
|
|
||||||
if rails3?
|
|
||||||
%Q{Add the following to your Gemfile:\n\n gem "compass", ">= #{Compass::VERSION}"}
|
|
||||||
else
|
|
||||||
%Q{Add the following to your environment.rb:\n\n config.gem "compass", :version => ">= #{Compass::VERSION}"}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def finalize(options = {})
|
|
||||||
if options[:create]
|
|
||||||
puts <<-NEXTSTEPS
|
|
||||||
|
|
||||||
Congratulations! Your rails project has been configured to use Compass.
|
|
||||||
Just a couple more things left to do.
|
|
||||||
|
|
||||||
#{gem_config_instructions}
|
|
||||||
|
|
||||||
Then, make sure you restart your server.
|
|
||||||
|
|
||||||
Sass will automatically compile your stylesheets during the next
|
|
||||||
page request and keep them up to date when they change.
|
|
||||||
NEXTSTEPS
|
|
||||||
end
|
|
||||||
unless options[:prepare]
|
|
||||||
if manifest.has_stylesheet?
|
|
||||||
puts "\nNow add these lines to the head of your layout(s):\n\n"
|
|
||||||
puts stylesheet_links
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def hamlize?
|
|
||||||
# XXX Is there a better way to detect haml in a particular rails project?
|
|
||||||
require 'haml'
|
|
||||||
true
|
|
||||||
rescue LoadError
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def install_location_for_html(to, options)
|
|
||||||
separate("public/#{pattern_name_as_dir}#{to}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def prompt_sass_dir
|
|
||||||
if rails3?
|
|
||||||
nil
|
|
||||||
else
|
|
||||||
recommended_location = separate('app/stylesheets')
|
|
||||||
default_location = separate('public/stylesheets/sass')
|
|
||||||
print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
|
|
||||||
instead of the Sass default location of #{default_location}.
|
|
||||||
Is this OK? (Y/n) }
|
|
||||||
answer = $stdin.gets.downcase[0]
|
|
||||||
answer == ?n ? default_location : recommended_location
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def prompt_css_dir
|
|
||||||
if rails3?
|
|
||||||
nil
|
|
||||||
else
|
|
||||||
recommended_location = separate("public/stylesheets/compiled")
|
|
||||||
default_location = separate("public/stylesheets")
|
|
||||||
puts
|
|
||||||
print %Q{Compass recommends that you keep your compiled css in #{recommended_location}/
|
|
||||||
instead the Sass default of #{default_location}/.
|
|
||||||
However, if you're exclusively using Sass, then #{default_location}/ is recommended.
|
|
||||||
Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
|
|
||||||
answer = $stdin.gets
|
|
||||||
answer = answer.downcase[0]
|
|
||||||
answer == ?n ? default_location : recommended_location
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def config_contents
|
|
||||||
project_path, Compass.configuration.project_path = Compass.configuration.project_path, nil
|
|
||||||
("# This configuration file works with both the Compass command line tool and within Rails.\n" +
|
|
||||||
Compass.configuration.serialize)
|
|
||||||
ensure
|
|
||||||
Compass.configuration.project_path = project_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def initializer_contents
|
|
||||||
%Q{require 'compass'
|
|
||||||
|require 'compass/app_integration/rails'
|
|
||||||
|Compass::AppIntegration::Rails.initialize!
|
|
||||||
|}.gsub(/^\s+\|/,'')
|
|
||||||
end
|
|
||||||
|
|
||||||
def stylesheet_prefix
|
|
||||||
if css_dir.length >= 19
|
|
||||||
"#{css_dir[19..-1]}/"
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def stylesheet_links
|
|
||||||
if hamlize?
|
|
||||||
haml_stylesheet_links
|
|
||||||
else
|
|
||||||
html_stylesheet_links
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def haml_stylesheet_links
|
|
||||||
html = "%head\n"
|
|
||||||
manifest.each_stylesheet do |stylesheet|
|
|
||||||
# Skip partials.
|
|
||||||
next if File.basename(stylesheet.from)[0..0] == "_"
|
|
||||||
ss_line = " = stylesheet_link_tag '#{stylesheet_prefix}#{stylesheet.to.sub(/\.s[ac]ss$/,'.css')}'"
|
|
||||||
if stylesheet.options[:media]
|
|
||||||
ss_line += ", :media => '#{stylesheet.options[:media]}'"
|
|
||||||
end
|
|
||||||
if stylesheet.options[:condition]
|
|
||||||
ss_line = " /[if #{stylesheet.options[:condition]}]\n " + ss_line
|
|
||||||
end
|
|
||||||
html << ss_line + "\n"
|
|
||||||
end
|
|
||||||
html
|
|
||||||
end
|
|
||||||
def html_stylesheet_links
|
|
||||||
html = "<head>\n"
|
|
||||||
manifest.each_stylesheet do |stylesheet|
|
|
||||||
# Skip partials.
|
|
||||||
next if File.basename(stylesheet.from)[0..0] == "_"
|
|
||||||
ss_line = "<%= stylesheet_link_tag '#{stylesheet_prefix}#{stylesheet.to.sub(/\.s[ac]ss$/,'.css')}'"
|
|
||||||
if stylesheet.options[:media]
|
|
||||||
ss_line += ", :media => '#{stylesheet.options[:media]}'"
|
|
||||||
end
|
|
||||||
ss_line += " %>"
|
|
||||||
if stylesheet.options[:condition]
|
|
||||||
ss_line = "<!--[if #{stylesheet.options[:condition]}]>" + ss_line + "<![endif]-->"
|
|
||||||
end
|
|
||||||
html << " #{ss_line}\n"
|
|
||||||
end
|
|
||||||
html << "</head>"
|
|
||||||
html
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,17 +0,0 @@
|
|||||||
unless defined?(Compass::RAILS_LOADED)
|
|
||||||
Compass::RAILS_LOADED = true
|
|
||||||
begin
|
|
||||||
require 'action_pack/version'
|
|
||||||
if ActionPack::VERSION::MAJOR >= 3
|
|
||||||
if ActionPack::VERSION::MINOR < 1
|
|
||||||
require 'compass/app_integration/rails/actionpack30'
|
|
||||||
else
|
|
||||||
require 'compass/app_integration/rails/actionpack31'
|
|
||||||
end
|
|
||||||
else
|
|
||||||
require 'compass/app_integration/rails/actionpack2x'
|
|
||||||
end
|
|
||||||
rescue LoadError, NameError => e
|
|
||||||
$stderr.puts "Compass could not access the rails environment: #{e}"
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,78 +0,0 @@
|
|||||||
# =================================================================
|
|
||||||
# Compass Ruby on Rails Installer (template) v.1.0
|
|
||||||
# written by Derek Perez (derek@derekperez.com)
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
# NOTE: This installer is designed to work as a Rails template,
|
|
||||||
# and can only be used with Rails 2.3+.
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
# Copyright (c) 2009 Derek Perez
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person
|
|
||||||
# obtaining a copy of this software and associated documentation
|
|
||||||
# files (the "Software"), to deal in the Software without
|
|
||||||
# restriction, including without limitation the rights to use,
|
|
||||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the
|
|
||||||
# Software is furnished to do so, subject to the following
|
|
||||||
# conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be
|
|
||||||
# included in all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
# OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
# =================================================================
|
|
||||||
|
|
||||||
# Determine if we use sudo, defaults to true unless we are
|
|
||||||
# on win32, cygwin, or mingw32 or they ask us not to
|
|
||||||
def sudo_is_an_option?
|
|
||||||
return false if RUBY_PLATFORM =~ /(win|w)32$/ # true if win32, cygwin or mingw32
|
|
||||||
return false if ENV['NO_SUDO'] =~ /true/i
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "==================================================="
|
|
||||||
puts "Welcome to the Compass Installer for Ruby on Rails!"
|
|
||||||
puts "==================================================="
|
|
||||||
puts
|
|
||||||
|
|
||||||
# css framework prompt
|
|
||||||
css_framework = ask("What CSS Framework install do you want to use with Compass?")
|
|
||||||
|
|
||||||
# sass storage prompt
|
|
||||||
sass_dir = ask("Where would you like to keep your sass files within your project? (default: 'app/stylesheets')")
|
|
||||||
sass_dir = "app/stylesheets" if Compass::Util.blank?(sass_dir)
|
|
||||||
|
|
||||||
# compiled css storage prompt
|
|
||||||
css_dir = ask("Where would you like Compass to store your compiled css files? (default: 'public/stylesheets/compiled')")
|
|
||||||
css_dir = "public/stylesheets/compiled" if Compass::Util.blank?(css_dir)
|
|
||||||
|
|
||||||
# use sudo for gem commands?
|
|
||||||
use_sudo = nil
|
|
||||||
if sudo_is_an_option? # dont give them the option if they are on a system that can't use sudo (aka windows)
|
|
||||||
use_sudo = yes?("Use sudo for the gem commands? (the default for your system is #{sudo_is_an_option? ? 'yes' : 'no'})")
|
|
||||||
end
|
|
||||||
use_sudo = sudo_is_an_option? if Compass::Util.blank?(use_sudo)
|
|
||||||
|
|
||||||
# define dependencies
|
|
||||||
gem "haml", :version => ">=3.0.0"
|
|
||||||
gem "compass", :version => ">= 0.10.0"
|
|
||||||
|
|
||||||
# install and unpack
|
|
||||||
rake "gems:install GEM=haml --trace", :sudo => use_sudo
|
|
||||||
rake "gems:install GEM=compass --trace", :sudo => use_sudo
|
|
||||||
rake "gems:unpack GEM=compass --trace"
|
|
||||||
|
|
||||||
# build out compass command
|
|
||||||
compass_command = "compass init rails . --css-dir=#{css_dir} --sass-dir=#{sass_dir} "
|
|
||||||
compass_command << "--using #{css_framework} " unless Compass::Util.blank?(css_framework)
|
|
||||||
|
|
||||||
# integrate it!
|
|
||||||
run "haml --rails ."
|
|
||||||
run compass_command
|
|
Loading…
Reference in New Issue
Block a user