Merged pull request #60 from karlbright/master.

Theme asset filenames made lowercase
This commit is contained in:
Didier Lafforgue 2011-04-27 07:19:53 -07:00
commit c27062452e
3 changed files with 21 additions and 3 deletions

View File

@ -113,7 +113,7 @@ class ThemeAsset
self.folder = self.content_type.to_s.pluralize if self.folder.blank?
# no accents, no spaces, no leading and ending trails
self.folder = ActiveSupport::Inflector.transliterate(self.folder).gsub(/(\s)+/, '_').gsub(/^\//, '').gsub(/\/$/, '').downcase
self.folder = ActiveSupport::Inflector.transliterate(self.folder).gsub(/(\s)+/, '_').gsub(/^\//, '').gsub(/\/$/, '')
# folder should begin by a root folder
if (self.folder =~ /^(stylesheets|javascripts|images|medias|fonts)/).nil?

View File

@ -5,7 +5,7 @@ module Locomotive
# Write the link to a stylesheet resource
# input: url of the css file
def stylesheet_tag(input)
def stylesheet_tag(input,media='screen')
return '' if input.nil?
unless input =~ /^(\/|http:)/
@ -14,7 +14,7 @@ module Locomotive
input = "#{input}.css" unless input.ends_with?('.css')
%{<link href="#{input}" media="screen" rel="stylesheet" type="text/css" />}
%{<link href="#{input}" media="#{media}" rel="stylesheet" type="text/css" />}
end
# Write the link to javascript resource

View File

@ -26,6 +26,24 @@ describe Locomotive::Liquid::Filters::Html do
stylesheet_tag('/trash/main').should == result
end
it 'should return a link tag for a stylesheet file and media attribute set to print' do
result = "<link href=\"/sites/000000000000000000000042/theme/stylesheets/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('main.css','print').should == result
stylesheet_tag('main','print').should == result
stylesheet_tag(nil).should == ''
end
it 'should return a link tag for a stylesheet file with folder and media attribute set to print' do
result = "<link href=\"/sites/000000000000000000000042/theme/stylesheets/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('trash/main.css','print').should == result
end
it 'should return a link tag for a stylesheet file without touching the url and media attribute set to print' do
result = "<link href=\"/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('/trash/main.css','print').should == result
stylesheet_tag('/trash/main','print').should == result
end
it 'should return a script tag for a javascript file' do
result = %{<script src="/sites/000000000000000000000042/theme/javascripts/main.js" type="text/javascript"></script>}
javascript_tag('main.js').should == result