middleman-simple-thumbnailer 1.0.2 → 1.4.0

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.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.devcontainer/Dockerfile +20 -0
  3. data/.devcontainer/devcontainer.json +35 -0
  4. data/.github/workflows/ci.yml +22 -0
  5. data/.gitignore +4 -0
  6. data/README.md +84 -12
  7. data/config/cucumber.yml +1 -0
  8. data/features/caching_thumbnails_in_development.feature +29 -1
  9. data/features/generate_image_thumbnails.feature +19 -5
  10. data/features/generate_image_thumbnails_image_path.feature +44 -0
  11. data/features/generate_image_thumbnails_relative_assets.feature +43 -0
  12. data/features/generate_new_data_file.feature +21 -0
  13. data/features/given_data_file.feature +30 -0
  14. data/features/support/image_thumbnails_steps.rb +89 -11
  15. data/fixtures/basic-app-data-file-generate/config.rb +1 -0
  16. data/fixtures/basic-app-data-file-generate/source/images/original.jpg +0 -0
  17. data/fixtures/basic-app-data-file-generate/source/page-with-images-to-resize.html.erb +10 -0
  18. data/fixtures/basic-app-data-file-generate/source/page-with-untouched-image.html.erb +9 -0
  19. data/fixtures/basic-app-data-file/config.rb +1 -0
  20. data/fixtures/basic-app-data-file/data/simple_thumbnailer.yml +5 -0
  21. data/fixtures/basic-app-data-file/source/images/original.jpg +0 -0
  22. data/fixtures/basic-app-data-file/source/page-with-images-to-resize.html.erb +10 -0
  23. data/fixtures/basic-app-data-file/source/page-with-untouched-image.html.erb +9 -0
  24. data/fixtures/basic-app-data-file/source/sitemap.html.erb +5 -0
  25. data/fixtures/basic-app-image-path-use-cache/config.rb +1 -0
  26. data/fixtures/basic-app-image-path-use-cache/source/images/original.jpg +0 -0
  27. data/fixtures/basic-app-image-path-use-cache/source/page-with-images-to-resize.html.erb +16 -0
  28. data/fixtures/basic-app-image-path-use-cache/source/page-with-untouched-image.html.erb +12 -0
  29. data/fixtures/basic-app-image-path/config.rb +1 -0
  30. data/fixtures/basic-app-image-path/source/images/original.jpg +0 -0
  31. data/fixtures/basic-app-image-path/source/page-with-images-to-resize.html.erb +16 -0
  32. data/fixtures/basic-app-image-path/source/page-with-untouched-image.html.erb +12 -0
  33. data/fixtures/basic-app-no-resize/config.rb +1 -0
  34. data/fixtures/basic-app-no-resize/source/images/original.jpg +0 -0
  35. data/fixtures/basic-app-no-resize/source/page-with-untouched-image.html.erb +9 -0
  36. data/fixtures/basic-app-relative-assets-use-cache/config.rb +2 -0
  37. data/fixtures/basic-app-relative-assets-use-cache/source/images/original.jpg +0 -0
  38. data/fixtures/basic-app-relative-assets-use-cache/source/page-with-images-to-resize.html.erb +16 -0
  39. data/fixtures/basic-app-relative-assets-use-cache/source/page-with-untouched-image.html.erb +9 -0
  40. data/fixtures/basic-app-relative-assets/config.rb +2 -0
  41. data/fixtures/basic-app-relative-assets/source/images/original.jpg +0 -0
  42. data/fixtures/basic-app-relative-assets/source/page-with-images-to-resize.html.erb +16 -0
  43. data/fixtures/basic-app-relative-assets/source/page-with-untouched-image.html.erb +9 -0
  44. data/fixtures/basic-app-use-cache/config.rb +1 -0
  45. data/fixtures/basic-app-use-cache/source/images/original.jpg +0 -0
  46. data/fixtures/basic-app-use-cache/source/page-with-images-to-resize.html.erb +10 -0
  47. data/fixtures/basic-app-use-cache/source/page-with-untouched-image.html.erb +9 -0
  48. data/fixtures/basic-app/source/page-with-images-to-resize.html.erb +2 -2
  49. data/fixtures/basic-app/source/page-with-untouched-image.html.erb +1 -1
  50. data/fixtures/cached-thumbnails-use-cache/config.rb +1 -0
  51. data/fixtures/cached-thumbnails-use-cache/source/images/original.jpg +0 -0
  52. data/fixtures/cached-thumbnails-use-cache/source/page-with-images-to-resize.html.erb +10 -0
  53. data/fixtures/custom-cache-dir-use-cache/config.rb +3 -0
  54. data/fixtures/custom-cache-dir-use-cache/source/images/original.jpg +0 -0
  55. data/fixtures/custom-cache-dir-use-cache/source/page-with-images-to-resize.html.erb +10 -0
  56. data/lib/middleman-simple-thumbnailer.rb +4 -1
  57. data/lib/middleman-simple-thumbnailer/extension.rb +143 -17
  58. data/lib/middleman-simple-thumbnailer/image.rb +46 -37
  59. data/lib/middleman-simple-thumbnailer/image_store.rb +42 -0
  60. data/lib/middleman-simple-thumbnailer/rack.rb +42 -0
  61. data/lib/middleman-simple-thumbnailer/resource.rb +19 -0
  62. data/lib/middleman-simple-thumbnailer/version.rb +1 -1
  63. data/middleman-simple-thumbnailer.gemspec +8 -6
  64. metadata +104 -45
  65. data/.travis.yml +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a8fcbef0d63780a552248c4a83a2450abdacb456
4
- data.tar.gz: 0dba15673827e0da8cbe89d9ee4f49dc844d29a6
2
+ SHA256:
3
+ metadata.gz: 7d26882da6c2c6bc7b27f6b2ea10a6d87190f2eb36d2f1365294860fd747966c
4
+ data.tar.gz: b1b99d9f8dd8955a040475de9554b2e610f91d6867969d1fb3ab00c3b95a3f28
5
5
  SHA512:
6
- metadata.gz: dcbfcc6a3f1373bb78c578c522a002fc265971d701dc9fc98efd7c40d9c8cc599be47a4fd05d3cb3463f105769a1134a901448f1c4fd0eec89a0af657bd76bf0
7
- data.tar.gz: cd5abd6b19674cbab8273324022711d3cda865f70e3cf3df484cfd8273a1a7b51cdeb20d706ce60429b1155111539a478cdeace265f30edb35825108c2e554f7
6
+ metadata.gz: 78184f4ad682582dec4b790c08829527013f5cc451ec5cc41de0644341c07da1a609f2ffd20c5dc54bc85945bdc44abe30b7167c9764ecbc1ce7c31d5a445d74
7
+ data.tar.gz: cf26509202cff72228f4c4babd5f48f67c5c40f93c17f8608e7f91af7ff970affc04b86019c7a5d8093cf31e182e0390bc7acde77f9b7f76270e813c809bf49e
@@ -0,0 +1,20 @@
1
+ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/ruby/.devcontainer/base.Dockerfile
2
+
3
+ # [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6, 2.5
4
+ ARG VARIANT="3"
5
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
6
+
7
+ # [Option] Install Node.js
8
+ ARG INSTALL_NODE="true"
9
+ ARG NODE_VERSION="lts/*"
10
+ RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11
+
12
+ # [Optional] Uncomment this section to install additional OS packages.
13
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
14
+ && apt-get -y install --no-install-recommends imagemagick
15
+
16
+ # [Optional] Uncomment this line to install additional gems.
17
+ # RUN gem install <your-gem-names-here>
18
+
19
+ # [Optional] Uncomment this line to install global node packages.
20
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,35 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "build": {
6
+ "dockerfile": "Dockerfile",
7
+ "args": {
8
+ // Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6, 2.5
9
+ "VARIANT": "2.7",
10
+ // Options
11
+ "INSTALL_NODE": "false",
12
+ "NODE_VERSION": "lts/*"
13
+ }
14
+ },
15
+
16
+ // Set *default* container specific settings.json values on container create.
17
+ "settings": {
18
+ "terminal.integrated.shell.linux": "/bin/bash"
19
+ },
20
+
21
+ // Add the IDs of extensions you want installed when the container is created.
22
+ "extensions": [
23
+ "rebornix.Ruby"
24
+ ],
25
+
26
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
27
+ // "forwardPorts": [],
28
+
29
+ // Use 'postCreateCommand' to run commands after the container is created.
30
+ "postCreateCommand": "sudo apt-get update && sudo apt-get install -y ripgrep && gem install bundler && bundle install",
31
+
32
+ // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
33
+ "remoteUser": "vscode"
34
+
35
+ }
@@ -0,0 +1,22 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ continue-on-error: ${{ matrix.experimental == true }}
9
+ name: ubuntu-ruby-${{ matrix.ruby-version }}
10
+ strategy:
11
+ matrix:
12
+ ruby-version: ['2.7']
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby-version }}
19
+ bundler-cache: true
20
+ - name: Runs tests
21
+ run: bundle exec cucumber
22
+
data/.gitignore CHANGED
@@ -4,3 +4,7 @@ Gemfile.lock
4
4
  pkg/*
5
5
  .rvmrc
6
6
  tmp
7
+ .ruby-version
8
+ .direnv
9
+ .envrc
10
+ .vscode
data/README.md CHANGED
@@ -4,17 +4,19 @@ Middleman Simple Thumbnailer [![Build Status](https://travis-ci.org/kubenstein/m
4
4
  Middleman Simple Thumbnailer is a [Middleman](http://middlemanapp.com/) extension that allows you to create image thumbnails by providing `resize_to` option to image_tag helper.
5
5
 
6
6
 
7
- Installation
8
- -------
7
+ ## Installation
8
+
9
9
  Put this line into your `Gemfile`:
10
10
  ```
11
11
  gem 'middleman-simple-thumbnailer'
12
12
  ```
13
13
 
14
- Usage
15
- -----
14
+ ## Usage
15
+
16
+ ### All mode
17
+
16
18
  Enable the extension in `config.rb`:
17
- ```
19
+ ```ruby
18
20
  activate :middleman_simple_thumbnailer
19
21
  ```
20
22
 
@@ -23,11 +25,81 @@ And modify your `image_tag`'s by adding `resize_to` parameter:
23
25
  = image_tag image, resize_to: '50x50', class: 'thumbnail'
24
26
  ```
25
27
 
26
- Build/Development modes
27
- -----
28
- During development thumbnails will be created on fly and presented as a base64 strings.
29
- During build thumbnails will be created as normal files and stored in same dir as their originals.
28
+ You can also use the `image_path` helper the same way in place where you need only the path of the resized image:
29
+ ```html
30
+ <picture>
31
+ <source srcset="<%= image_path 'original.jpg', resize_to: 1200 %>" media="(min-width: 900px)">
32
+ <%= image_tag "original.jpg", resize_to: "400%", class: 'the-image-class' %>
33
+ </picture>
34
+ ```
35
+
36
+ This extension use ImageMagick (via mini_magick) to resize the images.
37
+ The `resize_to` format is therefore the one defined ny ImageMagick. The documentation can be found [there](http://www.imagemagick.org/script/command-line-processing.php#geometry).
38
+
39
+ ### Dynamic mode
40
+
41
+ This mode is the default operating mode for this extension.
42
+ The images are generated according to their declaration in the helpers.
43
+ See the [known limitations](#known-limitation) paragraph below for known limitation in this mode.
44
+
45
+ ### Declarative mode
46
+
47
+ In this mode, the resized file are declared. They are then added to the sitemap and generated at the same time than the other files.
48
+
49
+ To activate this new mode, the option `:use_specs` must be used when activating the extension.
50
+
51
+ ```ruby
52
+ activate :middleman_simple_thumbnailer, use_specs: true
53
+ ```
54
+
55
+ Then the resizing specifications must be declared in a special [Middleman data file](https://middlemanapp.com/advanced/data-files/). By default the extension will look for `data/simple_thumbnailer.yaml`.
56
+
57
+ This file must contains a list of mappings with the following keys:
58
+ - `path`: the relative path of the image file in the `source\images` folder. This can be a glob pattern (https://ruby-doc.org/core/Dir.html#method-c-glob) (still relative to the `source\images` folder).
59
+ - `resize_to`: the [ImageMagix resize](http://www.imagemagick.org/script/command-line-processing.php#geometry) parameter
60
+
61
+ example (in yaml, file `data/simple_thumbnailer.yaml`):
62
+
63
+ ```yaml
64
+ ---
65
+ - path: original.jpg
66
+ resize_to: 10x10
67
+ - path: "*.jpg"
68
+ resize_to: 5x5
69
+ ```
70
+
71
+ The use of the `image_tag` and `image_path` helpers stay the same.
72
+
73
+ In this mode if a resizing specification found in an `image_tag` or `image_path` helper is not declared in the specification data file, a warning is emitted and the data file is rewritten to include the resizing specification. If the specification file doesn't exist, it is created (this behavior can be configured).
74
+
75
+
76
+ ### options
77
+
78
+ Option | default value | Description
79
+ ------------------------------|----------------------------------|-------------
80
+ :use\_cache\_dev | `true` | In development, add a Rack middleware to serve the resized image from cache
81
+ :cache\_dir | `'tmp/simple-thumbnailer-cache'` | Directory (relative to project root) for cached thumbnails.
82
+ :use\_specs | `false` | Wether or not use resize specfication data file
83
+ :specs\_data | `'simple_thumbnailer'` | name of the specification data file. It must follow the Middleman data file name convention.
84
+ :specs\_data\_default\_format | `'yaml'` | defaut specification format (and extension). Can be 'yml', 'yaml', 'json'
85
+ :specs\_data\_save\_old | `true` | save previous specification data file
86
+ :update\_specs | `true` | Warn about missing image files in the specification file and add them to it. The spécification file will be overwritten.
87
+
88
+
89
+ ## Known limitation
90
+
91
+ In the dynamic mode, this extension is unable to update the [sitemap](https://middlemanapp.com/advanced/sitemap/). Some extensions (like [middleman-s3_sync](https://github.com/fredjean/middleman-s3_sync)) uses the content of the sitemap to do their work. Therefore, the generated resized images will not be seen by such extensions, even if they are corectly generated.
92
+
93
+
94
+ ## Build/Development modes
95
+
96
+ During development:
97
+ - if option `use_cache_dev` is set to `true` thumbnails will be created when accessed, and are served with a rack middleware from the cache folder.
98
+ - Otherwise thumbnails will be created on fly and presented as a base64 strings.
99
+
100
+ During build thumbnails will be created as normal files and stored in same dir as their originals.
101
+
102
+
103
+ ## LICENSE
30
104
 
31
- LICENSE
32
- -----
33
- MIT
105
+ MIT
@@ -0,0 +1 @@
1
+ default: --publish-quiet
@@ -4,18 +4,46 @@ Feature: Caching thumbnails in development
4
4
  Given the Server is running at "basic-app"
5
5
  And there is no cache directory yet
6
6
  When I go to "/page-with-images-to-resize.html"
7
+ And I visit all images
7
8
  Then the cache directory should exist with the following files
8
9
  | images/original.10x10gt.eb4e78fd2554225b2.jpg |
9
- | images/original.5x5.eb4e78fd2554225b2.jpg |
10
+ | images/original.5x5.eb4e78fd2554225b2.jpg |
11
+
12
+ Scenario: Cached thumbnails are created use cache dev
13
+ Given the Server is running at "basic-app-use-cache"
14
+ And there is no cache directory yet
15
+ When I go to "/page-with-images-to-resize.html"
16
+ And I visit all images
17
+ Then the cache directory should exist with the following files
18
+ | images/original.10x10gt.eb4e78fd2554225b2.jpg |
19
+ | images/original.5x5.eb4e78fd2554225b2.jpg |
20
+
10
21
 
11
22
  Scenario: Cached thumbnails are used, if present
12
23
  Given the Server is running at "cached-thumbnails"
13
24
  When I go to "/page-with-images-to-resize.html"
14
25
  Then I should see base64ed data of the cached thumbnails
15
26
 
27
+ Scenario: Cached thumbnails are used, if present use cache dev
28
+ Given the Server is running at "cached-thumbnails-use-cache"
29
+ When I go to "/page-with-images-to-resize.html"
30
+ Then I should see urls for the following cached thumbnails:
31
+ | type | size | class | relative |
32
+ | img | 10x10 | 10x10 | false |
33
+ | img | 5x5 | 5x5 | false |
34
+
16
35
  Scenario: Manually setting the cache directory
17
36
  Given the Server is running at "custom-cache-dir"
18
37
  When I go to "/page-with-images-to-resize.html"
38
+ And I visit all images
39
+ Then the cache directory should exist at "tmp/xxx" with the following files
40
+ | images/original.10x10.eb4e78fd2554225b2.jpg |
41
+ | images/original.5x5.eb4e78fd2554225b2.jpg |
42
+
43
+ Scenario: Manually setting the cache directory use cache
44
+ Given the Server is running at "custom-cache-dir-use-cache"
45
+ When I go to "/page-with-images-to-resize.html"
46
+ And I visit all images
19
47
  Then the cache directory should exist at "tmp/xxx" with the following files
20
48
  | images/original.10x10.eb4e78fd2554225b2.jpg |
21
49
  | images/original.5x5.eb4e78fd2554225b2.jpg |
@@ -1,15 +1,23 @@
1
1
  Feature: Generate image thumbnails
2
-
2
+
3
3
  Scenario: Preserve default image_tag behaviour if no resize_to param is given
4
4
  Given the Server is running at "basic-app"
5
5
  When I go to "/page-with-untouched-image.html"
6
- Then I should see '<img src="/images/original.jpg" />'
6
+ Then I should see '<img src="/images/original.jpg" alt="Original" />'
7
7
 
8
8
  Scenario: Preserve default image_tag behaviour after build if no resize_to param was given
9
9
  Given a fixture app "basic-app"
10
10
  And a successfully built app at "basic-app"
11
11
  When I cd to "build"
12
- Then the file "page-with-untouched-image.html" should contain '<img src="/images/original.jpg" />'
12
+ Then the file "page-with-untouched-image.html" should contain '<img src="/images/original.jpg" alt="Original" />'
13
+
14
+ Scenario: Generate base64 thumbnail of image with resize_to param given use cache dev
15
+ Given the Server is running at "basic-app-use-cache"
16
+ When I go to "/page-with-images-to-resize.html"
17
+ Then I should see urls for the following cached thumbnails:
18
+ | type | size | class | relative | alt |
19
+ | img | 10x10> | 10x10 | false | Original.10x10gt |
20
+ | img | 5x5 | 5x5 | false | Original.5x5 |
13
21
 
14
22
  Scenario: Generate base64 thumbnail of image with resize_to param given
15
23
  Given the Server is running at "basic-app"
@@ -24,5 +32,11 @@ Feature: Generate image thumbnails
24
32
  | filename | dimensions |
25
33
  | images/original.10x10gt.jpg | 10x5 |
26
34
  | images/original.5x5.jpg | 5x2 |
27
- And the file "page-with-images-to-resize.html" should contain '<img class="image-resized-to10x10" src="/images/original.10x10gt.jpg" />'
28
- And the file "page-with-images-to-resize.html" should contain '<img class="image-resized-to5x5" src="/images/original.5x5.jpg" />'
35
+ And the file "page-with-images-to-resize.html" should contain '<img src="/images/original.10x10gt.jpg" class="image-resized-to10x10" alt="Original.10x10gt" />'
36
+ And the file "page-with-images-to-resize.html" should contain '<img src="/images/original.5x5.jpg" class="image-resized-to5x5" alt="Original.5x5" />'
37
+
38
+ Scenario: Not using resize_to should nt fail the build
39
+ Given a fixture app "basic-app-no-resize"
40
+ And a successfully built app at "basic-app-no-resize"
41
+ When I cd to "build"
42
+ Then the file "page-with-untouched-image.html" should contain '<img src="/images/original.jpg" alt="Original" />'
@@ -0,0 +1,44 @@
1
+ Feature: Generate image thumbnails with image path
2
+
3
+ Scenario: Preserve default image_path behaviour if no resize_to param is given
4
+ Given the Server is running at "basic-app-image-path"
5
+ When I go to "/page-with-untouched-image.html"
6
+ Then I should see '<img src="/images/original.jpg" alt="Original" />'
7
+ And I should see '<source srcset="/images/original.jpg" media="(min-width: 900px)">'
8
+
9
+ Scenario: Preserve default image_path behaviour after build if no resize_to param was given
10
+ Given a fixture app "basic-app-image-path"
11
+ And a successfully built app at "basic-app-image-path"
12
+ When I cd to "build"
13
+ Then the file "page-with-untouched-image.html" should contain '<img src="/images/original.jpg" alt="Original" />'
14
+ And the file "page-with-untouched-image.html" should contain '<source srcset="/images/original.jpg" media="(min-width: 900px)">'
15
+
16
+
17
+ Scenario: Generate url thumbnail of image with resize_to param given use cache dev
18
+ Given the Server is running at "basic-app-image-path-use-cache"
19
+ When I go to "/page-with-images-to-resize.html"
20
+ Then I should see urls for the following cached thumbnails:
21
+ | type | size | class | relative | alt |
22
+ | img | 10x10> | 10x10 | false | Original.10x10gt |
23
+ | img | 5x5 | 5x5 | false | Original.5x5 |
24
+
25
+ Scenario: Generate base64 thumbnail of image with resize_to param given
26
+ Given the Server is running at "basic-app-image-path"
27
+ When I go to "/page-with-images-to-resize.html"
28
+ Then I should see base64ed thumbnails and srcset of the images
29
+
30
+
31
+ Scenario: After build server resized images
32
+ Given a fixture app "basic-app-image-path"
33
+ And a successfully built app at "basic-app-image-path"
34
+ When I cd to "build"
35
+ Then the following images should exist:
36
+ | filename | dimensions |
37
+ | images/original.10x10gt.jpg | 10x5 |
38
+ | images/original.5x5.jpg | 5x2 |
39
+ | images/original.20x20.jpg | 20x9 |
40
+ | images/original.15x15.jpg | 15x7 |
41
+ And the file "page-with-images-to-resize.html" should contain '<img src="/images/original.10x10gt.jpg" class="image-resized-to10x10" alt="Original.10x10gt" />'
42
+ And the file "page-with-images-to-resize.html" should contain '<source srcset="/images/original.20x20.jpg" media="(min-width: 900px)">'
43
+ And the file "page-with-images-to-resize.html" should contain '<img src="/images/original.5x5.jpg" class="image-resized-to5x5" alt="Original.5x5" />'
44
+ And the file "page-with-images-to-resize.html" should contain '<source srcset="/images/original.15x15.jpg" media="(min-width: 900px)">'
@@ -0,0 +1,43 @@
1
+ Feature: Generate image thumbnails
2
+
3
+ Scenario: Preserve default image_tag behaviour if no resize_to param is given
4
+ Given the Server is running at "basic-app-relative-assets"
5
+ When I go to "/page-with-untouched-image.html"
6
+ Then I should see '<img src="images/original.jpg" alt="Original" />'
7
+
8
+ Scenario: Preserve default image_tag behaviour after build if no resize_to param was given
9
+ Given a fixture app "basic-app-relative-assets"
10
+ And a successfully built app at "basic-app-relative-assets"
11
+ When I cd to "build"
12
+ Then the file "page-with-untouched-image.html" should contain '<img src="images/original.jpg" alt="Original" />'
13
+
14
+
15
+ Scenario: Generate url thumbnail of image with resize_to param given
16
+ Given the Server is running at "basic-app-relative-assets-use-cache"
17
+ When I go to "/page-with-images-to-resize.html"
18
+ Then I should see urls for the following cached thumbnails:
19
+ | type | size | class | relative | alt |
20
+ | img | 10x10 | 10x10 | true | Original.10x10gt |
21
+ | img | 5x5 | 5x5 | true | Original.5x5 |
22
+ | srcset | 20x20> | | true | |
23
+ | srcset | 15x15> | | true | |
24
+
25
+ Scenario: Generate base64 thumbnail of image with resize_to param given
26
+ Given the Server is running at "basic-app-relative-assets"
27
+ When I go to "/page-with-images-to-resize.html"
28
+ Then I should see base64ed thumbnails of the images
29
+
30
+ Scenario: After build server resized images
31
+ Given a fixture app "basic-app-relative-assets"
32
+ And a successfully built app at "basic-app-relative-assets"
33
+ When I cd to "build"
34
+ Then the following images should exist:
35
+ | filename | dimensions |
36
+ | images/original.10x10.jpg | 10x5 |
37
+ | images/original.5x5.jpg | 5x2 |
38
+ | images/original.20x20gt.jpg | 20x9 |
39
+ | images/original.15x15gt.jpg | 15x7 |
40
+ And the file "page-with-images-to-resize.html" should contain '<img src="images/original.10x10.jpg" class="image-resized-to10x10" alt="Original.10x10gt" />'
41
+ And the file "page-with-images-to-resize.html" should contain '<source srcset="images/original.20x20gt.jpg" media="(min-width: 900px)">'
42
+ And the file "page-with-images-to-resize.html" should contain '<img src="images/original.5x5.jpg" class="image-resized-to5x5" alt="Original.5x5" />'
43
+ And the file "page-with-images-to-resize.html" should contain '<source srcset="images/original.15x15gt.jpg" media="(min-width: 900px)">'
@@ -0,0 +1,21 @@
1
+ Feature: Generate data file
2
+
3
+ Scenario: Check images
4
+ Given a fixture app "basic-app-data-file-generate"
5
+ And a successfully built app at "basic-app-data-file"
6
+ When I cd to "build"
7
+ Then the following images should exist:
8
+ | filename | dimensions |
9
+ | images/original.10x10gt.jpg | 10x5 |
10
+ | images/original.5x5.jpg | 5x2 |
11
+
12
+ Scenario: Check generated data file content
13
+ Given a fixture app "basic-app-data-file-generate"
14
+ And a successfully built app at "basic-app-data-file-generate"
15
+ When I cd to "data"
16
+ Then a file named "simple_thumbnailer.yaml" should exist
17
+ And file "simple_thumbnailer.yaml" should contain the following data:
18
+ | path | resize_to |
19
+ | original.jpg | 5x5 |
20
+ | original.jpg | 10x10> |
21
+
@@ -0,0 +1,30 @@
1
+ Feature: Use data file
2
+
3
+ Scenario: Check images from data file
4
+ Given a fixture app "basic-app-data-file"
5
+ And a successfully built app at "basic-app-data-file"
6
+ When I cd to "build"
7
+ Then the following images should exist:
8
+ | filename | dimensions |
9
+ | images/original.10x10.jpg | 10x5 |
10
+ | images/original.10x10gt.jpg | 10x5 |
11
+ | images/original.5x5.jpg | 5x2 |
12
+
13
+ Scenario: Check data file content
14
+ Given a fixture app "basic-app-data-file"
15
+ And a successfully built app at "basic-app-data-file"
16
+ When I cd to "data"
17
+ Then a file named "simple_thumbnailer.yml" should exist
18
+ And file "simple_thumbnailer.yml" should contain the following data:
19
+ | path | resize_to |
20
+ | original.jpg | 10x10 |
21
+ | *.jpg | 5x5 |
22
+ | original.jpg | 10x10> |
23
+
24
+ Scenario: Check sitemap file
25
+ Given a successfully built app at "basic-app-data-file"
26
+ When I cd to "build"
27
+ Then a file named "sitemap.html" should exist
28
+ And the file "sitemap.html" should contain '<li><a href="/images/original.10x10.jpg">/images/original.10x10.jpg</a></li>'
29
+ And the file "sitemap.html" should contain '<li><a href="/images/original.5x5.jpg">/images/original.5x5.jpg</a></li>'
30
+ And the file "sitemap.html" should not contain '<li><a href="/images/original.10x10gt.jpg">/images/original.10x10gt.jpg</a></li>'