middlemac-extras 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf5e2bfe3faed7c34abaf50486196b1c50cfe5f3
4
- data.tar.gz: b6c58fce72a4d5a18cf65810187e4c2177f5dd51
3
+ metadata.gz: 47aad4c22b21d4814184a9f3d0bfbbaa7a3c1d49
4
+ data.tar.gz: ed424b5d4b2ac535f57580cc31b9b7413b4b5b61
5
5
  SHA512:
6
- metadata.gz: 94a0b6fb575fbb78e1f29c4642d8013a6c6526860e7edccde7c29a2bbd9b5c35d321b96206be73c8797664b53a765bd0e33586fcac986e59f13cb05ad5a66404
7
- data.tar.gz: 4045e6ffb9335e8190839777343b3d2f8d8cbf300bb778d231932b4ee5dc12a4814ea45b8573191e6870eefd6a378c90c2da330bd5e322bdd63d6988e294b5ef
6
+ metadata.gz: d78a4a8951950f779079bacc9c9d78bc6335bd6d24777864a02dd68f21ea3d0619bcddc951f090d0aa0d0a73852067ecee71ba86d9d9cdabc46ad9ff2b38855e
7
+ data.tar.gz: 5edc65933dec1909430c1b3b089a32725fbd6282d2d08448e4a8fb662c5b1e8ff71f8bf0b0cd502fc22670718a081b78f3c7c3230fe6dfcd1074a6c50fc66473
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  middlemac-extras change log
2
2
  ===========================
3
3
 
4
+ - Version 1.0.5 / 2016-April-08
5
+
6
+ - Fixed the implementation of css_image_sizes so that full path is not
7
+ always used, as Middleman using `:relative_assets` doesn't use the full
8
+ path.
9
+
4
10
  - Version 1.0.0 / 2016-April-05
5
11
 
6
12
  - Initial Release
@@ -9,7 +9,7 @@ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw]
9
9
  gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
10
10
 
11
11
  # Middleman Gems
12
- gem 'middlemac-extras', '~> 1.0'
12
+ gem 'middlemac-extras', '~> 1.0.5'
13
13
  gem 'middleman', '~> 4.1.6'
14
14
  gem 'middleman-syntax'
15
15
 
@@ -58,7 +58,7 @@ helpers do
58
58
  end
59
59
 
60
60
  def product_version
61
- '1.0.0'
61
+ '1.0.5'
62
62
  end
63
63
 
64
64
  def product_uri
@@ -63,3 +63,37 @@ You will be tempted to add this helper to your `style.css.scss` file, maybe
63
63
  even renaming it to `style.css.scss.erb`, but this will not work due to the
64
64
  order that Middleman and SASS build output.
65
65
  {:.note}
66
+
67
+
68
+ ## Technical details
69
+
70
+ This CSS will control your image sizes by specifying a maximum width and height
71
+ for each image in the project using the `src` attribute selector and matching
72
+ against the end of that value. For example:
73
+
74
+ ~~~ scss
75
+ img[src$='icon.png'] { max-width: 256px; max-height: 256px; }
76
+ ~~~
77
+
78
+ CSS matches using literal text, and so will not respect relative paths. The
79
+ simple rule above has a high possibility of naming collisions with other files
80
+ named `icon.png`.
81
+
82
+ If you follow Middleman’s best practices and keep most or all of your images in
83
+ the defined `:images_dir` then the possibility of naming collisions will go
84
+ away, as this helper will deliver the `src` attribute selectors starting with
85
+ the final component of your `:images_dir`, for example:
86
+
87
+ ~~~ scss
88
+ img[src$='images/logo-small.png'] { max-width: 128px; max-height: 128px; }
89
+ img[src$='images/blog/logo-small.png'] { max-width: 160px; max-height: 160px; }
90
+ img[src$='icon_32x32.png'] { max-width: 32px; max-height: 32px; }
91
+ ~~~
92
+
93
+ In this example, the last image – `icon_32x32.png` – is not within `:images_dir`
94
+ and so has no directory and is subject to naming collisions.
95
+
96
+ The scheme above will work whether or not Middleman is configured with
97
+ `relative_assets` because both relative and absolute links will always contain
98
+ that last part of the path component. The only way this might break is by
99
+ serving HTML pages from within your `:images_dir`.
@@ -250,11 +250,21 @@ class MiddlemacExtras < ::Middleman::Extension
250
250
  if FastImage.size(file)
251
251
  width = (FastImage.size(file)[0] / factor).to_i.to_s
252
252
  height = (FastImage.size(file)[1] / factor).to_i.to_s
253
- @md_sizes_b << "img[src$='#{r.url}'] { max-width: #{width}px; max-height: #{height}px; }"
253
+ # CSS matches string literals and doesn't evaluate image paths.
254
+ # Assets in the image path with always bear the final path component
255
+ # in order to avoid collisions while working with relative_assets or
256
+ # not; items outside of the images_dir will use the basename only and
257
+ # be subject to collisions.
258
+ if r.url.start_with?("/#{app.config[:images_dir]}")
259
+ subtract = "/#{app.config[:images_dir].split('/')[0...-1].join('/')}/"
260
+ url = r.url.sub(subtract, '')
261
+ @md_sizes_b << "img[src$='#{url}'] { max-width: #{width}px; max-height: #{height}px; }"
262
+ else
263
+ @md_sizes_b << "img[src$='#{File.basename(r.url)}'] { max-width: #{width}px; max-height: #{height}px; }"
264
+ end
254
265
  end
255
266
  end # each
256
267
  end
257
-
258
268
  @md_sizes_b.join("\n")
259
269
  end
260
270
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module MiddlemacExtras
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middlemac-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Derry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core