diff --git a/.gitignore b/.gitignore
index ff808e6d..b0bf03d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,4 @@ lib/ext
log/*
passwd
server.properties
-
+.gradle
diff --git a/README.md b/README.md
index 57434417..8d9fd97c 100644
--- a/README.md
+++ b/README.md
@@ -2,11 +2,11 @@ _This is the README file for version 1.7.0 of the Helma Javascript Web Applicati
__TL;DR__
-- make sure you have Java 1.4 or higher as well as Apache Ant installed
-- clone this repository
-- build Helma with `ant jar`
-- invoke `start.sh`, resp. `start.bat`, depending on your platform
-- direct your web browser to http://localhost:8080
+- Make sure you have Java 1.4 or higher installed
+- Clone this repository
+- Build Helma with `./gradlew`
+- Invoke `start.sh`, resp. `start.bat`, depending on your platform
+- Direct your web browser to http://localhost:8080
# Helma
diff --git a/build.gradle b/build.gradle
index 430d7c6d..8f22cf89 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,7 +19,7 @@ dependencies {
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '8.1.22.v20160922'
compile group: 'org.eclipse.jetty', name: 'jetty-xml', version: '8.1.22.v20160922'
compile group: 'javax.mail', name: 'mail', version: '1.4.7'
- compile group: 'org.mozilla', name: 'rhino', version: '1.7R5'
+ compile group: 'org.mozilla', name: 'rhino', version: '1.7.7.1'
compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2.1'
compile group: 'xmlrpc', name: 'xmlrpc', version: '2.0.1'
}
diff --git a/lib/rhino-1.7.7.1.jar b/lib/rhino-1.7.7.1.jar
new file mode 100644
index 00000000..a8b9417a
Binary files /dev/null and b/lib/rhino-1.7.7.1.jar differ
diff --git a/lib/rhino-1.7R5.jar b/lib/rhino-1.7R5.jar
deleted file mode 100644
index 76b6eaed..00000000
Binary files a/lib/rhino-1.7R5.jar and /dev/null differ
diff --git a/src/helma/framework/ResponseBean.java b/src/helma/framework/ResponseBean.java
index 47e3b751..0217fde9 100644
--- a/src/helma/framework/ResponseBean.java
+++ b/src/helma/framework/ResponseBean.java
@@ -203,8 +203,10 @@ public class ResponseBean implements Serializable {
*
* @param str the string to write to the response buffer
*/
- public void write(String str) {
- res.write(str);
+ public void write(String... str) {
+ for (String s : str) {
+ res.write(s);
+ }
}
/**
@@ -212,8 +214,10 @@ public class ResponseBean implements Serializable {
*
* @param str the string to write to the response buffer
*/
- public void writeln(String str) {
- res.writeln(str);
+ public void writeln(String... str) {
+ for (String s : str) {
+ res.writeln(s);
+ }
}
/**
@@ -237,8 +241,10 @@ public class ResponseBean implements Serializable {
*
* @param message the message
*/
- public void debug(String message) {
- res.debug(message);
+ public void debug(String... messages) {
+ for (String message : messages) {
+ res.debug(message);
+ }
}
/**
diff --git a/src/helma/framework/ResponseTrans.java b/src/helma/framework/ResponseTrans.java
index 4ec26c70..e650e2c0 100644
--- a/src/helma/framework/ResponseTrans.java
+++ b/src/helma/framework/ResponseTrans.java
@@ -377,8 +377,7 @@ public final class ResponseTrans extends Writer implements Serializable {
String str = (message == null) ? "null" : message.toString();
- debugBuffer.append("
");
+ debugBuffer.append("
");
debugBuffer.append(str);
debugBuffer.append("
");
}
diff --git a/src/helma/main/Server.java b/src/helma/main/Server.java
index da90daf1..1ddf8584 100644
--- a/src/helma/main/Server.java
+++ b/src/helma/main/Server.java
@@ -38,7 +38,7 @@ import helma.util.ResourceProperties;
*/
public class Server implements Runnable {
// version string
- public static final String version = "1.7.3 (__builddate__)";
+ public static final String version = "🐜 (__builddate__)";
// static server instance
private static Server server;
diff --git a/src/helma/main/launcher/Main.java b/src/helma/main/launcher/Main.java
index 5f2a94a9..6ed02900 100644
--- a/src/helma/main/launcher/Main.java
+++ b/src/helma/main/launcher/Main.java
@@ -35,7 +35,7 @@ import java.util.ArrayList;
*/
public class Main {
public static final String[] jars = {
- "helma.jar", "rhino-1.7R5.jar",
+ "helma.jar", "rhino-1.7.7.1.jar",
"commons-logging-1.2.jar",
"xmlrpc-2.0.1.jar", "mail-1.4.7.jar", "activation-1.1.jar",
"commons-fileupload-1.3.2.jar", "commons-codec-1-10.jar",
diff --git a/src/helma/scripting/rhino/PathWrapper.java b/src/helma/scripting/rhino/PathWrapper.java
index 7a86cab4..406c615f 100644
--- a/src/helma/scripting/rhino/PathWrapper.java
+++ b/src/helma/scripting/rhino/PathWrapper.java
@@ -35,7 +35,7 @@ public class PathWrapper extends ScriptableObject {
/**
* Zero arg constructor for creating the PathWrapper prototype.
*/
- public PathWrapper (RhinoCore core) throws PropertyException, NoSuchMethodException {
+ public PathWrapper (RhinoCore core) throws RhinoException, NoSuchMethodException {
this.core = core;
// create a dummy path object
this.path = new RequestPath(core.app);
diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/helma/scripting/rhino/RhinoCore.java
index 49cd229c..46c1d57f 100644
--- a/src/helma/scripting/rhino/RhinoCore.java
+++ b/src/helma/scripting/rhino/RhinoCore.java
@@ -25,6 +25,7 @@ import helma.objectmodel.db.DbMapping;
import helma.objectmodel.db.NodeHandle;
import helma.scripting.*;
import helma.util.*;
+
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.ContextFactory;
@@ -42,9 +43,12 @@ import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.WrapFactory;
import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.commonjs.module.RequireBuilder;
+import org.mozilla.javascript.commonjs.module.provider.*;
import org.mozilla.javascript.tools.debugger.ScopeProvider;
import java.io.*;
+import java.net.URI;
import java.text.*;
import java.util.*;
import java.lang.ref.WeakReference;
@@ -89,9 +93,9 @@ public final class RhinoCore implements ScopeProvider {
// optimization level for rhino engine, ranges from -1 to 9
int optLevel = 0;
- // language version - default to JS 1.7
- int languageVersion = 170;
-
+ // language version - default to JS 1.8
+ int languageVersion = 180;
+
// debugger/tracer flags
boolean hasDebugger = false;
boolean hasTracer = false;
@@ -157,6 +161,27 @@ public final class RhinoCore implements ScopeProvider {
global.initStandardObjects(context, false);
global.init();
+ // Enable loading and exporting of CommonJS modules with require and module.exports, resp.
+ // Inspiration: http://stackoverflow.com/a/30355409/5281580
+
+ List
commonJsPaths = new ArrayList();
+ commonJsPaths.add(app.getAppDir().toURI());
+ String commonJsAppPath = app.getProperty("commonjs.dir");
+
+ if (commonJsAppPath != null) {
+ File commonJsAppDir = new File(app.getAppDir(), commonJsAppPath);
+ if (commonJsAppDir.isDirectory()) {
+ commonJsPaths.add(commonJsAppDir.toURI());
+ }
+ }
+
+ new RequireBuilder()
+ .setModuleScriptProvider(new StrongCachingModuleScriptProvider(
+ new UrlModuleSourceProvider(commonJsPaths, null)))
+ .setSandboxed(true)
+ .createRequire(context, global)
+ .install(global);
+
pathProto = new PathWrapper(this);
hopObjectProto = HopObject.init(this);
@@ -816,7 +841,7 @@ public final class RhinoCore implements ScopeProvider {
}
}
return props;
- }
+ }
/**
* Get the RhinoCore instance associated with the current thread, or null
@@ -1207,6 +1232,7 @@ public final class RhinoCore implements ScopeProvider {
} else {
app.logError("Unsupported rhino.languageVersion: " + languageVersion);
}
+
// Set up visual debugger if rhino.debug = true
if (hasDebugger)
initDebugger(cx);