Examples of CssCompressor


Examples of com.yahoo.platform.yui.compressor.CssCompressor

                  new FileInputStream(srcFile), "UTF-8");

              out = new OutputStreamWriter(new FileOutputStream(
                  copyToFile), "UTF-8");

              CssCompressor compressor = new CssCompressor(in);
              compressor.compress(out, -1);

              // zk modified here
            } finally {
              if (in != null) {
                in.close();
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

    }

    @Override
    public String compress(String original) {
        try {
            CssCompressor compressor = new CssCompressor(new StringReader(original));
            StringWriter out = new StringWriter(original.length() / 2);
            compressor.compress(out, getLineBreakPosition());
            return out.toString();
        } catch (IOException iox) {
            throw new WicketRuntimeException("A problem occurred while compressing CSS resource: " + iox.getMessage(), iox);
        }
    }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

            if ("js".equals(type)) {
                JavaScriptCompressor jsc = new JavaScriptCompressor(in, getLogBasedErrorReporter());
                jsc.compress(out, linebreak, munge, verbose, preserveAllSemiColons, disableOptimizations);
            } else if ("css".equals(type)) {
                CssCompressor cssc = new CssCompressor(in);
                cssc.compress(out, 100);
            }
            out.flush();
            minifiedBytes = baos.toByteArray();
        } catch (Exception e) { // Catch everything - on a runtime exception, we still want to return the unminified bytes
            LOG.warn("Could not minify resources, returned unminified bytes", e);
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

          JavaScriptCompressor compressor = new JavaScriptCompressor(in, reporter); in=null;  
          out = compressor.compress(linebreakpos, munge, ycVerbose,
              preserveAllSemiColons, disableOptimizations);         
                 
        } else if (".css".equals(ext) && yuiCompressCss) {              
          CssCompressor compressor = new CssCompressor(in); in=null// under the covers YUI just appends to a new SB
          out = compressor.compress(linebreakpos);          // their final product is just a string, just get that directly
        }
                if (out != null)
          fileHelper.writeFile(out.getBytes("UTF-8"), new File(outPath), false)// ensure final form not barf in browser by forcing utf8            

            } catch (EvaluatorException e) {   
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

                    throw new RuntimeException(errorReporter.getErrorMessage());
                }

            } else if("css".equals(extension)) {

                CssCompressor compressor = new CssCompressor(in);
                compressor.compress(out, 10);
            }
        } catch (Exception e) {
            //如果失败了,直接做个副本,防止加载js/css出错
            try {
                FileUtils.copyFile(new File(fileName), new File(minFileName));
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

  private static final String MIME_TYPE_CSS = "text/css; charset=utf-8";

  @Override
  protected final Response process(final HttpServletResponse resp,
      final StringReader jssr) throws IOException {
    CssCompressor css = new CssCompressor(jssr);
    StringWriter sw = new StringWriter();

    resp.setContentType(MIME_TYPE_CSS);
    css.compress(sw, WRAP_AT_COLUMN);
    return Response.of(true, sw.toString());
  }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

      e.printStackTrace();
    }
  }
 
  public static void minimizeCSS(String name) {
    CssCompressor compressor;

    try {
      compressor = new CssCompressor(new InputStreamReader(DefaultStyle.class.getResourceAsStream(name+".css")));
      FileOutputStream outstream = new FileOutputStream("C://temp/"+name+".min.css");
      OutputStreamWriter writer = new OutputStreamWriter(outstream,
          "UTF-8");
      compressor.compress(writer, -1);
      writer.flush();
      writer.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

                // fail gracefully on malformed javascript: send it without compressing
                normalOutput(inputStream);
                return;
            }
        } else if (this.key.endsWith(".css?minify")) {
            CssCompressor compressor = new CssCompressor(in);
            compressor.compress(outWriter, MINIFY_LINEBREAKPOS);
        } else {
            // or not if not right type
            normalOutput(inputStream);
            return;
        }
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

  }
 
  public static String compress(final String toCompress) {
    final StringWriter writer = new StringWriter((int) (toCompress.length() * 0.8));
    try {
      new CssCompressor(new StringReader(toCompress)).compress(writer, 0);
    } catch (final Exception e) {
      log.warn("Could not compress merged CSS stream, using uncompressed content", e);
      return toCompress;
    }
    return writer.toString();
View Full Code Here

Examples of com.yahoo.platform.yui.compressor.CssCompressor

  public static byte[] compress(final byte[] toCompress, Charset charset) {
    ByteArrayOutputStream out = new ByteArrayOutputStream(toCompress.length);
   
    final OutputStreamWriter writer = new OutputStreamWriter(out);
    try {
      new CssCompressor(new InputStreamReader(new ByteArrayInputStream(toCompress), charset)).compress(writer, 0);
      writer.flush();
      writer.close();
    } catch (final Exception e) {
      log.warn("Could not compress merged CSS stream, using uncompressed content", e);
      return toCompress;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.