Added support for a fonts directory. This is where font files are kept

and should be accessible to the webserver. By default the fonts directory
is the "fonts" subdirectory of the css directory but another location
can be set via the fonts_dir and http_fonts_dir configuration options.
This commit is contained in:
Chris Eppstein 2009-11-27 17:10:48 -08:00
parent d2c314839d
commit 070f39c6b7
3 changed files with 45 additions and 20 deletions

View File

@ -1,26 +1,29 @@
module Compass
module Configuration
def self.attributes_for_directory(dir_name, http_dir_name = dir_name)
[
"#{dir_name}_dir",
"#{dir_name}_path",
("http_#{http_dir_name}_dir" if http_dir_name),
("http_#{http_dir_name}_path" if http_dir_name)
].compact.map{|a| a.to_sym}
end
ATTRIBUTES = [
# What kind of project?
:project_type,
# Where is the project?
:project_path,
:css_dir,
:sass_dir,
:images_dir,
:javascripts_dir,
:extensions_dir,
:css_path,
:sass_path,
:images_path,
:javascripts_path,
:extensions_path,
:http_path,
:http_images_dir,
:http_stylesheets_dir,
:http_javascripts_dir,
:http_images_path,
:http_stylesheets_path,
:http_javascripts_path,
# Where are the various bits of the project
attributes_for_directory(:css, :stylesheets),
attributes_for_directory(:sass, nil),
attributes_for_directory(:images),
attributes_for_directory(:javascripts),
attributes_for_directory(:fonts),
attributes_for_directory(:extensions, nil),
# Compilation options
:output_style,
:environment,
:relative_assets,
@ -28,7 +31,7 @@ module Compass
:sass_options,
:asset_host,
:asset_cache_buster
]
].flatten
end
end

View File

@ -14,6 +14,10 @@ module Compass
"extensions"
end
def default_fonts_dir
File.join(top_level.css_dir, "fonts")
end
def default_output_style
if top_level.environment == :development
:expanded
@ -56,6 +60,12 @@ module Compass
end
end
def default_fonts_path
if (pp = top_level.project_path) && (dir = top_level.fonts_dir)
File.join(pp, dir)
end
end
def default_http_images_dir
top_level.images_dir
@ -73,6 +83,18 @@ module Compass
http_root_relative top_level.http_stylesheets_dir
end
def default_http_fonts_dir
if fd = top_level.fonts_dir_without_default
fd
else
"#{top_level.http_stylesheets_dir}/fonts"
end
end
def default_http_fonts_path
http_root_relative top_level.http_fonts_dir
end
def default_http_javascripts_dir
top_level.javascripts_dir
end

View File

@ -15,12 +15,12 @@ class ConfigurationTest < Test::Unit::TestCase
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "js"
# Set this to the root of your project when deployed:
http_path = "/"
output_style = :nested
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
@ -87,9 +87,9 @@ class ConfigurationTest < Test::Unit::TestCase
expected_serialization = <<EXPECTED
# Require any additional compass plugins here.
project_path = "/home/chris/my_compass_project"
css_dir = "css"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
additional_import_paths = ["../foo", "/path/to/my/framework"]