Skip to content

Commit 487c60f

Browse files
committed
Added module.properties for AMP target
Added recurse() javascript function Updated README files git-svn-id: https://share-extras.googlecode.com/svn/trunk/Javascript Console@1122 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent 83ca66c commit 487c60f

File tree

13 files changed

+170
-36
lines changed

13 files changed

+170
-36
lines changed

javascript-console-repo/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/alfresco-data-model-4.0.0.jar" sourcepath="/ALFRESCO_SDK_400/src/alfresco-datamodel-src.zip"/>
77
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/alfresco-remote-api-4.0.0.jar"/>
88
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/dependencies/spring-surf/spring-surf-core-1.0.0.jar"/>
9-
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/dependencies/spring-surf/spring-webscripts-1.0.0.jar"/>
9+
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/dependencies/spring-surf/spring-webscripts-1.0.0.jar" sourcepath="/ALFRESCO_SDK_400"/>
1010
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/dependencies/commons/commons-lang-2.6.jar"/>
1111
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/dependencies/commons/commons-logging-1.1.1.jar"/>
1212
<classpathentry kind="var" path="ALFRESCO_SDK_400/lib/server/dependencies/j2ee/servlet.jar"/>

javascript-console-repo/README.txt

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Javascript Console Admin Console component for Alfresco Share
23
=============================================================
34

@@ -11,21 +12,41 @@ Installation
1112
------------
1213

1314
The component has been developed to install on top of an existing Alfresco
14-
3.4 installation.
15+
3.4 or 4.0 installation. There are two different version in this archive with
16+
a specific folder for each of the Alfresco version.
17+
18+
When you have chosen the correct folder (3.4.x or 4.0.x) for your Alfresco version
19+
you'll find two jar files within that folder. The javascript-console-repo.jar needs
20+
to be copied into the Alfresco repository:
21+
22+
tomcat/webapps/alfresco/WEB-INF/lib/
23+
24+
The other file javascript-console-share.jar needs to be copied to the
25+
corresponding folder in the Share webapp:
26+
27+
tomcat/webapps/share/WEB-INF/lib/
28+
29+
The deployment location has changed recently (with Javascript Console 0.5)
30+
because the Javascript Console now uses Java classes that have to be deployed
31+
to these locations and can NOT reside in tomcat/shared/lib anymore.
1532

16-
An Ant build script is provided to build a JAR file containing the
17-
custom files, which can then be installed into the 'tomcat/shared/lib' folder
18-
of your Alfresco installation.
1933

20-
To build the JAR file, run the following command from the base project
21-
directory.
34+
Building
35+
--------
2236

23-
ant clean dist-jar
37+
To build the individual JAR files, run the following command from the base
38+
project directory.
2439

25-
The command should build a JAR file named javascript-console.jar
26-
in the 'dist' directory within your project.
40+
ant -Dalfresco.sdk.dir=c:\dev\sdks\alfresco-enterprise-sdk-4.0.0 clean dist-jar
2741

28-
To deploy the dashlet files into a local Tomcat instance for testing, you can
42+
The command should build a JAR file named javascript-console-repo.jar or
43+
javascript-console-share.jar in the 'dist' directory within your project.
44+
45+
There also is the javascript-console-dist which builds both jar files and
46+
creates a patched version for Alfresco 3.4.x which does not support all the
47+
features of the version for 4.0.x
48+
49+
To deploy the extension files into a local Tomcat instance for testing, you can
2950
use the hotcopy-tomcat-jar task. You will need to set the tomcat.home
3051
property in Ant.
3152

@@ -34,8 +55,10 @@ property in Ant.
3455
Once you have run this you will need to restart Tomcat so that the classpath
3556
resources in the JAR file are picked up.
3657

58+
3759
Using the component
3860
-------------------
3961

4062
Log in to Alfresco Share as an admin user and navigate to the Administration
4163
page. Click 'Javascript Console' in the left hand side navigation.
64+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
jar.name=javascript-console-repo-0.5.jar
2+
amp.name=javascript-console-repo-0.5.amp
23
src.zip.name=javascript-console-repo-src-0.5.zip
34
build.res.dir.name=alfresco
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
11
jsconsole.setSpace(space);
2+
function recurse(scriptNode, processorOrOptions) {
3+
4+
var result = [];
5+
6+
var recurseInternal = function(scriptNode, options, path, level) {
7+
var index = 0;
8+
9+
if (level < options.maxlevel) {
10+
for (c in scriptNode.children) {
11+
var child = scriptNode.children[c];
12+
var childPath = path + "/"+ child.name;
13+
14+
if (options.filter === undefined || options.filter(child, childPath, index, level)) {
15+
var procResult = options.process(child, childPath, index, level);
16+
if (procResult !== undefined) {
17+
result.push(procResult);
18+
};
19+
};
20+
21+
if (child.isContainer) {
22+
if (options.branch === undefined || options.branch(child, childPath, index, level) ) {
23+
recurseInternal(child, options, childPath, level+1);
24+
};
25+
};
26+
27+
index++;
28+
};
29+
};
30+
};
31+
32+
var options = {};
33+
if (processorOrOptions === undefined) {
34+
options.process = function(node) { return node; };
35+
} else if (typeof processorOrOptions == "function") {
36+
options.process = processorOrOptions;
37+
}
38+
else {
39+
options = processorOrOptions;
40+
};
41+
42+
if (options.maxlevel === undefined) {
43+
options.maxlevel = 100;
44+
};
45+
46+
recurseInternal(scriptNode, options, "", 0);
47+
48+
return result;
49+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Custom AMP to WAR location mappings
2+
3+
#
4+
# The following property can be used to include the standard set of mappings.
5+
# The contents of this file will override any defaults. The default is
6+
# 'true', i.e. the default mappings will be augmented or modified by values in
7+
# this file.
8+
#
9+
include.default=true
10+
11+
#
12+
# Custom mappings. If 'include.default' is false, then this is the complete set.
13+
#
14+
#/WEB-INF=/WEB-INF
15+
#/web=/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# JavascriptConsole-repo module properties
2+
module.id=de.fme.alfresco.JavascriptConsole-repo
3+
module.aliases=jsconsole-repo
4+
module.version=0.5
5+
module.title=fme Javascript Console Repository Extension
6+
module.description=Adminstration console module to execute arbitrary javascript code.

javascript-console-repo/source/java/de/fme/jsconsole/ExecuteWebscript.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public class ExecuteWebscript extends AbstractWebScript {
7070
public void init(Container container, Description description) {
7171
super.init(container, description);
7272
try {
73-
preRollScript = readScriptFromResource(preRollScriptResource);
74-
postRollScript = readScriptFromResource(postRollScriptResource);
73+
preRollScript = readScriptFromResource(preRollScriptResource, true);
74+
postRollScript = readScriptFromResource(postRollScriptResource, false);
7575
} catch (IOException e) {
7676
log.error("Could not read base import script.");
7777
}
@@ -99,13 +99,18 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws
9999
}
100100
}
101101

102-
private String readScriptFromResource(Resource resource) throws IOException {
102+
private String readScriptFromResource(Resource resource, boolean unwrapLines) throws IOException {
103103
@SuppressWarnings("unchecked")
104104
List<String> lines = (List<String>) IOUtils.readLines(resource.getInputStream());
105105

106106
StringBuffer script = new StringBuffer();
107107
for (String line : lines) {
108-
script.append(line.replace("\n", ""));
108+
if (unwrapLines) {
109+
script.append(line.replace("\n", ""));
110+
}
111+
else {
112+
script.append(line);
113+
}
109114
}
110115
return script.toString();
111116
}
Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Javascript Console Admin Console component for Alfresco Share
23
=============================================================
34

@@ -11,21 +12,41 @@ Installation
1112
------------
1213

1314
The component has been developed to install on top of an existing Alfresco
14-
3.4 installation.
15+
3.4 or 4.0 installation. There are two different version in this archive with
16+
a specific folder for each of the Alfresco version.
17+
18+
When you have chosen the correct folder (3.4.x or 4.0.x) for your Alfresco version
19+
you'll find two jar files within that folder. The javascript-console-repo.jar needs
20+
to be copied into the Alfresco repository:
21+
22+
tomcat/webapps/alfresco/WEB-INF/lib/
23+
24+
The other file javascript-console-share.jar needs to be copied to the
25+
corresponding folder in the Share webapp:
26+
27+
tomcat/webapps/share/WEB-INF/lib/
28+
29+
The deployment location has changed recently (with Javascript Console 0.5)
30+
because the Javascript Console now uses Java classes that have to be deployed
31+
to these locations and can NOT reside in tomcat/shared/lib anymore.
1532

16-
An Ant build script is provided to build a JAR file containing the
17-
custom files, which can then be installed into the 'tomcat/shared/lib' folder
18-
of your Alfresco installation.
1933

20-
To build the JAR file, run the following command from the base project
21-
directory.
34+
Building
35+
--------
2236

23-
ant clean dist-jar
37+
To build the individual JAR files, run the following command from the base
38+
project directory.
2439

25-
The command should build a JAR file named javascript-console.jar
26-
in the 'dist' directory within your project.
40+
ant -Dalfresco.sdk.dir=c:\dev\sdks\alfresco-enterprise-sdk-4.0.0 clean dist-jar
2741

28-
To deploy the dashlet files into a local Tomcat instance for testing, you can
42+
The command should build a JAR file named javascript-console-repo.jar or
43+
javascript-console-share.jar in the 'dist' directory within your project.
44+
45+
There also is the javascript-console-dist which builds both jar files and
46+
creates a patched version for Alfresco 3.4.x which does not support all the
47+
features of the version for 4.0.x
48+
49+
To deploy the extension files into a local Tomcat instance for testing, you can
2950
use the hotcopy-tomcat-jar task. You will need to set the tomcat.home
3051
property in Ant.
3152

@@ -34,8 +55,10 @@ property in Ant.
3455
Once you have run this you will need to restart Tomcat so that the classpath
3556
resources in the JAR file are picked up.
3657

58+
3759
Using the component
3860
-------------------
3961

4062
Log in to Alfresco Share as an admin user and navigate to the Administration
4163
page. Click 'Javascript Console' in the left hand side navigation.
64+
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
jar.name=javascript-console-share-0.5.jar
2+
amp.name=javascript-console-share-0.5.amp
23
src.zip.name=javascript-console-share-src-0.5.zip
3-
build.res.dir.name=share
4+
build.res.dir.name=share
5+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Custom AMP to WAR location mappings
2+
3+
#
4+
# The following property can be used to include the standard set of mappings.
5+
# The contents of this file will override any defaults. The default is
6+
# 'true', i.e. the default mappings will be augmented or modified by values in
7+
# this file.
8+
#
9+
include.default=true
10+
11+
#
12+
# Custom mappings. If 'include.default' is false, then this is the complete set.
13+
#
14+
#/WEB-INF=/WEB-INF
15+
#/web=/

0 commit comments

Comments
 (0)