1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/core_extensions/compass.rb

99 lines
3.2 KiB
Ruby
Raw Normal View History

module Middleman::CoreExtensions::Compass
class << self
def registered(app)
2011-09-17 15:52:40 -04:00
# Where to look for fonts
app.set :fonts_dir, "fonts"
2011-11-08 18:05:06 -05:00
app.define_hook :after_compass_config
2011-09-17 15:52:40 -04:00
app.extend ClassMethods
require "compass"
# Susy grids
begin
require "susy"
rescue LoadError
end
app.after_configuration do
# Support a stand-alone compass config file
# Many options are overwritten by Middleman, but the config is a good
# place to add:
# * output_style
# * disable_warnings
# * sass_options
# * line_comments
# * sprite_engine
# * chunky_png_options
compass_config_file = File.join(app.root, "compass.config")
if File.exists?(compass_config_file)
::Compass.add_project_configuration(compass_config_file)
end
::Compass.configuration do |config|
2011-07-26 16:40:37 -04:00
config.project_path = app.root
config.environment = :development
config.cache_path = File.join(app.root, ".sass-cache")
2011-07-26 16:40:37 -04:00
views_root = File.basename(app.views)
config.sass_dir = File.join(views_root, app.css_dir)
config.css_dir = File.join(views_root, app.css_dir)
config.javascripts_dir = File.join(views_root, app.js_dir)
config.fonts_dir = File.join(views_root, app.fonts_dir)
config.images_dir = File.join(views_root, app.images_dir)
2011-07-26 16:29:41 -04:00
config.http_images_path = if app.respond_to? :http_images_path
app.http_images_path
else
File.join(app.http_prefix || "/", app.images_dir)
end
2011-07-26 16:29:41 -04:00
config.http_stylesheets_path = if app.respond_to? :http_css_path
app.http_css_path
else
File.join(app.http_prefix || "/", app.css_dir)
end
2011-07-26 16:29:41 -04:00
config.http_javascripts_path = if app.respond_to? :http_js_path
app.http_js_path
else
File.join(app.http_prefix || "/", app.js_dir)
end
2011-09-17 15:52:40 -04:00
config.http_fonts_path = if app.respond_to? :http_fonts_path
app.http_fonts_path
2011-07-26 16:29:41 -04:00
else
File.join(app.http_prefix || "/", app.fonts_dir)
end
config.asset_cache_buster :none
config.output_style = :nested
2011-10-19 19:21:46 -04:00
# config.add_import_path(config.sass_dir)
end
2011-07-13 14:41:59 -04:00
# Required for relative paths
configure :build do
::Compass.configuration do |config|
config.environment = :production
build_root = File.basename(self.build_dir)
config.css_dir = File.join(build_root, self.css_dir)
config.images_dir = File.join(build_root, self.images_dir)
2011-09-16 13:16:23 -04:00
config.fonts_dir = File.join(build_root, self.fonts_dir)
end
end
2011-11-08 18:05:06 -05:00
run_hook :after_compass_config, ::Compass.configuration
end
end
alias :included :registered
end
module ClassMethods
# Add a block/proc to be run after features have been setup
def compass_config(&block)
2011-11-08 18:05:06 -05:00
after_compass_config(&block)
end
end
end