middleman/middleman-sprockets — pull request #66 by kt3k (2014-09-05 13:23:37+00:00)
Title: Fix a bug of in_trusted_source_directory?

Hi!

I believe I've found a bug in `Asset#in_trusted_source_directory?`.

The meaning of this method has changed in #61.
It used to mean:
```
source_directory.end_with?('images') || source_directory.end_with?('fonts')
```
but now it means:
```
File.basename(source_directory.to_s) == 'images' ||
File.basename(source_directory.to_s) == 'img' ||
source_path.dirname.basename.to_s == 'images' ||
source_path.dirname.basename.to_s == 'img' ||
File.basename(source_directory.to_s) == 'fonts' ||
source_path.dirname.basename.to_s == 'fonts'
```

Because of this, the latest version of middleman imports all of the images and fonts under the load_paths.
I think it isn't the intended behaviour and I'd like to suggest this change which restores the original behaviour of the method.

According to #59, the original intention of the method came from the handling of `export_all` flag in older versions of extension.rb.

It was like:
```
environment.paths.each do |load_path|
output_dir = nil
export_all = false
if load_path.end_with?('/images')
output_dir = @app.config[:images_dir]
export_all = true
elsif load_path.end_with?('/fonts')
output_dir = @app.config[:fonts_dir]
export_all = true
elsif load_path.end_with?('/stylesheets')
output_dir = @app.config[:css_dir]
elsif load_path.end_with?('/javascripts')
output_dir = @app.config[:js_dir]
end
...
```

It means that if load_path ends with `fonts` or `images`, the app imports all assets under it; in other words, the app "trusts" the load_path. Therefore this change should restore the original intention of the method.

Thanks,