lionel 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +10 -0
- data/lib/lionel/extensions/middleman.rb +79 -0
- data/lib/lionel/lionel.rb +1 -0
- data/lib/lionel/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -12,6 +12,16 @@ And then execute:
|
|
12
12
|
|
13
13
|
$ bundle
|
14
14
|
|
15
|
+
### Installation - Middleman
|
16
|
+
|
17
|
+
If you want to serve/build assets from an engine, add this to your config.rb
|
18
|
+
|
19
|
+
activate :lionel do |l|
|
20
|
+
l.engines_with_images << "#{engine_name}"
|
21
|
+
end
|
22
|
+
|
23
|
+
(see the [demo app](https://github.com/gkop/lionel-middleman-demo/blob/master/config.rb) for example)
|
24
|
+
|
15
25
|
## Known Supported Engines
|
16
26
|
|
17
27
|
* [jquery-rails](https://rubygems.org/gems/jquery-rails)
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Lionel
|
2
|
+
module Extensions
|
3
|
+
module Middleman
|
4
|
+
class Options < Struct.new(:engines_with_images); end
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def registered(app, &block)
|
8
|
+
options = Options.new([])
|
9
|
+
yield options if block_given?
|
10
|
+
# Let's run our images/ through sprockets just as we do js and css,
|
11
|
+
# so we can serve images packaged in engines
|
12
|
+
|
13
|
+
# Inspired by https://github.com/Vasfed/middleman/commit/c9b4edcc0a3fb9fd4da43af78cedd50351479205
|
14
|
+
# This may be CRUFT if similar behavior is implemented by middleman
|
15
|
+
# itself
|
16
|
+
try_paths = [
|
17
|
+
%w{ assets },
|
18
|
+
%w{ app },
|
19
|
+
%w{ app assets },
|
20
|
+
%w{ vendor },
|
21
|
+
%w{ vendor assets },
|
22
|
+
%w{ lib },
|
23
|
+
%w{ lib assets }
|
24
|
+
].inject([]) do |sum, v|
|
25
|
+
sum + [File.join(v, 'images')]
|
26
|
+
end
|
27
|
+
|
28
|
+
app.after_configuration do
|
29
|
+
::Middleman.rubygems_latest_specs.select { |g|
|
30
|
+
options.engines_with_images.include?(g.name)
|
31
|
+
}.map(&:full_gem_path).each do |root_path|
|
32
|
+
try_paths.map {|p| File.join(root_path, p) }.
|
33
|
+
select {|p| File.directory?(p) }.
|
34
|
+
each {|path| sprockets.append_path(path) }
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add our app images to sprockets, too
|
38
|
+
sprockets.append_path("#{root}/#{source}/#{images_dir}")
|
39
|
+
|
40
|
+
# Intercept requests to /images and pass to sprockets
|
41
|
+
our_sprockets = sprockets
|
42
|
+
map("/#{images_dir}") { run our_sprockets }
|
43
|
+
end
|
44
|
+
|
45
|
+
app.build_config do
|
46
|
+
# Copy over engined images to build/images/
|
47
|
+
FileUtils.mkdir_p "#{root}/build/images"
|
48
|
+
::Middleman.rubygems_latest_specs.select { |g|
|
49
|
+
options.engines_with_images.include?(g.name)
|
50
|
+
}.map(&:full_gem_path).each do |root_path|
|
51
|
+
try_paths.map {|p| File.join(root_path, p) }.
|
52
|
+
select {|p| File.directory?(p) }.
|
53
|
+
each do |path|
|
54
|
+
FileUtils.cp_r Dir[path+"/*"], "#{root}/build/images"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# ugly hack around current_path being nil when executing path helpers
|
60
|
+
if defined? ::Middleman::Extensions::RelativeAssets
|
61
|
+
::Middleman::Extensions::RelativeAssets::InstanceMethods.module_eval do
|
62
|
+
alias_method :old_asset_url, :asset_url
|
63
|
+
|
64
|
+
def asset_url(path, prefix="")
|
65
|
+
old_asset_url(path, prefix)
|
66
|
+
rescue Exception => ex
|
67
|
+
"#{prefix}/#{path}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
alias :included :registered
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
::Middleman::Extensions.register(:lionel, Lionel::Extensions::Middleman)
|
data/lib/lionel/lionel.rb
CHANGED
data/lib/lionel/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lionel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nullobject
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- README.md
|
61
61
|
- Rakefile
|
62
62
|
- lib/lionel.rb
|
63
|
+
- lib/lionel/extensions/middleman.rb
|
63
64
|
- lib/lionel/lionel.rb
|
64
65
|
- lib/lionel/rails.rb
|
65
66
|
- lib/lionel/version.rb
|