PK eFbق build.xml
PK y.F{~ ~ build.sh#!/bin/bash
MODULE="press"
VERSION=`grep self conf/dependencies.yml | sed "s/.*$MODULE //"`
TARGET=/var/www/repo/play-$MODULE/$MODULE-$VERSION.zip
rm -fr dist
play dependencies --sync || exit $?
play build-module || exit $?
zip --delete dist/*.zip "lib/mockito*"
if [ -e $TARGET ]; then
echo "Not publishing, $MODULE-$VERSION already exists"
else
cp dist/*.zip $TARGET
fi
PK cmRDO O LICENSE(The MIT License)
Copyright (c) 2009-2012 Dirk McCormick
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
PK cmRDzjo5 5 commands.py# Here you can create play commands that are specific to the module, and extend existing commands
MODULE = 'press'
# Commands that are specific to your module
COMMANDS = ['press:hello']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "press:hello":
print "~ Hello"
# This will be executed before any command (new, run...)
def before(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
# This will be executed after any command (new, run...)
def after(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "new":
pass
PK bF2!1# # manifestversion=3.2
frameworkVersions=1.3+
PK cmRDE.V V build.properties# change the play.path to where your play framework is installed
play.path=../../playPK 6EF commands.pyc
bSc @ s. d Z d g Z d Z d Z d Z d S( t presss press:helloc K sT | j d } | j d } | j d } | j d } | d k rP d GHn d S( Nt commandt appt argst envs press:hellos ~ Hello( t get( t kargsR R R R ( ( s ../play-press/commands.pyt execute s c K s@ | j d } | j d } | j d } | j d } d S( NR R R R ( R ( R R R R R ( ( s ../play-press/commands.pyt before s c K sO | j d } | j d } | j d } | j d } | d k rK n d S( NR R R R t new( R ( R R R R R ( ( s ../play-press/commands.pyt after s N( t MODULEt COMMANDSR R R
( ( ( s ../play-press/commands.pyt s PK cmRD)bpi> i> ! documentation/manual/home.textileh1. press
The __press__ module is a JavaScript and CSS minimizer that is designed to be transparent to the application developer:
Simply replace **==<script>==** tags with **#{press.script}** tags, and **==<link rel="stylesheet">==** tags with **#{press.stylesheet}** tags.
Press now also supports Less CSS.
h2. Enable press
Run the following command to install the __press__ module in your copy of Play, and note the version of the module that is installed.
bc. play install press
Include the following line in your application’s **conf/application.conf** file to load the __press__ module. Be sure to use the appropriate version number:
bc. module.press=${play.path}/modules/press-1.0
By default, __press__ does not minimize JavaScript and CSS files when Play is in dev mode. Add the following line to **conf/application.conf** in order to see the compressed output in dev:
bc. press.enabled=true
Add the following line to **conf/routes** to import the __press__ routes. This simply makes the urls used by the __press__ module more uniform:
bc. * / module:press
h2. Use press to aggregate and compress files
h3. Replace **==<script>==** with **#{press.script}**
For example, your template includes the following JavaScript files:
bc.
You would change the template to look like this:
bc.
#{press.script 'header.login.js' /}
#{press.script 'main.js' /}
#{press.script src:'library.min.js', compress:false /}
#{press.compressed-script /}
The **#{press.compressed-script /}** tag outputs a **==<script>==** tag whose source is the compressed output of the other files.
Note:
* library.min.js is already minimized. We don't need to minimize it again so we add the parameter **compress:false**.
* Don't try to minimize files included from an external website :) (eg if you include jQuery from Google's CDN)
h3. Replace **==<link rel="stylesheet">==** with **#{press.stylesheet}**
For example, your template includes the following CSS files:
bc.
You would change the template to look like this:
bc. #{press.stylesheet 'header.login.css' /}
#{press.stylesheet 'main.css' /}
#{press.compressed-stylesheet /}
h3. Sample output
The above example will output something that looks like this:
bc.
All JavaScript files are compressed into a single JS file and all CSS files are compressed into a single CSS file. __press__ outputs HTML comments indicating the order in which each JavaScript/CSS file was added to compression
h2. Use press to compress files individually
Instead of compressing files in a group, you can instead compress files individually (without aggregating them). To compress files individually use the **#{press.single-script}** and **#{press.single-stylesheet}** tags.
bc. #{press.single-script 'widget.js' /}
#{press.single-stylesheet 'header.login.css' /}
#{press.single-stylesheet 'widget.css' /}
The above example will output something that looks like this:
bc.
h2. Wildcard matching
When managing a lot of CSS or JS files in a project, instead of manually maintaining a press tag in a template for each file, you can include all files from a specific path by wildcard:
bc. #{press.script '*.js' /}
#{press.script 'some/path/*.js' /}
Any files matching the given extension are included, in ascending alphabetical order. Note, however, that partial glob patterns such as "path/prefix-*.js" aren't currently supported. The search can be made recursive by adding another asterisk:
bc. #{press.script '**.js' /}
The above will include all .js files from under your JavaScripts path ("/public/javascripts" for example).
h2. Tips
* The source CSS and JS files **MUST** be UTF-8 encoded
* The source files will be output in compressed format in the same order as they appear in HTML when compression is disabled.
* It doesn't matter where the **#{press.compressed-script}** and **#{press.compressed-stylesheet}** tags are declared. Even if there are **#{press.script}** or **#{press.stylesheet}** tags after them in the template, they will still be included in compression.
* In dev mode, changes to the JS and CSS files are detected real time. Simply save and refresh the page. See "Caching":#caching for options related to caching and the defaults for each mode.
* If the same file is included twice an exception will be thrown.
* Don't use press from within a 404.html or 500.html template. When invoking an error template Play changes the request object causing press to fail.
h2. Server Caching
When a compressed file is generated for a given set of input files, it is stored on disk in a configurable location. The next time the same set of files in the same order is requested, the file is retrieved from the cache. This is server side caching.
__press__ has three different caching mechanisms, of which you can choose one.
* Caching strategy **Change**: __press__ will detect changes to the JS and CSS files in real time, simply save and refresh the page. This is the recommended caching strategy as it sets the appropriate headers for "Client Side Caching":#clientcaching.
* Caching strategy **Always**: __press__ will not auto-detect changes. The cache is cleared each time the server is restarted. With this strategy, client side caching is disabled.
* Caching strategy **Never**: __press__ will not use the cache. Compression will be performed for every page request. This mode obviously puts a high load on the server and is only recommended if one of the above strategies cannot be used for some reason. Also, client side caching is disabled.
h2. Client Side Caching
With the **Change** caching strategy, __press__ will generate the compressed file name from the last modified timestamp of each file added to compression. Cache control headers are sent when the file is served so that the browser will cache the file. If any of the component files changes the compressed file name will also change, and the browser will request the new file.
With the **Always** or **Never** caching strategies, the last modified timestamp is not part of the file name, and no cache-enabling header is sent.
h2. In-Memory storage
To improve performance, or to use __press__ on systems such as Google App Engine that do not support writes to the file system, __press__ can be configured to store all compressed files in memory using Play's standard caching mechanism, instead of on the file system. See "Configuration":#configuration below.
h2. Configuration
Many configuration options are different between dev and production. All of them can be overridden. For more information on how to override a Play configuration option for a particular environment, see "Managing application.conf in several environments":http://www.playframework.org/documentation/1.0.3/ids
h3. __press.enabled__
Whether or not __press__ is enabled.
**press.enabled=true**
Each **#{press.script}** and **#{press.stylesheet}** tag will output an HTML comment
The **#{press.compressed-script}** and **#{press.compressed-stylesheet}** tags will output a **==<script>==** or **==<link rel="stylesheet">==** tag with its src attribute pointing to the compressed source.
**press.enabled=false**
Each **#{press.script}** and **#{press.stylesheet}** tag will output a corresponding **==<script>==** or **==<link rel="stylesheet">==** tag with the original, uncompressed source.
The **#{press.compressed-script}** and **#{press.compressed-stylesheet}** tag will output nothing
By default, when play is in dev mode __press__ is disabled, and in production it is enabled
h3. __press.cache__
The caching strategy to use. See "Caching":#caching.
**press.cache=Change**
The compressed file will be regenerated when the last modified date of one of the source js or css files is detected to have changed. This mode is recommended as the appropriate cache control headers are sent, allowing the browser to cache the file.
**press.cache=Always**
The server cache will always be used, regardless of whether the component files have changed. The server cache will be cleared when the server is restarted. Client side caching is disabled.
**press.cache=Never**
The cache will not be used: the js and css files will be compressed on every request, and client side caching is disabled.
By default, the caching strategy is **Change**.
h3. __press.cache.clearEnabled__
Indicates whether the action to clear the cache from the web is enabled in production.
Press exposes an action to clear the compressed js and css cache at /press/clear
By default, when play is in dev mode the action is available and in production it is disabled.
**press.cache.clearEnabled=true**
h3. __press.inMemoryStorage__
Indicates whether to store compressed files in memory or in the file system. See "In-Memory Storage":#inmem.
By default files are stored on the file system
**press.inMemoryStorage=false**
h3. __press.p3pHeader__
The P3P header to output. eg
**press.p3pHeader=CP="IDC DSP CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT"**
If missing or empty, no P3P header is output.
By default the P3P header is not output.
**press.p3pHeader=**
h3. __press.outputRawLess__
By default, when __press__ is disabled, Less files will still be compiled to CSS. If this option is set to true, Less files will not be compiled, they will be output as raw Less.
**press.outputRawLess=false**
h3. __press.key.lifetime__
The amount of time to keep the compression key, in play Time duration format (see play.libs.Time.parseDuration)
When the **#{press.compressed-script}** or **#{press.compressed-stylesheet}** tag is output, a temporary key is generated and used as part of the file name. The browser then requests the file and the server responds with the compressed javascript. So the key must last as long as the time between when the browser receives the HTML and when it makes the request for the JS. The default is 2 minutes
**press.key.lifetime=2mn**
h3. __press.compression.maxTimeMillis__
The maximum amount of time in milli-seconds that compression is allowed to take before a timeout exception is thrown.
**press.compression.maxTimeMillis=60000**
h3. __press.js.sourceDir__
The source directory for javascript files, relative to the application root
**press.js.sourceDir=/public/javascripts/**
h3. __press.css.sourceDir__
The source directory for css files, relative to the application root
**press.css.sourceDir=/public/stylesheets/**
h3. __press.js.outputDir__
The output directory where compressed javascript files will be written to, relative to the application root. Note: This directory will be created if it doesn't exist.
**press.js.outputDir=/public/javascripts/press/**
h3. __press.css.outputDir__
The output directory where compressed css files will be written to, relative to the application root. Note: This directory will be created if it doesn't exist.
**press.css.outputDir=/public/stylesheets/press/**
h3. __press.htmlCompatible__
By default, the output produced by press is compatible with XHTML. This means that ==<link>== tags are closed. If __press.htmlCompatible__ is **true**, the output will be compatible with HTML, meaning that ==<link>== tags will not be closed.
**press.htmlCompatible=false**
h3. Options for the YUI compressor
See "http://developer.yahoo.com/yui/compressor":http://developer.yahoo.com/yui/compressor for details
**press.yui.css.lineBreak=-1**
**press.yui.js.lineBreak=-1**
**press.yui.js.munge=true**
**press.yui.js.warn=false**
**press.yui.js.preserveAllSemiColons=false**
**press.yui.js.preserveStringLiterals=false**
h2. How __press__ works
press uses "YUI Compressor":http://developer.yahoo.com/yui/compressor/ to perform JavaScript and CSS minimization.
Each **#{press.script}** tag is replaced with a corresponding HTML comment, eg ****. This is necessary in order to indicate the order in which the files are declared, required to generate the compressed output (explained below).
The **#{press.compressed-script}** tag is replaced with a **==<script>==** tag containing a key derived from the page URL, eg
bc.
When the page is ready to be sent to the browser, __press__ scans the output for comments of the form **** and creates a list of files that will be compressed, that is associated with the key.
When the browser makes a request for **/press/js/sNJSWMCDDFAekXYWryWgigJJ.js**, __press__ extracts the key from the file path and uses it to retrieve the list of files. If there is already a compressed file containing those files in that order in the cache, __press__ returns that file to the browser. Otherwise it generates the compressed file on the fly and saves it to the cache.
The process is the same for CSS files.
h2. Gotchas
Relative image urls will not work in a compressed CSS file because the location of the file that is output by press is not the same as the original file. Use absolute urls.
Some utilities (such as "Aloha text editor":http://aloha-editor.com) will attempt to build a path using the dynamically generated url paths (eg /press/js/sNJSWMCDDFAekXYWryWgigJJ.js). In order to get around this problem you can add the following at the bottom of your routes file, **after** including the press routes:
bc. GET /press/js/ staticDir:public/javascripts
GET /press/css/ staticDir:public/stylesheets
Don't use press from within a 404.html or 500.html template. When invoking an error template Play changes the request object causing press to fail.
h2. Thanks
The following people have contributed to the development of this plugin:
* John Pletka
* waxzce
* dabeeeenster
* orefalo
* nzakas
* Jarno Rantanen
* judu
* Juergen Stumpp
* Erik Bakker
* Geert-Jan
* Kang-Sze Lin
* sauravshah
* Pyry-Samuli Lahti
* benoit
* Oren Ellenbogen
* João Augusto Venancio da Silva
* javialeon
* Shane Berry
* Johan Vosloo
* caioaoque
* Quentin Morisseau
* tomparle
Thanks!
h2. Questions
If anything in the documentation is not clear, if you find a bug, or if you have questions, please open an issue on the github project for this plugin:
"https://github.com/dirkmc/press/issues":https://github.com/dirkmc/press/issues
PK bFo lib/play-press.jarPK
bF META-INF/ PK
bF^f META-INF/MANIFEST.MFM
0CFZjg@q3@KN)e$N6Vֺ?E4< 3
괬AWfu#7WFHc`߂ qZys9G Ea+EdJiPK
bF press/PK
bF press/io/PK
bF play.plugins340*(J-.)M PK
bFN1 press/CacheManager.classV[WU&Ip!@Z!R TRbEӂ!3ifBz>!t/?IH erΙ}>L~뇟 W^pы1͇+2.{qWݘqU7ysҰ 5/p#قтE,
|&[7eE/ӆ[^wPe)>ܒt͚`,Jpč4Оt6W\ej$RsjAUj"_`,Uu5
1 E QƵCU=͈ƍMFn5w7WYP,dznќgI1iY5/%dr BdHaf;J·*Xf!7aM)`&
[P|D#CAϓ1:'2֓2j^GɁ7i)VrS0ε1$cMAY*⬄&9mʹ"U+K&^;ś_]g)Kƺ
$iAݰ%fUKtVP
i˔I260d܆ ݼ2,Elɸ`%*wy4*V
>
#XBO_-f +Sឌ|{Kjƾ#:X