Last active
February 6, 2021 12:41
-
-
Save kohyama/6183122 to your computer and use it in GitHub Desktop.
Revisions
-
kohyama revised this gist
Aug 9, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,6 +49,7 @@ Of course, it's O.K. to serve HTML and JavaScript files with whatever web server you like. In the case, HTML and JavaScript file whose name starts with `repl` isn't inhibitted. Refer [how to use browser REPL of ClojureScript with compojure](https://gist.github.com/kohyama/6191281). ### 5. Use it ``` -
kohyama revised this gist
Aug 9, 2013 . 4 changed files with 35 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,42 +1,56 @@ ## A minimum setting to use browser REPL of ClojureScript Assumed that you have set [leiningen](https://github.com/technomancy/leiningen) up and can use it. ### 1. Prepare files Copy `project.clj`, `repl-test.cljs` and `brepl-test.html` from this gist or git clone this gist and move or copy repl-test.cljs under `src` directory. ``` $ git clone https://gist.github.com/6183122.git $ cd 6183122/ $ mkdir src $ mv repl-test.cljs src/ ``` ### 2. Compile Compile `repl-test.cljs` into `brepl-test.js`. ``` $ lein cljsbuild once ``` Note that a JavaScript file whose name starts with `repl` raises an error like ``` Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:9000/repl-test.js". ``` at step 4. ### 3. Run a ClojureScript REPL ``` $ lein trampoline cljsbuild repl-listen Running ClojureScript REPL, listening on port 9000. "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> ``` This repl also works as a lightweight web server serving the project directory as the document root. ### 4. Open the HTML file Open brepl-test.html on a web browser via the repl web server. ``` http://localhost:9000/brepl-test.html ``` Note that openning as a local file with `file:` doesn't work. Also note that a HTML file whose name starts with `repl` raises an error like ``` No 'xpc' param provided to child iframe. ``` Of course, it's O.K. to serve HTML and JavaScript files with whatever web server you like. In the case, HTML and JavaScript file whose name starts with `repl` isn't inhibitted. ### 5. Use it ``` ClojureScript:cljs.user> (js/alert "Hello world from CLJS REPL!") ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ <html> <body> <script type="text/javascript" src="brepl-test.js"></script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,4 @@ :builds [{ :source-paths ["src"] :compiler { :output-to "brepl-test.js"}}]}) -
kohyama revised this gist
Aug 8, 2013 . 1 changed file with 6 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,21 +21,20 @@ $ lein cljsbuild once $ lein trampoline cljsbuild repl-listen Running ClojureScript REPL, listening on port 9000. "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> ``` This is a minimum web server serving `index.html` and JavaScript files under `js` directory. 4. Open index.html on web browser ``` http://localhost:9000/ ``` Note * `index.html` should be in the same directory in which project.clj is. * An html file nameed other than `index.html` doesn't work. * Openning as a local file with `file:` doesn't work. * Outputting compiled js files to a directory other than js doesn't work. 5. Use it ``` -
kohyama revised this gist
Aug 8, 2013 . 1 changed file with 45 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ # A minimum setting to use browser REPL of ClojureScript Assumed that you have set [leiningen](https://github.com/technomancy/leiningen) up and can use it. 1. Copy files or git clone this gist and move or copy repl-test.cljs under `src` directory ``` $ git clone https://gist.github.com/6183122.git $ cd 6183122/ $ mkdir src $ mv repl-test.cljs src/ ``` 2. Compile `repl-test.cljs` into `js/repl-test.js` ``` $ lein cljsbuild once ``` 3. Run a ClojureScript REPL ``` $ lein trampoline cljsbuild repl-listen Running ClojureScript REPL, listening on port 9000. "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> ``` This is a minimum web server serving `index.html` and JavaScript files under `js` directory. 4. Open index.html on web browser ``` http://localhost:9000/ ``` Note * `index.html` should be in the same directory in which project.clj is. * An html file nameed other than `index.html` doesn't work. * Openning as a local file with `file:` doesn't work. * Outputting compiled js files to a directory other than js doesn't work. 5. Use it ``` ClojureScript:cljs.user> (js/alert "Hello world from CLJS REPL!") ``` If the web browser pops an alert window up, it works. -
kohyama renamed this gist
Aug 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
kohyama revised this gist
Aug 8, 2013 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,6 @@ <head> </head> <body> <script type="text/javascript" src="js/repl-test.js"></script> </body> </html> File renamed without changes. -
Kei Tsuji renamed this gist
Aug 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Kei Tsuji revised this gist
Aug 8, 2013 . 4 changed files with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <html> <head> </head> <body> <script type="text/javascript" src="/js/repl-test.js"></script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,6 @@ :builds [{ :source-paths ["src"] :compiler { :output-to "js/repl-test.js" :optimizations :whitespace :pretty-print true}}]}) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ File renamed without changes. -
Kei Tsuji revised this gist
Aug 8, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,6 @@ :builds [{ :source-paths ["src"] :compiler { :output-to "js/repl-test.js" :optimizations :whitespace :pretty-print true}}]}) -
Kei Tsuji renamed this gist
Aug 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Kei Tsuji revised this gist
Aug 8, 2013 . 2 changed files with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <html> <head> </head> <body> <script type="text/javascript" src="/js/repl-test.js"></script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ -
kohyama revised this gist
Aug 8, 2013 . 2 changed files with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,4 @@ (ns repl-test (:require [clojure.browser.repl :as repl])) (repl/connect "http://localhost:9000/repl") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ <html> <head> </head> <body> <script type="text/javascript" src="repl-test.js"></script> </body> -
kohyama revised this gist
Aug 8, 2013 . 3 changed files with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ (defproject repl-test "0.1.0-SNAPSHOT" :plugins [[lein-cljsbuild "0.3.2"]] :cljsbuild { :builds [{ :source-paths ["src"] :compiler { :output-to "repl-test.js" :optimizations :whitespace :pretty-print true}}]}) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,3 @@ [goog.events.EventType :as event-type])) (repl/connect "http://localhost:9000/repl") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <html> <head></head> <body> <script type="text/javascript" src="repl-test.js"></script> </body> </html> -
kohyama created this gist
Aug 8, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ (ns repl-test (:require [clojure.browser.repl :as repl] [goog.dom :as dom] [goog.events :as events] [goog.events.EventType :as event-type])) (repl/connect "http://localhost:9000/repl") (defn ^:export init [] (.log js/console "foo"))