-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The CssCompressor in tapestry-webresources is now based on the latest YUI commit cf0497e. To make the original code work it needed some error fixing: - Duplicate variable declaration of "oldCss" - Faulty non-escaped regex - zeros.css test failed I'm not 100% sure the CssCompressor behaves 100% as before, but it's a necessary trade-off so it can be improved further, as the original YUI project is dead. All the pre-existing tests from YUI are now run directly in Tapestry, and we can add our own tests easily. Furthermore, the code was cleaned up with pre-compiled Patterns, and no longer converting between Strings/Readers/Writers. Co-authored-by: Volker Lamp <vlamp@apache.org>
- Loading branch information
Showing
140 changed files
with
8,442 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
This product includes software developed by | ||
The Apache Software Foundation (http://www.apache.org/). | ||
|
||
This product includes source from the YUI Compressor library, available under a BSD License. | ||
This product includes source and test files from the YUI Compressor library, available under a BSD License. | ||
http://yui.github.io/yuicompressor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
501 changes: 291 additions & 210 deletions
501
...-webresources/src/main/java/org/apache/tapestry5/internal/webresources/CssCompressor.java
Large diffs are not rendered by default.
Oops, something went wrong.
119 changes: 111 additions & 8 deletions
119
tapestry-webresources/src/test/groovy/t5/webresources/tests/CssCompressorSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,132 @@ | ||
package t5.webresources.tests | ||
|
||
import geb.spock.GebReportingSpec | ||
|
||
import org.apache.tapestry5.internal.webresources.CssCompressor | ||
import org.apache.tapestry5.test.JettyRunner | ||
|
||
import spock.lang.Issue; | ||
import spock.lang.Shared | ||
import spock.lang.Specification; | ||
|
||
class CssCompressorSpec extends Specification { | ||
|
||
@Issue('TAP5-2524') | ||
def "minify CSS with keyframes "() { | ||
setup: | ||
given: | ||
def css = '''@keyframes anim { | ||
0% { opacity: 0; } | ||
100% { opacity: 1; } | ||
}''' | ||
StringWriter writer = new StringWriter() | ||
def expected = "@keyframes anim{0%{opacity:0}100%{opacity:1}}" | ||
|
||
when: | ||
def result = CssCompressor.compress(css) | ||
|
||
then: | ||
result == expected | ||
} | ||
|
||
@Issue('TAP5-2753') | ||
def "preserve space for calc operators"() { | ||
given: | ||
def is = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/tap5-2753.css") | ||
def t = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/tap5-2753.css.min").text | ||
def expected = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/tap5-2753.css.min").text.trim() | ||
|
||
when: | ||
def result = CssCompressor.compress(is) | ||
|
||
then: | ||
result == expected | ||
} | ||
|
||
def "bootstrap.css integry check"() { | ||
given: | ||
def is = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/bootstrap.css") | ||
def expected = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/bootstrap.css.min").text.trim() | ||
|
||
when: | ||
def result = CssCompressor.compress(is) | ||
|
||
then: | ||
result == expected | ||
} | ||
|
||
def "yui compressor test '#rawFile'"() { | ||
given: | ||
def is = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/yui/$rawFile") | ||
def expected = CssCompressorSpec.class.getResourceAsStream("/t5/webresources/css/yui/${rawFile}.min").text.trim() | ||
|
||
when: | ||
new CssCompressor(new StringReader(css)).compress(writer, -1) | ||
def result = CssCompressor.compress(is) | ||
|
||
then: | ||
writer.toString() == '''@keyframes anim{0%{opacity:0}100%{opacity:1}}''' | ||
result == expected | ||
|
||
where: | ||
rawFile << [ | ||
"background-position.css", | ||
"border-none.css", | ||
"box-model-hack.css", | ||
"bug2527974.css", | ||
"bug2527991.css", | ||
"bug2527998.css", | ||
"bug2528034.css", | ||
"bug-flex.css", | ||
"bug-nested-pseudoclass.css", | ||
"bug-preservetoken-calc.css", | ||
"charset-media.css", | ||
"color.css", | ||
"color-keyword.css", | ||
"color-simple.css", | ||
"comment.css", | ||
"concat-charset.css", | ||
"dataurl-base64-doublequotes.css", | ||
"dataurl-base64-eof.css", | ||
"dataurl-base64-linebreakindata.css", | ||
"dataurl-base64-noquotes.css", | ||
"dataurl-base64-singlequotes.css", | ||
"dataurl-base64-twourls.css", | ||
"dataurl-dbquote-font.css", | ||
"dataurl-nonbase64-doublequotes.css", | ||
"dataurl-nonbase64-noquotes.css", | ||
"dataurl-nonbase64-singlequotes.css", | ||
"dataurl-noquote-multiline-font.css", | ||
"dataurl-realdata-doublequotes.css", | ||
"dataurl-realdata-noquotes.css", | ||
"dataurl-realdata-singlequotes.css", | ||
"dataurl-realdata-yuiapp.css", | ||
"dataurl-singlequote-font.css", | ||
"decimals.css", | ||
"dollar-header.css", | ||
"font-face.css", | ||
// "hsla-issue81.css.FAIL", | ||
"ie5mac.css", | ||
"ie-backslash9-hack.css", | ||
"issue151.css", | ||
// "issue172.css.FAIL", | ||
"issue180.css", | ||
"issue205.css", | ||
"issue221.css", | ||
"issue222.css", | ||
"issue-59.css", | ||
"lowercasing.css", | ||
"media-empty-class.css", | ||
"media-multi.css", | ||
"media-test.css", | ||
"old-ie-filter-matrix.css", | ||
"opacity-filter.css", | ||
"opera-pixel-ratio.css", | ||
"pointzeros.css", | ||
"preserve-case.css", | ||
"preserve-important.css", | ||
"preserve-new-line.css", | ||
"preserve-strings.css", | ||
"pseudo.css", | ||
"pseudo-first.css", | ||
// "rgb-issue81.css.FAIL", | ||
"special-comments.css", | ||
"star-underscore-hacks.css", | ||
"string-in-comment.css", | ||
"webkit-transform.css", | ||
"zeros.css" | ||
] | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
tapestry-webresources/src/test/groovy/t5/webresources/tests/WebResourcesSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.