Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
viebel committed Aug 22, 2016
1 parent f09e81a commit a9f274d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 37 deletions.
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(defproject klipse "2.3.0"
:description "Cljs compiler in cljs"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.198"]
:dependencies [[org.clojure/clojure "1.9.0-alpha10"]
[org.clojure/clojurescript "1.9.211"]
[org.clojure/core.async "0.2.385"]
[im.chit/purnam "0.5.2"]
[cljsjs/markdown "0.6.0-beta1-0"]
Expand Down
32 changes: 1 addition & 31 deletions resources/public/playground-dbg.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,7 @@
<br/>


<div class="lambda">
{div {@ style="text-align:center;font:bold 2em georgia;color:red;"} √(3{sup 2}+4{sup 2}) = {sqrt {+ {* 3 3} {* 4 4}}}}
</div>
<br/>
<div class="lambda">
{def amélie {img
{@ id="amelie"
src="http://epsilonwiki.free.fr/lambdaway/data/amelie_poulain.jpg"
height="150"
title="Amélie Poulain"
style="box-shadow:0 0 8px black;
border:1px solid white;
-webkit-transform:rotate(-5deg);
-moz-transform:rotate(-5deg);
transform:rotate(-5deg);"}}}
{amélie}
</div>
<br/>
<pre>
<code class="eval-html" data-editor-type="html">
&lt;h1&gt; Title &lt;/h1&gt;
&lt;b&gt; bold &lt;/b&gt;
</code>
</pre>


<div class="eval-html" data-editor-type="html">
&lt;img id="amelie" src="http://epsilonwiki.free.fr/lambdaway/data/amelie_poulain.jpg" height="150" title="Amélie Poulain" style="box-shadow:0 0 8px black; border:1px solid white; -webkit-transform:rotate(-5deg); -moz-transform:rotate(-5deg); transform:rotate(-5deg);"&gt;&lt;/img&gt;
</div>



<script src="https://viebel.github.io/klipse/examples/lambdaway_eval.js"></script>
<script>
window.klipse_settings = {
Expand Down
16 changes: 12 additions & 4 deletions src/klipse/plugin.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
(:require
[klipse.args-from-element :refer [editor-args-from-element eval-args-from-element content]]
[klipse.klipse-editors :refer [create-editor]]
[clojure.spec :as s :refer [instrument]]
[clojure.spec :as s]
[clojure.spec.test :as stest]
[clojure.walk :refer [keywordize-keys]]
[goog.dom :refer [isElement]]
[cljs.core.async :refer [<!]]
Expand Down Expand Up @@ -77,11 +78,18 @@
:settings ::klipse-settings
:mode ::mode))

(defn ->clj [settings]
; we cannot keywordize the keys as the modules might be written in javascript
(js->clj settings :keywordize-keys false))

(defn ^:export klipsify [element general-settings mode]
(if-let [opts (@mode-options mode)]
(klipsify-with-opts element general-settings opts)
(go (js/console.error "cannot find options for mode: " mode ". Supported modes are: " (clj->js (keys @mode-options))))))

(defn klipsify-js [element js-general-settings mode]
(klipsify element (->clj js-general-settings) mode))

(defn ^:export klipsify-elements [elements general-settings mode]
(go
(doseq [element elements]
Expand All @@ -94,7 +102,7 @@
(klipsify-elements (array-seq (js/document.querySelectorAll selector)) keywordized-settings (@selector->mode selector-name))))))

(defn ^:export init [js-settings]
(init-clj (js->clj js-settings :keywordize-keys false))); we cannot keywordize the keys as the modules might be written in javascript
(init-clj (->clj js-settings)))

(s/instrument #'klipsify)
(s/instrument #'klipsify-with-opts)
(stest/instrument `klipsify)
(stest/instrument `klipsify-with-opts)
3 changes: 3 additions & 0 deletions src/klipse/run/plugin/plugin.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
(defn ^:export settings []
(aget js/window "klipse_settings"))

(defn ^:export klipsify [element mode]
(plugin/klipsify-js element (settings) mode))

(plugin/init (settings))

0 comments on commit a9f274d

Please sign in to comment.