mirror of https://github.com/status-im/reagent.git
Generate demo page
This commit is contained in:
parent
93759f6043
commit
2c2dca026c
|
@ -1,3 +1,5 @@
|
|||
index.html
|
||||
site/demo.js
|
||||
target
|
||||
pom.xml
|
||||
.lein-repl-history
|
||||
|
|
10
Makefile
10
Makefile
|
@ -16,7 +16,7 @@ all: buildrun
|
|||
run: openbrowser buildrun
|
||||
|
||||
leinbuild: setup
|
||||
lein -o cljsbuild once $(CLJSBUILD)
|
||||
lein -o with-profile $(PROF) cljsbuild once $(CLJSBUILD)
|
||||
|
||||
openbrowser:
|
||||
(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
|
||||
|
||||
gensite:
|
||||
node bin/gen-site.js
|
||||
|
||||
prodbuild:
|
||||
$(MAKE) PROF=prod,test leinbuild
|
||||
|
||||
buildsite: prodbuild gensite
|
||||
|
||||
setversion:
|
||||
version=$(VERSION); \
|
||||
find . -name project.clj | \
|
||||
|
|
|
@ -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
|
||||
{:client {:compiler
|
||||
{:optimizations :advanced
|
||||
:pretty-print true}}}}}
|
||||
:pretty-print false}}}}}
|
||||
:test {:plugins [[com.cemerick/clojurescript.test "0.2.1"]]
|
||||
:cljsbuild
|
||||
{:builds
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
(def React tmpl/React)
|
||||
|
||||
|
||||
;; (defn as-component [comp]
|
||||
;; (tmpl/as-component comp))
|
||||
|
||||
|
|
|
@ -107,7 +107,9 @@
|
|||
(assert C)
|
||||
(when (nil? (.-cljsRatom C))
|
||||
(set! (.-cljsRatom C)
|
||||
(reaction :auto-run #(.forceUpdate C)
|
||||
(reaction :auto-run (if tmpl/isClient
|
||||
#(.forceUpdate C)
|
||||
identity)
|
||||
(do-render C (.-cljsRenderFn C)))))
|
||||
(ratom/run (.-cljsRatom C)))
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
(def React reacts/React)
|
||||
|
||||
(def isClient (not (nil? (try (.-document js/window)
|
||||
(catch js/Object e nil)))))
|
||||
|
||||
(defn dash-to-camel [dashed]
|
||||
(let [words (string/split (name dashed) #"-")
|
||||
camels (map string/capitalize (rest words))]
|
||||
|
|
|
@ -266,3 +266,9 @@
|
|||
[essential-api]
|
||||
[bmi-demo]
|
||||
[:p "WIP"]])
|
||||
|
||||
(defn ^:export mountdemo []
|
||||
(cloact/render-component [demo] (.-body js/document)))
|
||||
|
||||
(defn ^:export genpage []
|
||||
(cloact/render-component-to-string [demo]))
|
||||
|
|
Loading…
Reference in New Issue