7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/lionel/extensions/middleman.rb', line 7
def registered(app, &block)
options = Options.new([])
yield options if block_given?
try_paths = [
%w{ assets },
%w{ app },
%w{ app assets },
%w{ vendor },
%w{ vendor assets },
%w{ lib },
%w{ lib assets }
].inject([]) do |sum, v|
sum + [File.join(v, 'images')]
end
app.after_configuration do
::Middleman.rubygems_latest_specs.select { |g|
options.engines_with_images.include?(g.name)
}.map(&:full_gem_path).each do |root_path|
try_paths.map {|p| File.join(root_path, p) }.
select {|p| File.directory?(p) }.
each {|path| sprockets.append_path(path) }
end
sprockets.append_path("#{root}/#{source}/#{images_dir}")
our_sprockets = sprockets
map("/#{images_dir}") { run our_sprockets }
end
app.build_config do
FileUtils.mkdir_p "#{root}/build/images"
::Middleman.rubygems_latest_specs.select { |g|
options.engines_with_images.include?(g.name)
}.map(&:full_gem_path).each do |root_path|
try_paths.map {|p| File.join(root_path, p) }.
select {|p| File.directory?(p) }.
each do |path|
FileUtils.cp_r Dir[path+"/*"], "#{root}/build/images"
end
end
end
if defined? ::Middleman::Extensions::RelativeAssets
::Middleman::Extensions::RelativeAssets::InstanceMethods.module_eval do
alias_method :old_asset_url, :asset_url
def asset_url(path, prefix="")
old_asset_url(path, prefix)
rescue Exception => ex
"#{prefix}/#{path}"
end
end
end
end
|