diff --git a/app/models/theme_asset.rb b/app/models/theme_asset.rb index dfa958f2..e78cad11 100644 --- a/app/models/theme_asset.rb +++ b/app/models/theme_asset.rb @@ -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? diff --git a/lib/locomotive/liquid/filters/html.rb b/lib/locomotive/liquid/filters/html.rb index 963cfd30..0f804f5c 100644 --- a/lib/locomotive/liquid/filters/html.rb +++ b/lib/locomotive/liquid/filters/html.rb @@ -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') - %{} + %{} end # Write the link to javascript resource diff --git a/spec/lib/locomotive/liquid/filters/html_spec.rb b/spec/lib/locomotive/liquid/filters/html_spec.rb index 81f63c1a..1d11f29b 100644 --- a/spec/lib/locomotive/liquid/filters/html_spec.rb +++ b/spec/lib/locomotive/liquid/filters/html_spec.rb @@ -25,6 +25,24 @@ describe Locomotive::Liquid::Filters::Html do stylesheet_tag('/trash/main.css').should == result 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 = "" + 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 = "" + 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 = "" + 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 = %{}