/*
* YUI Compressor
* http://developer.yahoo.com/yui/compressor/
* Author: Julien Lecomte - http://www.julienlecomte.net/
* Author: Isaac Schlueter - http://foohack.com/
* Author: Stoyan Stefanov - http://phpied.com/
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
* The copyrights embodied in the content of this file are licensed
* by Yahoo! Inc. under the BSD (revised) open source license.
*/
package com.yahoo.platform.yui.compressor;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.ArrayList;
public class CssCompressor {
private StringBuffer srcsb = new StringBuffer();
public CssCompressor(Reader in) throws IOException {
// Read the stream...
int c;
while ((c = in.read()) != -1) {
srcsb.append((char) c);
}
}
// Leave data urls alone to increase parse performance.
protected String extractDataUrls(String css, ArrayList preservedTokens) {
int maxIndex = css.length() - 1;
int appendIndex = 0;
StringBuffer sb = new StringBuffer();
Pattern p = Pattern.compile("url\\(\\s*([\"']?)data\\:");
Matcher m = p.matcher(css);
/*
* Since we need to account for non-base64 data urls, we need to handle
* ' and ) being part of the data string. Hence switching to indexOf,
* to determine whether or not we have matching string terminators and
* handling sb appends directly, instead of using matcher.append* methods.
*/
while (m.find()) {
int startIndex = m.start() + 4; // "url(".length()
String terminator = m.group(1); // ', " or empty (not quoted)
if (terminator.length() == 0) {
terminator = ")";
}
boolean foundTerminator = false;
int endIndex = m.end() - 1;
while(foundTerminator == false && endIndex+1 <= maxIndex) {
endIndex = css.indexOf(terminator, endIndex+1);
if ((endIndex > 0) && (css.charAt(endIndex-1) != '\\')) {
foundTerminator = true;
if (!")".equals(terminator)) {
endIndex = css.indexOf(")", endIndex);
}
}
}
// Enough searching, start moving stuff over to the buffer
sb.append(css.substring(appendIndex, m.start()));
if (foundTerminator) {
String token = css.substring(startIndex, endIndex);
token = token.replaceAll("\\s+", "");
preservedTokens.add(token);
String preserver = "url(___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___)";
sb.append(preserver);
appendIndex = endIndex + 1;
} else {
// No end terminator found, re-add the whole match. Should we throw/warn here?
sb.append(css.substring(m.start(), m.end()));
appendIndex = m.end();
}
}
sb.append(css.substring(appendIndex));
return sb.toString();
}
public void compress(Writer out, int linebreakpos)
throws IOException {
Pattern p;
Matcher m;
String css = srcsb.toString();
int startIndex = 0;
int endIndex = 0;
int i = 0;
int max = 0;
ArrayList preservedTokens = new ArrayList(0);
ArrayList comments = new ArrayList(0);
String token;
int totallen = css.length();
String placeholder;
css = this.extractDataUrls(css, preservedTokens);
StringBuffer sb = new StringBuffer(css);
// collect all comment blocks...
while ((startIndex = sb.indexOf("/*", startIndex)) >= 0) {
endIndex = sb.indexOf("*/", startIndex + 2);
if (endIndex < 0) {
endIndex = totallen;
}
token = sb.substring(startIndex + 2, endIndex);
comments.add(token);
sb.replace(startIndex + 2, endIndex, "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + (comments.size() - 1) + "___");
startIndex += 2;
}
css = sb.toString();
// preserve strings so their content doesn't get accidentally minified
sb = new StringBuffer();
p = Pattern.compile("(\"([^\\\\\"]|\\\\.|\\\\)*\")|(\'([^\\\\\']|\\\\.|\\\\)*\')");
m = p.matcher(css);
while (m.find()) {
token = m.group();
char quote = token.charAt(0);
token = token.substring(1, token.length() - 1);
// maybe the string contains a comment-like substring?
// one, maybe more? put'em back then
if (token.indexOf("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_") >= 0) {
for (i = 0, max = comments.size(); i < max; i += 1) {
token = token.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", comments.get(i).toString());
}
}
// minify alpha opacity in filter strings
token = token.replaceAll("(?i)progid:DXImageTransform.Microsoft.Alpha\\(Opacity=", "alpha(opacity=");
preservedTokens.add(token);
String preserver = quote + "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___" + quote;
m.appendReplacement(sb, preserver);
}
m.appendTail(sb);
css = sb.toString();
// strings are safe, now wrestle the comments
for (i = 0, max = comments.size(); i < max; i += 1) {
token = comments.get(i).toString();
placeholder = "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___";
// ! in the first position of the comment means preserve
// so push to the preserved tokens while stripping the !
if (token.startsWith("!")) {
preservedTokens.add(token);
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
continue;
}
// \ in the last position looks like hack for Mac/IE5
// shorten that to /*\*/ and the next one to /**/
if (token.endsWith("\\")) {
preservedTokens.add("\\");
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
i = i + 1; // attn: advancing the loop
preservedTokens.add("");
css = css.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
continue;
}
// keep empty comments after child selectors (IE7 hack)
// e.g. html >/**/ body
if (token.length() == 0) {
startIndex = css.indexOf(placeholder);
if (startIndex > 2) {
if (css.charAt(startIndex - 3) == '>') {
preservedTokens.add("");
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
}
}
}
// in all other cases kill the comment
css = css.replace("/*" + placeholder + "*/", "");
}
// Normalize all whitespace strings to single spaces. Easier to work with that way.
css = css.replaceAll("\\s+", " ");
// Remove the spaces before the things that should not have spaces before them.
// But, be careful not to turn "p :link {...}" into "p:link{...}"
// Swap out any pseudo-class colons with the token, and then swap back.
sb = new StringBuffer();
p = Pattern.compile("(^|\\})(([^\\{:])+:)+([^\\{]*\\{)");
m = p.matcher(css);
while (m.find()) {
String s = m.group();
s = s.replaceAll(":", "___YUICSSMIN_PSEUDOCLASSCOLON___");
s = s.replaceAll( "\\\\", "\\\\\\\\" ).replaceAll( "\\$", "\\\\\
没有合适的资源?快使用搜索试试~ 我知道了~
基于PHP的昂酷拍卖系统.zip
共1210个文件
php:462个
html:156个
png:137个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 90 浏览量
2023-07-24
22:01:23
上传
评论
收藏 9.84MB ZIP 举报
温馨提示
基于PHP的昂酷拍卖系统.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP的昂酷拍卖系统.zip (1210个子文件)
authImage 1KB
php_xxtea.c 6KB
xxtea.c 2KB
jQuery.AsyncBox.v1.5.beta.chm 54KB
up-rewrite.conf 1KB
CREDITS 53B
ueditor.css 43KB
index.css 43KB
ueditor.min.css 33KB
user.css 28KB
video-js.css 21KB
list.css 15KB
common.css 13KB
cuitindex.css 12KB
install.css 12KB
base.css 11KB
video-js.min.css 11KB
jquery.datetimepicker.css 10KB
demos.css 8KB
common.css 7KB
shCoreDefault.css 7KB
brand.css 7KB
base.css 7KB
layout.css 5KB
video.css 4KB
scrawl.css 4KB
base.css 4KB
zcms.css 3KB
default.css 3KB
codemirror.css 3KB
uploadify.css 3KB
image.css 3KB
attachment.css 3KB
charts.css 3KB
picshow.css 3KB
emotion.css 2KB
dialogbase.css 2KB
music.css 2KB
tip-yellowsimple.css 2KB
tip-yellowsimple.css 2KB
tip-darkgray.css 2KB
tip-darkgray.css 2KB
tip-yellow.css 2KB
tip-yellow.css 2KB
tip-violet.css 2KB
tip-violet.css 2KB
tip-twitter.css 2KB
tip-skyblue.css 1KB
tip-skyblue.css 1KB
tip-green.css 1KB
tip-green.css 1KB
edittable.css 1KB
background.css 1KB
template.css 1KB
jquery.Jcrop.css 690B
help.css 395B
layout.css 180B
iframe.css 42B
left.cur 3KB
right.cur 3KB
768.dhp 40KB
512.dhp 35KB
1024.dhp 32KB
1536.dhp 28KB
3072.dhp 28KB
2048.dhp 25KB
4096.dhp 25KB
96.dhp 20KB
128.dhp 18KB
160.dhp 14KB
192.dhp 12KB
256.dhp 10KB
php_xxtea.dsp 9KB
vjs.eot 3KB
UEditorSnapscreen.exe 508KB
wface.gif 49KB
icon.gif 43KB
jxface2.gif 40KB
yface.gif 28KB
bface.gif 27KB
icons.gif 20KB
tface.gif 19KB
fface.gif 18KB
pay_ico.gif 14KB
default_1.gif 12KB
allbut_a.gif 11KB
cface.gif 8KB
default_bg.gif 8KB
regift.gif 8KB
userPhoto.gif 7KB
loading.gif 7KB
sprite.gif 7KB
link_8.gif 5KB
phot.gif 5KB
logo.gif 5KB
login_logo.gif 4KB
menu-current.gif 4KB
default_2.gif 4KB
common_btn.gif 4KB
allbg_a.gif 4KB
共 1210 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
助力毕业
- 粉丝: 2177
- 资源: 5130
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C语言实现基于STM32F103RC的电子相册(原理图、PCB源文件、程序源码及制作).zip
- C语言实现基于stm32和mpu9250的usb hid键盘、鼠标、游戏控制器.zip
- SAP GUI for Windows 7.70 Patch16
- C语言实现基于物联网的户外环境检测装置(STM32、APP、WIFI).zip
- Models for ICM/MCM美赛常用模型.zip
- cef源码CEF全称Chromium Embedded Framework
- hbase分布式.rar
- vc 6.0简介.rar
- C语言实现智能家居专用-STM32 以太网开发板电路设计(开源带例程).zip
- 基于深度学习的分类.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功