public abstract class AbstractLesscController extends AppController
Subclass will compile and serve CSS from LESS files. For more information on LESS, please see lesscss.org. Usually a developer would subclass this controller to trigger and compile in development environment, but the URI to CSS file would be ignored by the framework (configured in RouteConfig), so that a statically compiled version is served by a container or a web server.
This controller does not by itself compile LESS files. It shells out to a lessc
compiler, which
needs to be installed.
The controller will only compile LESS files if there have been any changes since the last invocation. If there has been no changes, it immediately serves the cached version of CSS compiled previously.
public class BootstrapController extends AbstractLesscController { protected File getLessFile() { return new File("src/main/webapp/less/bootstrap.less"); } } ... public class RouteConfig extends AbstractRouteConfig { public void init(AppContext appContext) { ignore("/bootstrap.css").exceptIn("development"); } }The line in the
RouteConfig
ensures that the URI /bootstrap.css
is ignored by the framework
in every environment except "development". This is why the controller is triggering in development environment only.HttpSupport.HttpBuilder, HttpSupport.RenderBuilder
Constructor and Description |
---|
AbstractLesscController() |
Modifier and Type | Method and Description |
---|---|
protected String[] |
getLesscArguments()
Subclass should override this method if they want to provide custom list of arguments to LessC compiler.
|
protected abstract File |
getLessFile()
Subclass should return a file handle pointing to the main Less file.
|
void |
index() |
actionSupportsHttpMethod, allowedActions, getContentType, getLayout, queryString, render, render, restful, restful, servletPath, standardActionSupportsHttpMethod
appContext, assign, blank, context, cookie, cookies, cookieValue, encoding, exists, flash, flash, flash, flash, format, getEncoding, getFile, getHttpServletRequest, getHttpServletResponse, getId, getLocale, getMap, getMap, getRealPath, getRequestBytes, getRequestHost, getRequestInputStream, getRequestPort, getRequestProtocol, getRequestStream, getRequestString, getResponseHeaders, getRoute, header, header, header, headers, host, ipAddress, ipForwardedFor, isDelete, isGet, isHead, isPost, isPut, isXhr, jsonList, jsonMap, jsonMaps, locale, locale, logDebug, logError, logError, logError, logInfo, logWarning, logWarning, merge, method, multipartFormItems, multipartFormItems, multipartFormItems, outputStream, outputStream, outputStream, param, param, params, params, params, params1st, params1st, path, port, protocol, redirect, redirect, redirect, redirect, redirect, redirect, redirect, redirect, redirectToReferrer, redirectToReferrer, remoteAddress, remoteHost, render, requestHas, respond, sanitize, sendCookie, sendCookie, sendFile, sendFile, sendPermanentCookie, session, session, session, sessionBoolean, sessionDouble, sessionFloat, sessionHas, sessionInteger, sessionLong, sessionObject, sessionString, setContentLength, setEncoding, setLocale, setRequestEncoding, setResponseEncoding, status, streamOut, uploadedFiles, uploadedFiles, uploadedFiles, uri, url, userAgent, values, view, view, view, writer, writer, xhr
public void index()
protected abstract File getLessFile()
protected String[] getLesscArguments()
Copyright © 2019 JavaLite. All rights reserved.