lib/spiderfw/templates/resources/sass.rb in spiderfw-0.6.26.pre1 vs lib/spiderfw/templates/resources/sass.rb in spiderfw-0.6.26
- old
+ new
@@ -17,13 +17,32 @@
require 'sass'
module Spider
+
+ class SassAppImporter < Sass::Importers::Filesystem
+
+ def _find(dir, name, options)
+ Spider.apps_by_path.each do |app_name, mod|
+ if name.index(app_name) == 0 && File.directory?(File.join(dir, app_name))
+ rel_path = name[app_name.length+1..-1]
+ name = File.join(app_name, 'public', rel_path)
+ return super(dir, name, options)
+ end
+ end
+ return super
+ end
+
+ end
class SassCompiler
+ def self.options
+ @options ||= {:load_paths => []}
+ end
+
def initialize(base_path)
@base_path = base_path
end
def compile(src, dest)
@@ -41,10 +60,20 @@
work_dir = FileUtils.mkdir_p(File.join(Spider.paths[:tmp], 'sass'))
src_dir = File.dirname(src)
src_dir = src_dir
# dest_dir = File.dirname(dest)
+ sass_options = Compass.sass_engine_options.merge({
+ :cache_location => File.join(work_dir, '.sass_cache')
+ })
+ # Spider.apps.each do |name, app|
+ # sass_options[:load_paths] << Sass::Importers::Filesystem.new(app.pub_path)
+ # end
+ Spider.app_paths.each do |path|
+ sass_options[:load_paths] << SassAppImporter.new(path)
+ end
+
options = {
:project_path => @base_path,
:css_dir => 'css',
:sass_dir => 'sass',
# :fonts_path => src_dir,
@@ -52,14 +81,13 @@
:fonts_dir => 'fonts',
:images_dir => 'img',
:javascripts_dir => 'js',
:relative_assets => true,
:line_comments => Spider.runmode == 'devel' ? true : false,
- :sass => Compass.sass_engine_options.merge({
- :cache_location => File.join(work_dir, '.sass_cache')
- }),
+ :sass => sass_options,
:css_filename => dest
}
+
config = Compass::Configuration::Data.new(:spider, options)
Compass.add_project_configuration(config)
compiler = Compass::Compiler.new(work_dir, File.dirname(src), File.dirname(dest), options)
compiler.compile(src, dest) if compiler.out_of_date?
\ No newline at end of file