@chripo suggested a new feature that allows users to run a shell script/python function for each file in the assets. The original idea came from a gallery hook, that generates thumbnails on-the-fly without any interaction of the user. So, ideally you would define a (regex) pattern for your gallery images or whatever you like and before (or after) Acrylamid compiles. The pattern matches the asset and does something with it (in this example, running convert -resize ...).
convert -resize ...
The exact syntax of a hook is not yet discussed, but it should be easy to write something like *.jpg => mkthumbnails or /js/ => minify.sh.
*.jpg => mkthumbnails
/js/ => minify.sh
New ideas from a short brain storming:
two possible pattern variants: shell globbing or regular expressions. Shell globbing is very intuitive and looks pretty cool: shots/**/*.jpg to apply the hook on all jpegs inside shots/ folder, but neither python's glob nor python-glob2 can handle this for all common usage cases e.g. *(.jpg|.png). RE: ugly, but easy to implement, hence the initial version must be configured using regular expressions
'.+\.jpg': (mkthumb, lambda p: join([dirname(p), 'thumbs/', basename(p))])) as configuration syntax. The first function runs the actual compution, but before doing this, Acrylamid evaluates the path translation function (the latter) to check whether the computation is necessary at all.
'.+\.jpg': (mkthumb, lambda p: join([dirname(p), 'thumbs/', basename(p))]))
the path translation is optional, so the hook-configuration can be broken down to '.+\.html': html.minify.
not a high priority but: Acrylamid might detect a change in the function and can force a re-generation of the hooks. This is only possible when you define your function in separate module and import the function from there.
Merge branch 'hooks', part of #104
Merge branch 'feature/post-hook', closes #104
(see section Pre and Post Hooks in docs/hooks.rst)