[Configuration] A more logical and consistent approach to http path locations.

This commit is contained in:
Chris Eppstein 2009-07-03 18:45:19 -07:00
parent 956c437fe9
commit 6555ab3952
2 changed files with 18 additions and 4 deletions

View File

@ -7,6 +7,7 @@ module Compass
ATTRIBUTES = [ ATTRIBUTES = [
:project_type, :project_type,
:project_path, :project_path,
:http_path,
:css_dir, :css_dir,
:sass_dir, :sass_dir,
:images_dir, :images_dir,
@ -15,6 +16,8 @@ module Compass
:environment, :environment,
:relative_assets, :relative_assets,
:http_images_path, :http_images_path,
:http_stylesheets_path,
:http_javascripts_path,
:additional_import_paths, :additional_import_paths,
:sass_options :sass_options
] ]
@ -93,12 +96,12 @@ module Compass
"images" "images"
end end
def default_http_images_path def default_http_path
"/#{images_dir}" "/"
end end
def comment_for_http_images_path def comment_for_http_path
"# To enable relative image paths using the images_url() function:\n# http_images_path = :relative\n" "# Set this to the root of your project when deployed:\n"
end end
def relative_assets? def relative_assets?
@ -140,6 +143,11 @@ module Compass
end end
end end
def mk_http_path(path)
hp = http_path[0..-2] if http_path[-1..-1] == "/"
"#{hp}/#{path}"
end
def add_import_path(*paths) def add_import_path(*paths)
# The @added_import_paths variable works around an issue where # The @added_import_paths variable works around an issue where
# the additional_import_paths gets overwritten during parse # the additional_import_paths gets overwritten during parse

View File

@ -13,6 +13,8 @@ class ConfigurationTest < Test::Unit::TestCase
# Require any additional compass plugins here. # Require any additional compass plugins here.
project_type = :stand_alone project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css" css_dir = "css"
sass_dir = "sass" sass_dir = "sass"
images_dir = "img" images_dir = "img"
@ -64,6 +66,7 @@ class ConfigurationTest < Test::Unit::TestCase
def test_additional_import_paths def test_additional_import_paths
contents = <<-CONFIG contents = <<-CONFIG
http_path = "/"
project_path = "/home/chris/my_compass_project" project_path = "/home/chris/my_compass_project"
css_dir = "css" css_dir = "css"
additional_import_paths = ["../foo"] additional_import_paths = ["../foo"]
@ -80,11 +83,14 @@ class ConfigurationTest < Test::Unit::TestCase
expected_serialization = <<EXPECTED expected_serialization = <<EXPECTED
# Require any additional compass plugins here. # Require any additional compass plugins here.
project_path = "/home/chris/my_compass_project" project_path = "/home/chris/my_compass_project"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css" css_dir = "css"
# To enable relative paths to assets via compass helper functions. Uncomment: # To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true # relative_assets = true
additional_import_paths = ["../foo", "/path/to/my/framework"] additional_import_paths = ["../foo", "/path/to/my/framework"]
EXPECTED EXPECTED
assert_equal "/", Compass.configuration.http_path
assert_equal expected_serialization, Compass.configuration.serialize assert_equal expected_serialization, Compass.configuration.serialize
end end