1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.plugin.skinx; |
21 |
|
|
22 |
|
import org.apache.commons.lang3.BooleanUtils; |
23 |
|
import org.apache.commons.lang3.StringUtils; |
24 |
|
import org.xwiki.model.reference.DocumentReference; |
25 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
26 |
|
|
27 |
|
import com.xpn.xwiki.XWikiContext; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 82.1% |
Uncovered Elements: 5 (28) |
Complexity: 9 |
Complexity Density: 0.56 |
|
35 |
|
public class JsSkinExtensionPlugin extends AbstractDocumentSkinExtensionPlugin |
36 |
|
{ |
37 |
|
|
38 |
|
public static final String JSX_CLASS_NAME = "XWiki.JavaScriptExtension"; |
39 |
|
|
40 |
|
|
41 |
|
public static final LocalDocumentReference JSX_CLASS_REFERENCE = new LocalDocumentReference("XWiki", |
42 |
|
"JavaScriptExtension"); |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
public static final String PLUGIN_NAME = "jsx"; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
public static final String DEFER_DEFAULT_PARAM = "xwiki.plugins.skinx.deferred.default"; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
@param |
61 |
|
@param |
62 |
|
@see |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
32 |
public JsSkinExtensionPlugin(String name, String className, XWikiContext context)... |
65 |
|
{ |
66 |
32 |
super(PLUGIN_NAME, className, context); |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
@inheritDoc |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
@see |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
4 |
@Override... |
79 |
|
public void virtualInit(XWikiContext context) |
80 |
|
{ |
81 |
4 |
super.virtualInit(context); |
82 |
|
} |
83 |
|
|
|
|
| 82.4% |
Uncovered Elements: 3 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
84 |
6100 |
@Override... |
85 |
|
public String getLink(String documentName, XWikiContext context) |
86 |
|
{ |
87 |
6100 |
DocumentReference documentReference = getCurrentDocumentReferenceResolver().resolve(documentName); |
88 |
6100 |
if (!isAccessible(documentReference, context)) { |
89 |
|
|
90 |
|
|
91 |
0 |
return ""; |
92 |
|
} |
93 |
|
|
94 |
6100 |
StringBuilder result = new StringBuilder("<script type='text/javascript' src='"); |
95 |
6100 |
result.append(getDocumentSkinExtensionURL(documentReference, documentName, PLUGIN_NAME, context)); |
96 |
|
|
97 |
6100 |
String defaultDeferString = context.getWiki().Param(DEFER_DEFAULT_PARAM); |
98 |
6100 |
Boolean defaultDefer = (!StringUtils.isEmpty(defaultDeferString)) ? Boolean.valueOf(defaultDeferString) : true; |
99 |
6100 |
if (BooleanUtils.toBooleanDefaultIfNull((Boolean) getParameter("defer", documentName, context), defaultDefer)) { |
100 |
6091 |
result.append("' defer='defer"); |
101 |
|
} |
102 |
6100 |
result.append("'></script>\n"); |
103 |
6100 |
return result.toString(); |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
9069 |
@Override... |
107 |
|
protected String getExtensionClassName() |
108 |
|
{ |
109 |
9069 |
return JSX_CLASS_NAME; |
110 |
|
} |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
@Override... |
113 |
|
protected String getExtensionName() |
114 |
|
{ |
115 |
0 |
return "Javascript"; |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
@inheritDoc |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
@see |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
6893 |
@Override... |
128 |
|
public String endParsing(String content, XWikiContext context) |
129 |
|
{ |
130 |
6893 |
return super.endParsing(content, context); |
131 |
|
} |
132 |
|
} |