mirror of
https://github.com/status-im/reagent.git
synced 2025-02-04 16:14:04 +00:00
Generate demo page
This commit is contained in:
parent
93759f6043
commit
2c2dca026c
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
|
index.html
|
||||||
|
site/demo.js
|
||||||
target
|
target
|
||||||
pom.xml
|
pom.xml
|
||||||
.lein-repl-history
|
.lein-repl-history
|
||||||
|
10
Makefile
10
Makefile
@ -16,7 +16,7 @@ all: buildrun
|
|||||||
run: openbrowser buildrun
|
run: openbrowser buildrun
|
||||||
|
|
||||||
leinbuild: setup
|
leinbuild: setup
|
||||||
lein -o cljsbuild once $(CLJSBUILD)
|
lein -o with-profile $(PROF) cljsbuild once $(CLJSBUILD)
|
||||||
|
|
||||||
openbrowser:
|
openbrowser:
|
||||||
(sleep 1 && open site/test.html) &
|
(sleep 1 && open site/test.html) &
|
||||||
@ -49,6 +49,14 @@ src/cloact/impl/react.min.js: bower_components/react/react-with-addons.min.js Ma
|
|||||||
|
|
||||||
copyjs: bower_components src/cloact/impl/react.min.js
|
copyjs: bower_components src/cloact/impl/react.min.js
|
||||||
|
|
||||||
|
gensite:
|
||||||
|
node bin/gen-site.js
|
||||||
|
|
||||||
|
prodbuild:
|
||||||
|
$(MAKE) PROF=prod,test leinbuild
|
||||||
|
|
||||||
|
buildsite: prodbuild gensite
|
||||||
|
|
||||||
setversion:
|
setversion:
|
||||||
version=$(VERSION); \
|
version=$(VERSION); \
|
||||||
find . -name project.clj | \
|
find . -name project.clj | \
|
||||||
|
35
bin/gen-site.js
Executable file
35
bin/gen-site.js
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
var fs = require("fs");
|
||||||
|
var vm = require('vm');
|
||||||
|
|
||||||
|
var srcFile = "target/cljs-client.js";
|
||||||
|
var src = fs.readFileSync(srcFile);
|
||||||
|
vm.runInThisContext(src, srcFile);
|
||||||
|
|
||||||
|
console.log('Generating page');
|
||||||
|
var main = demo.genpage();
|
||||||
|
|
||||||
|
var head = ['<head>',
|
||||||
|
'<meta charset="utf-8">',
|
||||||
|
'<title>This is Cloact</title>',
|
||||||
|
'<link rel="stylesheet" href="examples/todomvc/todos.css">',
|
||||||
|
'<link rel="stylesheet" href="examples/todomvc/todosanim.css">',
|
||||||
|
'<link rel="stylesheet" href="examples/simple/example.css">',
|
||||||
|
'<link rel="stylesheet" href="site/demo.css">',
|
||||||
|
'</head>'].join('\n');
|
||||||
|
|
||||||
|
var body = ['<body>',
|
||||||
|
main,
|
||||||
|
'<script type="text/javascript" src="site/demo.js"></script>',
|
||||||
|
'<script type="text/javascript">',
|
||||||
|
'demo.mountdemo();',
|
||||||
|
'</script>',
|
||||||
|
'</body>'].join('\n');
|
||||||
|
|
||||||
|
var html = ['<html>', head, body, '</html>'].join('\n');
|
||||||
|
|
||||||
|
console.log('Writing site');
|
||||||
|
fs.writeFileSync("index.html", html);
|
||||||
|
fs.writeFileSync("site/demo.js", src);
|
||||||
|
console.log('Wrote site');
|
@ -12,7 +12,7 @@
|
|||||||
{:builds
|
{:builds
|
||||||
{:client {:compiler
|
{:client {:compiler
|
||||||
{:optimizations :advanced
|
{:optimizations :advanced
|
||||||
:pretty-print true}}}}}
|
:pretty-print false}}}}}
|
||||||
:test {:plugins [[com.cemerick/clojurescript.test "0.2.1"]]
|
:test {:plugins [[com.cemerick/clojurescript.test "0.2.1"]]
|
||||||
:cljsbuild
|
:cljsbuild
|
||||||
{:builds
|
{:builds
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
(def React tmpl/React)
|
(def React tmpl/React)
|
||||||
|
|
||||||
|
|
||||||
;; (defn as-component [comp]
|
;; (defn as-component [comp]
|
||||||
;; (tmpl/as-component comp))
|
;; (tmpl/as-component comp))
|
||||||
|
|
||||||
|
@ -107,7 +107,9 @@
|
|||||||
(assert C)
|
(assert C)
|
||||||
(when (nil? (.-cljsRatom C))
|
(when (nil? (.-cljsRatom C))
|
||||||
(set! (.-cljsRatom C)
|
(set! (.-cljsRatom C)
|
||||||
(reaction :auto-run #(.forceUpdate C)
|
(reaction :auto-run (if tmpl/isClient
|
||||||
|
#(.forceUpdate C)
|
||||||
|
identity)
|
||||||
(do-render C (.-cljsRenderFn C)))))
|
(do-render C (.-cljsRenderFn C)))))
|
||||||
(ratom/run (.-cljsRatom C)))
|
(ratom/run (.-cljsRatom C)))
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
(def React reacts/React)
|
(def React reacts/React)
|
||||||
|
|
||||||
|
(def isClient (not (nil? (try (.-document js/window)
|
||||||
|
(catch js/Object e nil)))))
|
||||||
|
|
||||||
(defn dash-to-camel [dashed]
|
(defn dash-to-camel [dashed]
|
||||||
(let [words (string/split (name dashed) #"-")
|
(let [words (string/split (name dashed) #"-")
|
||||||
camels (map string/capitalize (rest words))]
|
camels (map string/capitalize (rest words))]
|
||||||
|
@ -266,3 +266,9 @@
|
|||||||
[essential-api]
|
[essential-api]
|
||||||
[bmi-demo]
|
[bmi-demo]
|
||||||
[:p "WIP"]])
|
[:p "WIP"]])
|
||||||
|
|
||||||
|
(defn ^:export mountdemo []
|
||||||
|
(cloact/render-component [demo] (.-body js/document)))
|
||||||
|
|
||||||
|
(defn ^:export genpage []
|
||||||
|
(cloact/render-component-to-string [demo]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user