From 0f03b00bb31837b1451409ae6285c87c6bea43f7 Mon Sep 17 00:00:00 2001 From: karlbright Date: Mon, 28 Mar 2011 14:15:12 +0800 Subject: [PATCH 1/3] Removed downcase method from theme asset creation. Causes issues when dealing with files that may have uppercase filenames, such as fonts --- app/models/theme_asset.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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? From 30eed79f2b718494dcef56e0643253d9bc4ab07b Mon Sep 17 00:00:00 2001 From: karlbright Date: Mon, 28 Mar 2011 14:15:12 +0800 Subject: [PATCH 2/3] Removed downcase method from theme asset creation. Causes issues when dealing with files that may have uppercase filenames, such as fonts --- app/models/theme_asset.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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? From 57dff76d8e5e1ad5ab43cd0fd443ce9ea051ae24 Mon Sep 17 00:00:00 2001 From: karlbright Date: Mon, 11 Apr 2011 15:22:41 +0800 Subject: [PATCH 3/3] Added ability to set media attribute within stylesheet_tag --- lib/locomotive/liquid/filters/html.rb | 4 ++-- .../lib/locomotive/liquid/filters/html_spec.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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 d6da61f1..99f1ef03 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 = %{}