atd-asset_bundler 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +12 -0
- data/app/controllers/asset_bundler/assets_controller.rb +13 -8
- data/app/controllers/assets/images_controller.rb +21 -0
- data/config/routes.rb +1 -0
- data/lib/asset_bundler/engine.rb +5 -0
- data/lib/asset_bundler/routing.rb +11 -0
- data/lib/asset_bundler/version.rb +1 -1
- metadata +5 -4
data/Rakefile
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
3
|
|
4
|
+
class Bundler::GemHelper
|
5
|
+
def install_gem
|
6
|
+
built_gem_path = build_gem
|
7
|
+
out, err, code = sh_with_code("sudo gem install #{built_gem_path} --no-rdoc --no-ri")
|
8
|
+
if err[/ERROR/]
|
9
|
+
Bundler.ui.error err
|
10
|
+
else
|
11
|
+
Bundler.ui.confirm "#{name} (#{version}) installed"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
4
16
|
Bundler::GemHelper.install_tasks
|
@@ -13,15 +13,12 @@ class AssetBundler::AssetsController < ActionController::Metal
|
|
13
13
|
# invalidate the browser cache with a cache-busting query string.
|
14
14
|
headers['Cache-Control'] = 'public'
|
15
15
|
headers['Expires'] = 1.year.from_now.httpdate
|
16
|
-
|
17
|
-
begin
|
18
|
-
render File.join(self.controller_path, self.expansion_for(params[:path]))
|
19
|
-
rescue ActionView::MissingTemplate
|
20
|
-
public_file = File.join(Rails.root, 'public', request.path)
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
begin
|
18
|
+
go_render(File.join(self.controller_path, self.expansion_for(params[:path])))
|
19
|
+
rescue
|
20
|
+
raise(ActionController::RoutingError,
|
21
|
+
"No route matches #{ request.path.inspect }")
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
@@ -47,4 +44,12 @@ class AssetBundler::AssetsController < ActionController::Metal
|
|
47
44
|
def expansion_for(path)
|
48
45
|
expansion?(path.to_s) ? expansions[path.to_sym] : path
|
49
46
|
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Renders text file
|
50
|
+
# Must be overwrited for binary data
|
51
|
+
#
|
52
|
+
def go_render(path)
|
53
|
+
render path
|
54
|
+
end
|
50
55
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Assets
|
2
|
+
class ImagesController < AssetBundler::AssetsController
|
3
|
+
include ActionController::Streaming
|
4
|
+
|
5
|
+
respond_to :png, :jpeg, :gif
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def go_render(path)
|
10
|
+
send_file find_template(path).identifier,
|
11
|
+
:type => formats.first,
|
12
|
+
:disposition => 'inline'
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def expansion?(path)
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/asset_bundler/engine.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
require 'asset_bundler'
|
2
2
|
|
3
3
|
class AssetBundler::Engine < ::Rails::Engine
|
4
|
+
initializer 'asset_bundler.mime_types' do
|
5
|
+
Mime::Type.register "image/jpeg", :jpeg, [ "image/pjpeg" ]
|
6
|
+
Mime::Type.register "image/gif", :gif
|
7
|
+
Mime::Type.register "image/png", :png, [ "image/x-png" ]
|
8
|
+
end
|
4
9
|
end
|
@@ -26,6 +26,17 @@ module ActionDispatch::Routing::Mapper::Assets
|
|
26
26
|
match "#{route}/*path.:format", :to => 'assets/stylesheets#go'
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Renders image assets whenever +paths+ are matched. Defaults to
|
32
|
+
# recognizing routes under '/images' if no +paths+ are given.
|
33
|
+
#
|
34
|
+
def images(*paths)
|
35
|
+
paths.push '/images' if paths.empty?
|
36
|
+
paths.each do |route|
|
37
|
+
match "#{route}/*path.:format", :to => 'assets/images#go'
|
38
|
+
end
|
39
|
+
end
|
29
40
|
end
|
30
41
|
|
31
42
|
class ActionDispatch::Routing::Mapper
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atd-asset_bundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stephen Touset
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-29 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- Gemfile
|
38
38
|
- Rakefile
|
39
39
|
- app/controllers/asset_bundler/assets_controller.rb
|
40
|
+
- app/controllers/assets/images_controller.rb
|
40
41
|
- app/controllers/assets/javascripts_controller.rb
|
41
42
|
- app/controllers/assets/stylesheets_controller.rb
|
42
43
|
- asset_bundler.gemspec
|