-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Sep 16, 2024
1 parent
72ed9e7
commit 8af1e3d
Showing
13 changed files
with
421 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
(ns demo.frepl | ||
(:require | ||
[clojure.string :as string] | ||
[modular.system] | ||
[reval.document.notebook] | ||
[reval.kernel.protocol :refer [kernel-eval]] | ||
[promesa.core :as p])) | ||
|
||
;; first lets get the running reval instance | ||
(def s (modular.system/system :reval)) | ||
|
||
(def code | ||
(reval.document.notebook/load-src "notebook.study.movies" :clj)) | ||
|
||
code | ||
|
||
(p/await (kernel-eval {:kernel :clj | ||
:ns "notebook.study.movies" | ||
:code code})) | ||
|
||
|
||
(p/await (kernel-eval {:kernel :clj | ||
:ns "user" | ||
:code code})) | ||
|
||
|
||
(p/await (kernel-eval {:code "(println 3) (def x 777) (defn f [] 99) (+ 3 4)" | ||
:kernel :clj | ||
:ns "bongotrott" | ||
:id 1})) | ||
|
||
(defn add-ns [ns] | ||
(str "(in-ns '" ns ")\r\n")) | ||
|
||
(def code-ns (add-ns "notebook.study.movies")) | ||
|
||
|
||
code-ns | ||
(p/await (kernel-eval {:kernel :clj | ||
:ns "user" | ||
:code code-ns})) | ||
|
||
|
||
|
||
|
||
(load-string code) | ||
|
||
(def code2 | ||
(let [ns "notebook.study.movies" | ||
code-ns (if (and ns (not (string/blank? ns))) | ||
(str "(in-ns '" ns " ) ") | ||
"nil") | ||
code-with-ns (str code-ns " [ " code " (str *ns*) ]")] | ||
code-with-ns)) | ||
|
||
code2 | ||
|
||
(load-string code2) | ||
|
||
|
||
(def code3 | ||
(let [ns "notebook.study.movies" | ||
code-ns (if (and ns (not (string/blank? ns))) | ||
(str "(in-ns '" ns " ) ") | ||
"nil") | ||
code-with-ns (str code-ns code )] | ||
code-with-ns)) | ||
|
||
code3 | ||
|
||
(load-string code3) | ||
|
||
(load-string "(in-ns 'xxx) (def a 1)") | ||
|
||
|
||
(load-string "(in-ns 'xxx) *ns*") | ||
|
||
(load-string "(ns abc)(def x 777) (defn f [] 99) (+ 3 4)") | ||
|
||
(load-string "(in-ns 'abc)(def x 777) (defn f [] 99) (+ 3 4)") | ||
|
||
(load-string "(in-ns 'ddd)(def x 777) (defn f [] 99) (+ 3 4)") | ||
|
||
(load-string "(in-ns 'ddd)(def x 777)") | ||
|
||
(load-string "(in-ns 'ddd)(def x 777) (defn y [] 4)") | ||
|
||
(load-string "(ns xxx) *ns*") | ||
|
||
|
||
(load-string "*ns*") | ||
|
||
(load-string "(ns yyy) *ns*") | ||
|
||
|
||
|
||
(p/await (kernel-eval {:kernel :clj | ||
:ns "notebook.study.movies" | ||
:code "*ns*"})) | ||
|
||
(p/await (kernel-eval {:kernel :clj | ||
:ns "notebook.study.movies" | ||
:code code-with-ns})) | ||
|
||
|
||
(def code2 "(ns bongo) (def x 34) (+ x 4) *ns*") | ||
|
||
|
||
(p/await (kernel-eval {:kernel :clj | ||
;:ns "user" | ||
:code code2})) | ||
|
||
|
||
(p/await (kernel-eval {:kernel :clj | ||
:ns "bongo" | ||
:code "*ns*"})) | ||
|
||
|
||
(load-string "*ns*") | ||
|
||
(load-string "(ns bongo) (def y 36)") | ||
|
||
(load-string "(in-ns 'bongo) y") | ||
|
||
|
||
; (in-ns 'yippie2) | ||
(load-string "(ns yippie7 (:require [clojure.pprint :refer [print-table]])) | ||
(def movies [{:a 1} {:a 2}]) | ||
(print-table movies) | ||
*ns* | ||
") |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(ns demo.page.overlay | ||
(:require | ||
[reval.frepl :refer [show-floating-repl show-floating-repl-namespace]])) | ||
|
||
|
||
(defn overlay-page [{:keys [route-params query-params handler] :as route}] | ||
[:div | ||
[:h1 "I am a normal reagent page. But I can add a floating repl."] | ||
[:a {:on-click #(show-floating-repl {:code "(+ 1 2 3)"})} | ||
[:p "show code (floating)"]] | ||
[:a {:on-click #(show-floating-repl {:code "(+ 1 2 3)" | ||
:render-fn 'reval.viz.render-fn/reagent | ||
:data ^{:hiccup true} | ||
[:span {:style {:color "blue"}} "25"]} | ||
)} | ||
[:p "show code (eval result)"]] | ||
|
||
[:a {:on-click #(show-floating-repl-namespace {:ns "notebook.study.movies" | ||
:kernel :clj | ||
})} | ||
[:p "show code (namespace)"]] | ||
|
||
|
||
[:a {:on-click #(show-floating-repl-namespace {:ns "demo.notebook.highcharts" | ||
:kernel :clj})} | ||
[:p "show code (highcharts)"]] | ||
|
||
|
||
|
||
]) | ||
|
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.