1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.web.sx; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.StringReader; |
24 |
|
import java.io.StringWriter; |
25 |
|
|
26 |
|
import org.slf4j.Logger; |
27 |
|
import org.slf4j.LoggerFactory; |
28 |
|
|
29 |
|
import com.yahoo.platform.yui.compressor.CssCompressor; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.5 |
|
37 |
|
public class CssExtension implements Extension |
38 |
|
{ |
39 |
|
|
40 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(CssExtension.class); |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
706 |
@Override... |
43 |
|
public String getClassName() |
44 |
|
{ |
45 |
706 |
return "XWiki.StyleSheetExtension"; |
46 |
|
} |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
236 |
@Override... |
49 |
|
public String getContentType() |
50 |
|
{ |
51 |
236 |
return "text/css; charset=UTF-8"; |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
236 |
@Override... |
55 |
|
public SxCompressor getCompressor() |
56 |
|
{ |
57 |
236 |
return new SxCompressor() |
58 |
|
{ |
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
59 |
236 |
@Override... |
60 |
|
public String compress(String source) |
61 |
|
{ |
62 |
236 |
try { |
63 |
236 |
CssCompressor compressor = new CssCompressor(new StringReader(source)); |
64 |
236 |
StringWriter out = new StringWriter(); |
65 |
236 |
compressor.compress(out, -1); |
66 |
236 |
return out.toString(); |
67 |
|
} catch (IOException ex) { |
68 |
0 |
LOGGER.warn("Exception compressing SSX code", ex); |
69 |
|
} |
70 |
0 |
return source; |
71 |
|
} |
72 |
|
}; |
73 |
|
} |
74 |
|
|
75 |
|
} |