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 org.apache.commons.lang3.StringUtils; |
23 |
|
import org.xwiki.lesscss.internal.compiler.CachedLESSCompiler; |
24 |
|
import org.xwiki.skin.Skin; |
25 |
|
import org.xwiki.template.Template; |
26 |
|
import org.xwiki.template.TemplateContent; |
27 |
|
import org.xwiki.template.TemplateManager; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 85% |
Uncovered Elements: 3 (20) |
Complexity: 7 |
Complexity Density: 0.54 |
|
35 |
|
public class TemplateLESSSource extends AbstractLESSSource |
36 |
|
{ |
37 |
|
private static final String FILE_SEPARATOR = "/"; |
38 |
|
|
39 |
|
private String templateName; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@param |
44 |
|
@param |
45 |
|
@param |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
47 |
3297 |
public TemplateLESSSource(TemplateManager templateManager, Skin skin, String templateName)... |
48 |
|
{ |
49 |
3297 |
super(templateManager, skin, getParentFolder(templateName)); |
50 |
3297 |
this.templateName = templateName; |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@return |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
3297 |
private static String getParentFolder(String templateName)... |
59 |
|
{ |
60 |
3297 |
return StringUtils.substringBeforeLast(templateName, FILE_SEPARATOR); |
61 |
|
} |
62 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
63 |
6730 |
@Override... |
64 |
|
public String getContent() throws FileNotFound, CannotReadFile |
65 |
|
{ |
66 |
6730 |
try { |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
6730 |
String mainSkinTemplate = "less/" + CachedLESSCompiler.MAIN_SKIN_STYLE_FILENAME; |
78 |
6730 |
if (mainSkinTemplate.equals(templateName)) { |
79 |
6 |
return templateManager.renderFromSkin(templateName, skin); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
6724 |
Template template = templateManager.getTemplate(templateName, skin); |
84 |
6724 |
TemplateContent templateContent = template.getContent(); |
85 |
6724 |
return templateContent.getContent(); |
86 |
|
|
87 |
|
} catch (Exception e) { |
88 |
0 |
throw new CannotReadFile(); |
89 |
|
} |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0 |
@Override... |
93 |
|
public byte[] getBytes() throws FileNotFound, CannotReadFile |
94 |
|
{ |
95 |
0 |
return getContent().getBytes(); |
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
384251 |
@Override... |
99 |
|
public String getName() |
100 |
|
{ |
101 |
384251 |
return templateName; |
102 |
|
} |
103 |
|
} |