Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
12 README.md
@@ -38,6 +38,8 @@ To minify javascripts in production do the following:
In your Gemfile:
gem 'jsmin'
+ # or
+ gem 'YUI'
In your app:
@@ -54,4 +56,14 @@ For more documentation about sprockets, please check [Sprockets](https://github.
:root => 'asset root' # default is app.root
:url => 'assets' # default map url, location, default is 'assets'
+# Contributors
+
+* @matthias-guenther
+* @swistak
+* @dommmel
+* @charlesvallieres
+* @jfcixmedia
+* @stefl
+* @mikesten
+
View
2  lib/padrino/sprockets-version.rb
@@ -1,5 +1,5 @@
module Padrino
module Sprockets
- VERSION = "0.0.1"
+ VERSION = "0.0.2"
end
end
View
43 lib/padrino/sprockets.rb
@@ -15,11 +15,6 @@ def evaluate(context, locals, &block)
module Padrino
module Sprockets
- class << self
- def registered(app)
- app.helpers Helpers
- end
- end
module Helpers
module ClassMethods
def sprockets(options={})
@@ -33,9 +28,7 @@ def sprockets(options={})
use Padrino::Sprockets::App, options
end
end
- def self.included(base)
- base.extend ClassMethods
- end
+
module AssetTagHelpers
# Change the folders to /assets/
def asset_folder_name(kind)
@@ -46,18 +39,31 @@ def asset_folder_name(kind)
end
end
end # AssetTagHelpers
+
+ def self.included(base)
+ base.send(:include, AssetTagHelpers)
+ base.extend ClassMethods
+ end
end #Helpers
+
class App
+ attr_reader :environment
+
def initialize(app, options={})
@app = app
@root = options[:root]
url = options[:url] || 'assets'
@matcher = /^\/#{url}\/*/
+ setup_environment(options[:minify], options[:paths] || [])
+ end
+
+ def setup_environment(minify=false, extra_paths=[])
@environment = ::Sprockets::Environment.new(@root)
@environment.append_path 'assets/javascripts'
@environment.append_path 'assets/stylesheets'
@environment.append_path 'assets/images'
- if options[:minify]
+
+ if minify
if defined?(YUI)
@environment.css_compressor = YUI::CssCompressor.new
else
@@ -69,14 +75,25 @@ def initialize(app, options={})
puts "Add jsmin to your Gemfile to enable minification"
end
end
- options[:paths].each do |sprocket_path|
+
+ extra_paths.each do |sprocket_path|
@environment.append_path sprocket_path
end
end
+
def call(env)
- return @app.call(env) unless @matcher =~ env["PATH_INFO"]
- env['PATH_INFO'].sub!(@matcher,'')
- @environment.call(env)
+ if @matcher =~ env["PATH_INFO"]
+ env['PATH_INFO'].sub!(@matcher,'')
+ @environment.call(env)
+ else
+ @app.call(env)
+ end
+ end
+ end
+
+ class << self
+ def registered(app)
+ app.helpers Padrino::Sprockets::Helpers
end
end
end #Sprockets

No commit comments for this range

Something went wrong with that request. Please try again.