public class LessFilter extends Filter
Filter
that automatically parses
LESS code and renders CSS using the
Less4j library. Also supports
minifying files, if the ".min.css" extension is used. See
CssUnifyMinifyFilter
.
This filter can track changes to the source files, updating the result file on-the-fly. This makes it easy to develop and debug a live site.
Note that this instances of this class can only guarantee atomic access to the rendered CSS file within the current VM.
Constructor and Description |
---|
LessFilter(Context context,
Restlet next,
File targetDirectory,
long minimumTimeBetweenValidityChecks)
Constructor using a 1-second
TimeoutedLessCompiler . |
LessFilter(Context context,
Restlet next,
File targetDirectory,
long minimumTimeBetweenValidityChecks,
com.github.sommeri.less4j.LessCompiler lessCompiler)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected int |
beforeHandle(Request request,
Response response) |
long |
getMinimumTimeBetweenValidityChecks()
A value of -1 disables all validity checking.
|
Set<File> |
getSourceDirectories()
The directories where the sources are found.
|
void |
setMinimumTimeBetweenValidityChecks(long minimumTimeBetweenValidityChecks) |
String |
toString() |
void |
translate(File lessFile,
File cssFile,
boolean minify)
Translate LESS to CSS, only if the LESS source is newer.
|
afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stop
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
public LessFilter(Context context, Restlet next, File targetDirectory, long minimumTimeBetweenValidityChecks)
TimeoutedLessCompiler
.context
- The contextnext
- The next restlettargetDirectory
- The directory into which CSS results should be writtenminimumTimeBetweenValidityChecks
- See getMinimumTimeBetweenValidityChecks()
public LessFilter(Context context, Restlet next, File targetDirectory, long minimumTimeBetweenValidityChecks, com.github.sommeri.less4j.LessCompiler lessCompiler)
context
- The contextnext
- The next restlettargetDirectory
- The directory into which CSS results should be writtenminimumTimeBetweenValidityChecks
- See getMinimumTimeBetweenValidityChecks()
lessCompiler
- The LESS compilerpublic Set<File> getSourceDirectories()
The set is thread-safe.
public long getMinimumTimeBetweenValidityChecks()
setMinimumTimeBetweenValidityChecks(long)
public void setMinimumTimeBetweenValidityChecks(long minimumTimeBetweenValidityChecks)
minimumTimeBetweenValidityChecks
- The minimum time between validity checks in millisecondsgetMinimumTimeBetweenValidityChecks()
public void translate(File lessFile, File cssFile, boolean minify) throws IOException
lessFile
- The LESS source filecssFile
- The CSS target file (will be overwritten)minify
- Whether to minify the CSSIOException
- In case of a reading, writing or translation errorCSSMin
protected int beforeHandle(Request request, Response response)
beforeHandle
in class Filter
Copyright © 2009-2016 Three Crickets LLC.