Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 5 files changed
  • 0 comments
  • 3 contributors
4 lib/sinatra/sprockets.rb
@@ -16,8 +16,8 @@ def self.configure(&block)
16 16 end
17 17
18 18 if config.compress_assets?
19   - environment.js_compressor = Closure::Compiler.new
20   - environment.css_compressor = YUI::CssCompressor.new
  19 + environment.js_compressor = config.js_compressor || Closure::Compiler.new
  20 + environment.css_compressor = config.css_compressor || YUI::CssCompressor.new
21 21 else
22 22 environment.js_compressor = false
23 23 environment.css_compressor = false
4 lib/sinatra/sprockets/configuration.rb
@@ -11,7 +11,9 @@ class Configuration
11 11 :relative_url_root => ENV['RACK_RELATIVE_URL_ROOT'],
12 12 :precompile => [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ],
13 13 :manifest_path => "public/assets",
14   - :app => nil
  14 + :app => nil,
  15 + :js_compressor => nil,
  16 + :css_compressor => nil
15 17 }
16 18 OPTIONS = DEFAULTS.keys
17 19
12 lib/sinatra/sprockets/helpers.rb
@@ -38,7 +38,7 @@ def video_tag(sources, options = {})
38 38
39 39 if sources.is_a?(Array)
40 40 content_tag("video", options) do
41   - sources.map { |source| tag("source", :src => source) }.join.html_safe
  41 + sources.map { |source| tag("source", :src => source) }.join
42 42 end
43 43 else
44 44 options[:src] = asset_path(sources)
@@ -68,7 +68,7 @@ def javascript_include_tag(*sources)
68 68 src = asset_path(source, :ext => 'js', :body => body, :digest => digest)
69 69 content_tag("script", "", { "type" => "application/javascript", "src" => src }.merge!(options))
70 70 end
71   - end.join("\n").html_safe
  71 + end.join("\n")
72 72 end
73 73
74 74 def stylesheet_link_tag(*sources)
@@ -87,7 +87,7 @@ def stylesheet_link_tag(*sources)
87 87 href = asset_path(source, :ext => 'css', :body => body, :protocol => :request, :digest => digest)
88 88 tag("link", { "rel" => "stylesheet", "type" => "text/css", "media" => "screen", "href" => href }.merge!(options))
89 89 end
90   - end.join("\n").html_safe
  90 + end.join("\n")
91 91 end
92 92
93 93 def asset_path(source, options={})
@@ -97,7 +97,7 @@ def asset_path(source, options={})
97 97 end
98 98
99 99 def tag(name, options = nil, open = false, escape = true)
100   - "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
  100 + "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}"
101 101 end
102 102
103 103 def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
@@ -139,13 +139,13 @@ def tag_options(options, escape = true)
139 139 attrs << %(#{key}="#{final_value}")
140 140 end
141 141 end
142   - " #{attrs.sort * ' '}".html_safe unless attrs.empty?
  142 + " #{attrs.sort * ' '}" unless attrs.empty?
143 143 end
144 144 end
145 145
146 146 def content_tag_string(name, content, options, escape = true)
147 147 tag_options = tag_options(options, escape) if options
148   - "<#{name}#{tag_options}>#{escape ? ERB::Util.h(content) : content}</#{name}>".html_safe
  148 + "<#{name}#{tag_options}>#{escape ? ERB::Util.h(content) : content}</#{name}>"
149 149 end
150 150 end
151 151 end
6 lib/sinatra/sprockets/rake.rb
@@ -10,9 +10,9 @@
10 10 namespace :precompile do
11 11 task :all => ["environment"] do
12 12 config = Sinatra::Sprockets.config
13   - config.compile = true
14   - config.digest = true
15   - config.digests = {}
  13 + config.compile ||= true
  14 + config.digest ||= true
  15 + config.digests ||= {}
16 16
17 17 env = Sinatra::Sprockets.environment
18 18 target = File.join(config.app.settings.public_path, config.prefix)
4 sinatra-sprockets.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14 14
15 15 s.rubyforge_project = s.name
16 16
17   - s.add_runtime_dependency 'sprockets', '~> 2.0.0'
  17 + s.add_runtime_dependency 'sprockets', '~> 2.0'
18 18 s.add_runtime_dependency 'uglifier'
19 19 s.add_runtime_dependency 'closure-compiler'
20 20 s.add_runtime_dependency 'yui-compressor'
@@ -33,6 +33,6 @@ Gem::Specification.new do |s|
33 33 "lib/sinatra/sprockets/static_compiler.rb",
34 34 "lib/sinatra/sprockets/version.rb"
35 35 ]
36   -
  36 +
37 37 s.require_paths << "lib"
38 38 end

No commit comments for this range

Something went wrong with that request. Please try again.