Skip to content

Commit

Permalink
[Configuration] A more logical and consistent approach to http path l…
Browse files Browse the repository at this point in the history
…ocations.
  • Loading branch information
chriseppstein committed Jul 6, 2009
1 parent 956c437 commit 6555ab3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/compass/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Configuration
ATTRIBUTES = [
:project_type,
:project_path,
:http_path,
:css_dir,
:sass_dir,
:images_dir,
Expand All @@ -15,6 +16,8 @@ class Configuration
:environment,
:relative_assets,
:http_images_path,
:http_stylesheets_path,
:http_javascripts_path,
:additional_import_paths,
:sass_options
]
Expand Down Expand Up @@ -93,12 +96,12 @@ def default_images_dir
"images"
end

def default_http_images_path
"/#{images_dir}"
def default_http_path
"/"
end

def comment_for_http_images_path
"# To enable relative image paths using the images_url() function:\n# http_images_path = :relative\n"
def comment_for_http_path
"# Set this to the root of your project when deployed:\n"
end

def relative_assets?
Expand Down Expand Up @@ -140,6 +143,11 @@ def css_path
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)
# The @added_import_paths variable works around an issue where
# the additional_import_paths gets overwritten during parse
Expand Down
6 changes: 6 additions & 0 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def test_parse_and_serialize
# 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"
Expand Down Expand Up @@ -64,6 +66,7 @@ def test_serialization_fails_with_asset_cache_buster_set

def test_additional_import_paths
contents = <<-CONFIG
http_path = "/"
project_path = "/home/chris/my_compass_project"
css_dir = "css"
additional_import_paths = ["../foo"]
Expand All @@ -80,11 +83,14 @@ def test_additional_import_paths
expected_serialization = <<EXPECTED
# Require any additional compass plugins here.
project_path = "/home/chris/my_compass_project"
# 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"]
EXPECTED
assert_equal "/", Compass.configuration.http_path
assert_equal expected_serialization, Compass.configuration.serialize
end

Expand Down

0 comments on commit 6555ab3

Please sign in to comment.