Permalink
Browse files

plugin (#50)

klipse plugin!!!!
  • Loading branch information...
viebel committed May 25, 2016
1 parent 7416738 commit af5cf3cdd73506f3b14bf6489af8e05e974b8bf8
View
@@ -3,8 +3,8 @@ resources/private/
resources/public/cards
resources/public/dbg
resources/public/fig
-resources/public/dev
-resources/public/prod
+resources/public/app
+resources/public/plugin
target/
.lein-repl-history
*-init.clj
View
@@ -0,0 +1,10 @@
+approve_by_comment: true
+approve_regex: ^Approved
+reject_regex: ^Rejected
+reset_on_push: false
+reviewers:
+ members:
+ - viebel
+ - raphaelboukara
+ name: default
+ required: 1
View
@@ -29,28 +29,15 @@ Press Ctrl-Enter to evaluate.
-## Run Locally
+## Run Locally: figwheel + devcards
```bash
-rlwrap lein figwheel
+rlwrap lein figwheel devcards figwheel
```
or
-```bash
-lein figwheel
-```
Open the browser [http://localhost:5014/index-dbg.html](http://localhost:5014/index-dbg.html)
- ## Run dev-card
-
- ```bash
-rlwrap lein figwheel devcards
-```
-or
-
-```bash
-lein figwheel devcards
-```
Open the browser [http://localhost:5014/cards.html](http://localhost:5014/cards.html)
@@ -63,8 +50,8 @@ Read [KLIPSE Magic](https://github.com/viebel/klipse/blob/master/tutorial.md) to
####1. Build
```bash
-lein clean
-lein cljsbuild once dev
+rm -rf resources/public/plugin resources/public/dev
+lein cljsbuild once app plugin
```
####2. Test
View
@@ -0,0 +1,29 @@
+(ns my.date
+ (:require [cljs-time.core :as t :refer [interval date-time in-minutes]]))
+
+[
+ (date-time 1986 10 14 4 3 27 456)
+ (in-minutes (interval (date-time 1986 10 2) (date-time 1986 10 14)))]
+
+(ns my.gadjett
+ (:require-macros [gadjett.core :as gadjett]))
+
+(with-out-str
+ (gadjett/dbg (map inc [1 23 ])))
+
+(ns my.frame
+ (:require [viebel.a8a0349b00689c40571b0faaa36a9ae8.raw.foo :refer [square]]))
+
+(square 19)
+
+;;; the following doesn't work
+(ns my.color
+ (:require [viebel.3800b8ebae5292921c7d6fcb6c995c1f.raw.body-color
+ :refer [set-bg-color]]))
+
+
+(set-bg-color "red")
+
+
+
+
View
@@ -2,8 +2,9 @@
:description "Cljs compiler in cljs"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.8.51"]
- [viebel/gadjett "0.1.10"]
[org.clojure/core.async "0.2.374"]
+ [im.chit/purnam "0.5.2"]
+ [viebel/gadjett "0.1.12"]
[org.omcljs/om "1.0.0-alpha32"]
[replumb "0.2.2-SNAPSHOT"]
[com.cemerick/url "0.1.1"]
@@ -32,10 +33,11 @@
:output-dir "resources/private/test"
:verbose false
:optimizations :whitespace }}
- :dev {
- :source-paths ["src"]
+ :app {
+ :source-paths ["src" "resources/public/lib"]
:compiler {
- :main "klipse.core"
+ :preamble ["mirror_extensions.js"]
+ :main "klipse.run.app"
:output-to "resources/public/dev/js/klipse.js"
:output-dir "resources/public/dev/js"
:pretty-print false
@@ -44,10 +46,24 @@
;:elide-asserts true
:optimizations :whitespace
:verbose false}}
+ :plugin {
+ :source-paths ["src" "resources/public/lib"]
+ :compiler {
+ :preamble ["mirror_extensions.js"]
+ :main "klipse.run.plugin"
+ :output-to "resources/public/plugin/js/klipse_plugin.js"
+ :output-dir "resources/public/plugin/js"
+ :pretty-print false
+ :optimize-constants true
+ :static-fns true
+ ;:elide-asserts true
+ :optimizations :whitespace
+ :verbose false}}
:figwheel {
:figwheel true
:source-paths ["src"]
- :compiler {:main "klipse.core"
+ :compiler {:main "klipse.run.all"
+ :preamble ["mirror_extensions.js"]
:asset-path "fig/js"
:output-to "resources/public/fig/js/klipse.fig.js"
:output-dir "resources/public/fig/js"
@@ -16,7 +16,6 @@
</div>
<div id="compiler" style="height: 100%;"></div>
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
- <script src="lib/mirror_extensions.js"></script>
<script src="dev/js/klipse.js?version=0.4.3"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+ <head lang="en">
+ <meta charset="UTF-8">
+ <title>KLIPSE: a simple and elegant online cljs compiler and evaluator</title>
+ <link rel='shortcut icon' type='image/x-icon' href='img/klipse.png' />
+ <link rel="stylesheet" type="text/css" href="css/codemirror.css">
+ </head>
+ <body>
+ <div class="clojure-js">
+ (map inc [100000 2 3])
+ </div>
+ <div class="clojure">
+ (
+ <span>
+ map inc [1 2 3]
+ </span>)
+ </div>
+ <br/>
+ <span class="clojure"> (defn foo [x] (* x x)) </span>
+ <br/>
+ <span class="clojure"> (foo 19) </span>
+ <br/>
+ <span class="clojure">
+ (ns my.ns
+ (:require [gadjett.collections :as collections :refer [map-object my-replace]]))
+
+ [(map-object inc {:a 1 :b 2})
+ (my-replace '{a (b) c (C C)} '(a c))]
+
+ </span>
+
+ <br/>
+ <span class="clojure">
+ (ns my.gg
+ (:require [goog.async]))
+
+ (str goog.async.nextTick)
+ </span>
+
+
+
+ <span class="clojure"> (map inc [1 2 3]) </span>
+ <br/>
+ <span class="clojure"> (zipmap '[a b c] [100 2 3]) </span>
+ <br/>
+ <span class="clojure"> (map inc [1000 2 3]) </span>
+ <br/>
+ <span class="clojure"> (map dec [1 2 3]) </span>
+ <br/>
+ <div class="clojure">
+
+(ns my.hello$macros) (defmacro hello [x] `(inc ~x)) (my.hello/hello 13)
+ </div>
+ <br/>
+ <script>
+ window.klipse_settings = {
+ selector: '.clojure',
+ selector_js: '.clojure-js'
+ };
+ </script>
+ <script src="lib/mirror_extensions.js"></script>
+ <script src="fig/js/klipse.fig.js"></script>
+ </body>
+</html>
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+ <head lang="en">
+ <meta charset="UTF-8">
+ <title>KLIPSE: a simple and elegant online cljs compiler and evaluator</title>
+ <link rel='shortcut icon' type='image/x-icon' href='img/klipse.png' />
+ </head>
+ <body>
+ <div class="clojure">
+ (
+ <span>
+ map inc [1 2 3]
+ </span>)
+ </div>
+ <br/>
+ <span class="clojure"> (defn foo [x] (* x x)) </span>
+ <span class="clojure"> (foo 19) </span>
+ <span class="clojure"> (ns my.elyahou) (defn bar [x] (* x x)) </span>
+ <span class="clojure"> (ns my.rafi) (my.elyahou/bar 19) </span>
+ <span class="clojure"> (map inc [1 2 3]) </span>
+ <br/>
+ <span class="clojure"> (map inc [100 2 3]) </span>
+ <br/>
+ <span class="clojure"> (map inc [1000 2 3]) </span>
+ <br/>
+ <span class="clojure"> (map dec [1 2 3]) </span>
+ <br/>
+ <div class="clojure">
+ (ns my.best$macros)
+ <br/>
+
+ (defmacro disp [& forms]
+ (cons `str (for [form forms]
+ `(str (pr-str '~form) " => " (pr-str ~form) "\n"))))
+
+ (my.best/disp
+ (map inc [1 2 3])
+ (+ 4 5 6))
+ </div>
+ <br/>
+ <link rel="stylesheet" type="text/css" href="css/codemirror.css">
+ <script>
+ window.klipse_settings = {
+ selector: '.clojure'
+ };
+ </script>
+ <script src="dev/js/klipse.js"></script>
+ </body>
+</html>
View
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+ <head lang="en">
+ <meta charset="UTF-8">
+ <title>KLIPSE: a simple and elegant online cljs compiler and evaluator</title>
+ <link rel='shortcut icon' type='image/x-icon' href='img/klipse.png' />
+ <link rel="stylesheet" type="text/css" href="css/codemirror.css">
+ </head>
+ <body>
+ <span class="clojure">
+ (ns my.ns3
+ (:require-macros [gadjett.core :as gadjett]))
+
+ (with-out-str
+ (gadjett/dbg (map inc [1 23 ])))
+
+ </span>
+
+ <script>
+ window.klipse_settings = {
+ selector: '.clojure',
+ selector_js: '.clojure-js'
+ };
+ </script>
+ <script src="lib/mirror_extensions.js"></script>
+ <script src="fig/js/klipse.fig.js"></script>
+ </body>
+</html>
View
@@ -1,6 +1,11 @@
gzip resources/public/dev/js/klipse.js
+gzip resources/public/plugin/js/klipse.js
gsutil -h "Content-Encoding:gzip" -h "Content-Type:application/javascript" cp resources/public/dev/js/klipse.js.gz gs://app.klipse.tech/dev/js/klipse.js
+gsutil -h "Content-Encoding:gzip" -h "Content-Type:application/javascript" cp resources/public/plugin/js/klipse_plugin.js.gz gs://app.klipse.tech/plugin/js/klipse_plugin.js
gunzip resources/public/dev/js/klipse.js.gz
+gunzip resources/public/plugin/js/klipse_plugin.js.gz
mv resources/public/dev/js/klipse.js /tmp
+mv resources/public/plugin/js/klipse_plugin.js /tmp
gsutil -m rsync -R resources/public gs://app.klipse.tech
mv /tmp/klipse.js resources/public/dev/js
+mv /tmp/klipse_plugin.js resources/public/plugin/js
View
@@ -0,0 +1,16 @@
+(ns klipse.app
+ (:require
+ [goog.dom :as gdom]
+ [om.next :as om]
+ [klipse.ui.layout :as ui]
+ [klipse.utils :refer [url-parameters]]
+ [klipse.control.control :as control]
+ [klipse.ui.editors.cljs :as cljs-editor]))
+
+(defn init []
+ (om/add-root!
+ control/reconciler
+ ui/Layout
+ (gdom/getElement "compiler"))
+
+ (cljs-editor/process-input control/reconciler (:cljs_in (url-parameters))))
@@ -4,7 +4,7 @@
(:require
[clojure.string :as string]
[gadjett.core :as gadjett :refer-macros [dbg]]
- [klipse.compiler :refer [eval compile]]
+ [klipse.compiler :refer [eval compile str-eval str-compile]]
[devcards.core :as dc :refer-macros [defcard deftest]]))
(defn remove-chars [s]
@@ -27,3 +27,39 @@
(are [input-clj output-clj]
(= (eval input-clj) [:ok output-clj])
"(ns my.ns$macros) (defmacro disp [& forms] (cons `str (for [form forms] `(str (pr-str '~form) \" => \" (pr-str ~form) \"\n\")))) (my.ns/disp (+ 1 2))" "(+ 1 2) => 3\n"))
+
+
+(deftest test-str-compile-ok
+ "str-compile should return the compileuation of the expression as a strin"
+ (are [input output]
+ (= (str-compile input) output)
+ "(+ 1 2)" "((1) + (2));\n"
+ "(map inc [1 2 3])" "cljs.core.map.call(null,cljs.core.inc,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [(1),(2),(3)], null));\n"))
+
+(deftest test-str-eval-ok
+ "str-eval should return the evaluation of the expression as a strin"
+ (are [input output]
+ (= (str-eval input) output)
+ "(+ 1 2)" "3"
+ "(map inc [1 2 3])" "(2 3 4)"))
+
+(deftest test-str-eval-error
+ "str-eval should return an error as a string"
+ (are [input output]
+ (= (str-eval input) output)
+ "(+ 1 2" "#error {:message \"EOF while reading\", :data {:type :reader-exception}}"
+ "(map inc [1 2 3]" "#error {:message \"EOF while reading\", :data {:type :reader-exception}}"))
+
+(deftest test-str-compile-error
+ "str-compile should return an error as a string"
+ (are [input output]
+ (= (str-compile input) output)
+ "(+ 1 2" "#error {:message \"Could not compile cljs-in\", :data {:tag :cljs/analysis-error}, :cause #error {:message \"EOF while reading, starting at line 1 and column 1\", :data {:type :reader-exception, :line 1, :column 6, :file \"cljs-in\"}}}"
+
+ "(map inc [1 2 3]" "#error {:message \"Could not compile cljs-in\", :data {:tag :cljs/analysis-error}, :cause #error {:message \"EOF while reading, starting at line 1 and column 1\", :data {:type :reader-exception, :line 1, :column 17, :file \"cljs-in\"}}}"))
+
+
+
+
+
+
@@ -4,7 +4,7 @@
(:require
[clojure.string :as string]
[gadjett.core :as gadjett :refer-macros [dbg]]
- [klipse.compiler :refer [eval compile]]
+ [klipse.compiler :refer [str-compile compile]]
[devcards.core :as dc :refer-macros [defcard deftest]]))
(defn remove-chars [s]
@@ -16,6 +16,7 @@
(defn error->clj [[status error]]
[status {:message (.. error -message)}])
+
(deftest success
"compile with success"
(are [input output]
Oops, something went wrong.

0 comments on commit af5cf3c

Please sign in to comment.