Permalink
Browse files

the browser repl lives

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
0 parents commit 91d7ce28af43664f6fce3a145b630a75ae622bd1 @ibdknox committed Jul 28, 2011
Showing 1,433 changed files with 415,729 additions and 0 deletions.
@@ -0,0 +1,6 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-failures
+.lein-deps-sum
29 README
@@ -0,0 +1,29 @@
+# brepl
+
+The Clojure script browser repl.
+
+## Usage
+
+'''bash
+lein deps
+'''
+
+In ./brepl make sure your CLOJURESCRIPT_HOME is set to wherever clojurescript is on your macine.
+
+'''
+./brepl
+'''
+
+Then just open the included index.html in a browser that supports websockets (only tested in chrome so far).
+Results are printed to the browser's console, so make sure you have it open.
+
+## Notes
+
+ClojureScript doesn't have a (require) function in cljs.core, so I've implemented one for brepl, which I can't
+guarantee will act the same as (ns some-ns (:require ...)), though I haven't seen any differences.
+
+## License
+
+Copyright (C) 2011 Chris Granger
+
+Distributed under the Eclipse Public License, the same as Clojure.
8 brepl
@@ -0,0 +1,8 @@
+#!/bin/bash
+export CLOJURESCRIPT_HOME=/users/chris/repos/clojurescript/
+BREAK_CHARS="(){}[],^%$#@\"\";:''|\\"
+
+rlwrap -r -c -b $BREAK_CHARS script/cljbrepl
+
+
+
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Hello ClojureScript</title>
+ <script type="text/javascript" src="out/goog/base.js"></script>
+ <script type="text/javascript" src="out/goog/deps.js"></script>
+ <script type="text/javascript" src="out/socket.io.min.js"></script>
+ <script type="text/javascript" src="out/brepl.js"></script>
+ </head>
+ <body>
+ <!-- In unoptimized mode, additional script tags are required -->
+ </body>
+</html>
+
@@ -0,0 +1,20 @@
+(function(window) {
+
+ var socket = new io.Socket("localhost", {port: "9090", transports: ['websocket','xhr-polling'], rememberTransport: true, connectTimeout: false });
+ socket.on("message", function(data) {
+ var retVal = eval(data);
+ console.log(retVal);
+ //if(retVal) retVal = retVal.toString();
+ //if(retVal && retVal.length > 100) retVal = retVal.substring(0, 100);
+ //socket.send(retVal);
+ });
+ socket.on('connect', function() {
+ });
+ socket.on("disconnect", function() {
+ });
+ socket.connect();
+
+ window.socket = socket;
+
+
+})(window)
Oops, something went wrong.

0 comments on commit 91d7ce2

Please sign in to comment.