Introduction
Plugin to server static content with jetty servlet in develoment and production, optional you can configure with any other server in production
Install
grails install-plugin http://jettystatic.googlecode.com/files/grails-jettystatic-0.1.zip
Version 0.2 is compatible with grails 1.1+
grails install-plugin http://jettystatic.googlecode.com/files/grails-jettystatic-0.2.zip
Default Behavior
By default exposes the content in:
'project_dir'/static/resources"
Example:
shopProject/static/resources/text.txt
http://localhost:8080/shopProject/resources/test.txt
Taglib
Resource Tag generates the url to static resource
${resource(file:'text.txt')} -> http://localhost:8080/shopProject/resources/test.txtIf you are using 0.2 then you need to provide the namespace also so above line would be written as
${jettyStatic.resource(file:'text.txt')} -> http://localhost:8080/shopProject/resources/test.txtConfiguration
Overwrites the defaults dirs and the tag behavior
jettystatic.dir = Absolute path to server static content
jettystatic.basepath = The basepath to remove in a resource taglib
Example:
jettystatic {
dir = '/opt/mydir/files'
basepath = '/opt/mydir/files/resources'
}
${resource(file:'/opt/mydir/files/resources/text.txt')} -> http://localhost:8080/shopProject/resources/test.txtAlso you can ignore jetty servlet in production and server the content as you want with:
jettystatic.ignore=true
jettystatic.absolute.url=http://mystaticserver
${resource(file:'text.txt')} -> http://mystaticserver/test.txt
if using 0.2 version of plugin then the above line would be written as
${jettyStatic.resource(file:'text.txt')} -> http://mystaticserver/test.txt