Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Embed a REPL in symbol pages #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ $ cljs watch sitegen
$ node target/sitegen.js
```

Build client-side code:

```
$ cljs watch client
$ cljs watch interactive
```

To publish the site to the [GitHub Pages deployment repo](https://github.com/cljs/cljs.github.io):

```
Expand Down
4 changes: 4 additions & 0 deletions cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
:compiler {:main "client.core"
:output-to "output/js/client.js"
:optimizations :advanced}}
:interactive {:src "src"
:compiler {:main "client.interactive"
:output-to "output/js/interactive.js"
:optimizations :advanced}}
:server {:src "src"
:compiler {:target :nodejs
:main "server.core"
Expand Down
3 changes: 3 additions & 0 deletions src/client/interactive.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(ns client.interactive)

(js/console.log "Interactive !")
3 changes: 2 additions & 1 deletion src/sitegen/api_pages.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@

(defn create-sym-page! [{:keys [ns name-encode] :as sym}]
(->> (sym-page sym)
(common-layout {:head {:title (str "CLJS - " (docname-display (:full-name sym)))}})
(common-layout {:head {:title (str "CLJS - " (docname-display (:full-name sym)))}
:interactive true})
(hiccup/render)
(urls/write! (urls/api-sym ns name-encode))))

Expand Down
8 changes: 7 additions & 1 deletion src/sitegen/layout.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(declare head)
(declare body-header)
(declare body-footer)
(declare interactive)

(defn common-layout [opts content]
[:html
Expand All @@ -14,7 +15,8 @@
(body-header)
content
(body-footer)]
[:script {:src "/js/client.js"}]]])
[:script {:src "/js/client.js"}]
(interactive (:interactive opts))]])

(defn sidebar-layout [& columns]
(case (count columns)
Expand Down Expand Up @@ -90,3 +92,7 @@
[:a {:href "http://opensource.org/licenses/eclipse-1.0.php"} "EPL 1.0"]
[:br]
"Copyright © Rich Hickey"]]])

(defn interactive [is-interactive]
(when is-interactive
[:script {:src (str "/js/interactive.js")}]))