This issue has been opened to gather the discussions about a new architecture for the extension.
When analysing the middleman extension workflow when writing code for the PR #12, it has appeared that middleman-simple-thumbnailer doesn't follow the expected extension workflow.
Middleman expects that extensions know the list of files they generate/manipulate before the build phase. In fact, Middleman expects that extensions update the sitemap in the "manipulate_resource_list" callback. This callback is called before the build, and the list of resource can not be modified afterwards.
But in its current implementation, middleman-simple-thumbnailer knows the list of file to generate after the build phase, since they are compiled when the template helper is called.
The issue #10 is an example of why this is a problem. The asset_hash extension works on the sitemap to create the files hashes. Therefore it will not work on files that are not "declared" in the sitemap, such as those created by middleman-simple-thumbnailer.
My suggestion for a correction is to introduce a data file listing the resized images.
This file could be written in advance by the user, or/and more conveniently updated/created in the image helper. middleman-simple-thumbnailer would now manipulate the site map and generate the files before the middleman build phase.
On each image resize the image helper would do the following action:
record the resized image in a temporary data file (to have the list of resized image)
as for today, call the "super" method
In the after_build callback, the content of the temporary data file is compared to the previous existing one. If it differs, the user is prompted to relaunch the build and the data file is updated with the new resized image list.
The main drawback of my suggestion, is that the user have to launch the build twice (and remember to do it) if the list of resized images is modified.
is there a way to get around this
if not, is there a way to automatically relaunch the build (from the extension)
This issue has been opened to gather the discussions about a new architecture for the extension.
When analysing the middleman extension workflow when writing code for the PR #12, it has appeared that middleman-simple-thumbnailer doesn't follow the expected extension workflow.
Middleman expects that extensions know the list of files they generate/manipulate before the build phase. In fact, Middleman expects that extensions update the sitemap in the "manipulate_resource_list" callback. This callback is called before the build, and the list of resource can not be modified afterwards.
But in its current implementation, middleman-simple-thumbnailer knows the list of file to generate after the build phase, since they are compiled when the template helper is called.
The issue #10 is an example of why this is a problem. The asset_hash extension works on the sitemap to create the files hashes. Therefore it will not work on files that are not "declared" in the sitemap, such as those created by middleman-simple-thumbnailer.
My suggestion for a correction is to introduce a data file listing the resized images. This file could be written in advance by the user, or/and more conveniently updated/created in the image helper. middleman-simple-thumbnailer would now manipulate the site map and generate the files before the middleman build phase. On each image resize the image helper would do the following action:
after_build
callback, the content of the temporary data file is compared to the previous existing one. If it differs, the user is prompted to relaunch the build and the data file is updated with the new resized image list.The main drawback of my suggestion, is that the user have to launch the build twice (and remember to do it) if the list of resized images is modified.
ym