public
Description: A Rails plugin to make it easy to use YUI on Rails instead of (or along with, I suppose) Prototype and scriptaculous
Clone URL: git://github.com/rubaidh/yui_on_rails.git
Implement yui_stylesheet_path.

Returns the path to the stylesheet for a YUI CSS component, including the
minified version if requested and available.
mathie (author)
Tue Apr 15 06:48:06 -0700 2008
commit  f3e16ba8e84db0139b49e840875461b02a50e799
tree    4138b709c699e468cdb9cc935329a89fae65e8ce
parent  d333ca7a407b5548f30fedc903ed2139e5659d37
...
66
67
68
 
69
70
71
...
102
103
104
 
 
 
 
 
105
106
107
...
66
67
68
69
70
71
72
...
103
104
105
106
107
108
109
110
111
112
113
0
@@ -66,6 +66,7 @@ module ActionView # :nodoc:
0
         }
0
 
0
         CSS_COMPONENTS = [ "base", "fonts", "grids", "reset", "reset-fonts", "reset-fonts-grids"]
0
+ CSS_COMPONENTS_WITHOUT_MINIFIED_VERSION = [ "reset-fonts", "reset-fonts-grids"]
0
 
0
         def yui_javascript_path(source, version = nil)
0
           suffix = ""
0
@@ -102,6 +103,11 @@ module ActionView # :nodoc:
0
         def yui_js_dependencies_for_component(component)
0
           JS_COMPONENT_DEPENDENCIES[component] || []
0
         end
0
+
0
+ def yui_stylesheet_path(source, version = nil)
0
+ suffix = "-min" if "#{version}" == "min" && !CSS_COMPONENTS_WITHOUT_MINIFIED_VERSION.include?(source)
0
+ compute_public_path("#{source}#{suffix}", "yui/build/#{source}", 'css')
0
+ end
0
       end
0
     end
0
   end
...
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140
141
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
0
@@ -136,6 +136,28 @@ class AssetTagHelperTest < Test::Unit::TestCase
0
     assert_equal ["yahoo", "dom", "event", "animation", "container", "menu", "element", "button", "editor"], yui_js_components_with_dependencies(["dom", "animation", "editor"])
0
   end
0
 
0
+ def test_yui_stylesheet_path_generates_correct_paths
0
+ CSS_COMPONENTS.each do |component|
0
+ path = yui_stylesheet_path(component)
0
+ assert_equal "/yui/build/#{component}/#{component}.css", path
0
+ assert_file_exists "#{File.dirname(__FILE__)}/../../resources#{path}"
0
+ end
0
+ end
0
+
0
+ def test_yui_stylesheet_path_generates_correct_paths_for_minified_versions
0
+ (CSS_COMPONENTS - CSS_COMPONENTS_WITHOUT_MINIFIED_VERSION).each do |component|
0
+ path = yui_stylesheet_path(component, :min)
0
+ assert_equal "/yui/build/#{component}/#{component}-min.css", path
0
+ assert_file_exists "#{File.dirname(__FILE__)}/../../resources#{path}"
0
+ end
0
+
0
+ CSS_COMPONENTS_WITHOUT_MINIFIED_VERSION.each do |component|
0
+ path = yui_stylesheet_path(component, :min)
0
+ assert_equal "/yui/build/#{component}/#{component}.css", path
0
+ assert_file_exists "#{File.dirname(__FILE__)}/../../resources#{path}"
0
+ end
0
+ end
0
+
0
   private
0
   def assert_file_exists(file)
0
     assert File.exists?(file), "File #{file} does not exist."

Comments

    No one has commented yet.