1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.lesscss.internal.compiler.less4j; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.skin.SkinManager; |
27 |
|
import org.xwiki.template.TemplateManager; |
28 |
|
|
29 |
|
import com.github.sommeri.less4j.Less4jException; |
30 |
|
import com.github.sommeri.less4j.LessCompiler; |
31 |
|
import com.github.sommeri.less4j.LessSource; |
32 |
|
import com.github.sommeri.less4j.core.DefaultLessCompiler; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component(roles = Less4jCompiler.class) |
41 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.12 |
|
42 |
|
public class Less4jCompiler |
43 |
|
{ |
44 |
|
@Inject |
45 |
|
private TemplateManager templateManager; |
46 |
|
|
47 |
|
@Inject |
48 |
|
private SkinManager skinManager; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@param |
53 |
|
@param |
54 |
|
@param |
55 |
|
@return |
56 |
|
@throws |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
58 |
38 |
public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException... |
59 |
|
{ |
60 |
38 |
LessCompiler lessCompiler = new DefaultLessCompiler(); |
61 |
38 |
LessCompiler.Configuration options = new LessCompiler.Configuration(); |
62 |
38 |
options.setCompressing(true); |
63 |
38 |
options.getSourceMapConfiguration().setInline(inlineSourceMap); |
64 |
38 |
options.getSourceMapConfiguration().setIncludeSourcesContent(true); |
65 |
38 |
LessSource lessSource = |
66 |
|
new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin)); |
67 |
38 |
LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options); |
68 |
37 |
return lessResult.getCss(); |
69 |
|
} |
70 |
|
} |