com.yahoo.platform.yui.compressor.CssCompressor Java Examples
The following examples show how to use
com.yahoo.platform.yui.compressor.CssCompressor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TioCssCompressor.java From t-io with Apache License 2.0 | 5 votes |
@Override public String compress(String filePath, String srcCssContent) { try { CssCompressor cssCompressor = new CssCompressor(new StringReader(srcCssContent)); StringWriter sw = new StringWriter(); int linebreakpos = -1; cssCompressor.compress(sw, linebreakpos); String ret = sw.toString(); if (ret == null || ret.length() == 0) { log.warn("压缩后的文件大小为0, {}", filePath); return srcCssContent; } // byte[] initBytes = srcCssContent.getBytes(); // byte[] afterBytes = ret.getBytes(); // // if (afterBytes.length >= initBytes.length) { // log.warn("CSS压缩后的文件反而较大, init size:{}, after size:{}, file:{}", initBytes.length, afterBytes.length, filePath); // return srcCssContent; // } // return commits + ret; return ret; } catch (Exception e) { log.error(e.toString(), e); return srcCssContent; } }
Example #2
Source File: MinifyUtil.java From minifierbeans with Apache License 2.0 | 5 votes |
public void compressCssInternal(Reader in, Writer out, MinifyProperty minifyProperty) throws IOException { try { CssCompressor compressor = new CssCompressor(in); in.close(); in = null; compressor.compress(out, minifyProperty.getLineBreakPosition()); out.flush(); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } }
Example #3
Source File: YuiCssCompressor.java From htmlcompressor with Apache License 2.0 | 5 votes |
@Override public String compress(String source) { StringWriter result = new StringWriter(); try { CssCompressor compressor = new CssCompressor(new StringReader(source)); compressor.compress(result, lineBreak); } catch (IOException e) { result.write(source); e.printStackTrace(); } return result.toString(); }
Example #4
Source File: cfSTYLESHEET.java From openbd-core with GNU General Public License v3.0 | 5 votes |
private String minimiseCSS( String cssContents ) throws cfmRunTimeException { StringReader stringReader = new StringReader( cssContents ); try{ CssCompressor compressor = new CssCompressor( stringReader ); StringWriter out = new StringWriter(); compressor.compress(out, -1); return out.toString(); }catch(Exception e){ throw newRunTimeException( "CSS Minimizer: failed: " + e.getMessage() ); } }
Example #5
Source File: Compressor.java From GreasySpoon with GNU Affero General Public License v3.0 | 5 votes |
/** * CSS compression method, based on YUI Compressor * @param content uncompressed JavaScript * @return A compressed JavaScript */ public static String cleanupCSS(String content) { Reader reader = new StringReader(content); Writer writer = new StringWriter(); try { CssCompressor cssc = new CssCompressor(reader); cssc.compress(writer, -1); } catch (Exception e) { return content; } return writer.toString(); }