[buildout]
extends = lxml.cfg
parts +=
    nginx
    nginx.conf
    example-theme
    ploneorg-theme
    rebuild-themes

[nginx]
recipe = zc.recipe.cmmi
url = http://html-xslt.googlecode.com/files/nginx-0.7.65-html-xslt-2.tar.gz
# The SSI bug was fixed in nginx-0.7.65-html-xslt-2.tar.gz
md5sum = f863bdfdbeb01c11677d856c78716b35
extra_options =
    --conf-path=${buildout:directory}/etc/nginx.conf
    --sbin-path=${buildout:directory}/bin
    --error-log-path=${buildout:directory}/var/log/nginx-error.log
    --http-log-path=${buildout:directory}/var/log/nginx-access.log
    --pid-path=${buildout:directory}/var/nginx.pid
    --lock-path=${buildout:directory}/var/nginx.lock
    --with-http_stub_status_module
    --with-http_xslt_module
    --with-libxml2=${buildout:directory}/parts/lxml/libxml2
    --with-libxslt=${buildout:directory}/parts/lxml/libxslt
#    --with-debug --with-cc-opt="-O0" # helps debugging with gdb

[nginx.conf]
recipe = collective.recipe.template
port = 8000
root = ${buildout:directory}/examples
filter.xsl = ${buildout:directory}/lib/xdv/filter.xsl
example.xsl = ${buildout:directory}/etc/example.xsl
ploneorg.xsl = ${buildout:directory}/etc/ploneorg.xsl
input = ${buildout:directory}/templates/nginx.conf.in
output = ${buildout:directory}/etc/nginx.conf

[example-theme]
recipe = plone.recipe.command
includemode = ssi
command = 
    ${buildout:directory}/bin/xdvcompiler \
        --includemode=${:includemode}  --output=${nginx.conf:example.xsl} \
        ${nginx.conf:root}/rules.xml ${nginx.conf:root}/theme.html
update-command = ${:command}

[ploneorg-theme]
recipe = plone.recipe.command
includemode = ssi
command = 
    ${buildout:directory}/bin/xdvcompiler \
        --includemode=${:includemode}  --output=${nginx.conf:ploneorg.xsl} \
        --extra=${nginx.conf:root}/ploneorg/default-extra.xsl \
        ${nginx.conf:root}/ploneorg/default.xml ${nginx.conf:root}/ploneorg/plone.html
update-command = ${:command}

[rebuild-themes]
recipe = collective.recipe.template
library-path = ${buildout:directory}/parts/lxml/libxml2/lib:${buildout:directory}/parts/lxml/libxslt/lib
inline =
    #!/bin/sh
    export LD_LIBRARY_PATH=${:library-path}
    export DYLD_LIBRARY_PATH=${:library-path}
    ${example-theme:command} && echo example theme rebuilt
    ${ploneorg-theme:command} && echo ploneorg theme rebuilt
    ${buildout:directory}/bin/nginx -s reload && echo nginx reloaded.
output = ${buildout:directory}/bin/rebuild-themes
mode = 755
