Package com.yahoo.platform.yui.compressor

Examples of com.yahoo.platform.yui.compressor.CssCompressor.compress()


            switch (engine) {
                case YUI:
                    log.debug("Using YUI Compressor engine.");

                    CssCompressor compressor = new CssCompressor(reader);
                    compressor.compress(writer, yuiConfig.getLineBreak());
                    break;
                default:
                    log.warn("CSS engine not supported.");
                    break;
            }
View Full Code Here


              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

    @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

            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

          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

                }

            } 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

      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());
  }

  @Override
  protected final void render(final HttpServletResponse resp,
View Full Code Here

    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

                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

                            .getBytes(charset)),
                            charset);
        Writer out = new OutputStreamWriter(baos, charset);
        CssCompressor compressor = new CssCompressor(in);
        in.close();
        compressor.compress(out, -1);
        out.flush();
        content = baos.toByteArray();
        out.close();
    }
   
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.