Class: Middleman::Thumbnailer::SitemapExtension
- Inherits:
-
Object
- Object
- Middleman::Thumbnailer::SitemapExtension
- Defined in:
- lib/middleman-thumbnailer/extension.rb
Instance Method Summary collapse
-
#initialize(app) ⇒ SitemapExtension
constructor
A new instance of SitemapExtension.
-
#manipulate_resource_list(resources) ⇒ Object
Add sitemap resource for every image in the sprockets load path.
Constructor Details
#initialize(app) ⇒ SitemapExtension
Returns a new instance of SitemapExtension.
89 90 91 |
# File 'lib/middleman-thumbnailer/extension.rb', line 89 def initialize(app) @app = app end |
Instance Method Details
#manipulate_resource_list(resources) ⇒ Object
Add sitemap resource for every image in the sprockets load path
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/middleman-thumbnailer/extension.rb', line 94 def manipulate_resource_list(resources) images_dir_abs = File.join(@app.source_dir, @app.images_dir) images_dir = @app.images_dir = Thumbnailer. dimensions = [:dimensions] namespace = [:namespace_directory].join(',') files = DirGlob.glob(images_dir_abs, [:namespace_directory], [:filetypes]) resource_list = files.map do |file| path = file.gsub(@app.source_dir + File::SEPARATOR, '') specs = ThumbnailGenerator.specs(path, dimensions) specs.map do |name, spec| resource = nil resource = Middleman::Sitemap::Resource.new(@app.sitemap, spec[:name], File.join([:build_dir], spec[:name])) unless name == :original end end.flatten.reject {|resource| resource.nil? } resources + resource_list end |