Skip to content

Commit 1ddf023

Browse files
committed
GitHub pages
1 parent 408a0b2 commit 1ddf023

File tree

7 files changed

+2327
-10
lines changed

7 files changed

+2327
-10
lines changed

.project/devserver.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require_relative "common/common"
2-
require "json"
32

43
def start_dev()
54
c = Common.new

.project/docs.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require_relative "common/common"
2+
3+
def build_docs_folder()
4+
c = Common.new
5+
env = c.load_env
6+
cname = "#{env.namespace}-docs-build"
7+
c.run_inline %W{
8+
docker create --name #{cname}
9+
-w /w
10+
-v jars:/root/.m2
11+
dmohs/clojurescript
12+
lein with-profile +docs cljsbuild once
13+
}
14+
at_exit { c.run_inline %W{docker rm -f #{cname}} }
15+
env.source_file_paths.each do |src_path|
16+
c.pipe(
17+
%W{tar -c #{src_path}},
18+
%W{docker cp - #{cname}:/w}
19+
)
20+
end
21+
c.run_inline %W{docker start -a #{cname}}
22+
c.run_inline %W{rm -rf docs}
23+
c.run_inline %W{mkdir -p docs/examples/target}
24+
c.run_inline %W{docker cp #{cname}:/w/resources/public/target/compiled.js docs/examples/target}
25+
c.sf.foreach_static_file do |path, entry|
26+
c.run_inline %W{cp -R #{path}/#{entry} docs/examples/#{entry}}
27+
end
28+
end
29+
30+
def test_docs()
31+
require "webrick"
32+
WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "docs/examples").start
33+
end
34+
35+
Common.register_command({
36+
:invocation => "build-docs",
37+
:description => "(Re-)Builds the docs/ folder.",
38+
:fn => Proc.new { |*args| build_docs_folder(*args) }
39+
})
40+
41+
Common.register_command({
42+
:invocation => "test-docs",
43+
:description => "Runs an HTTP server against the docs/examples folder.",
44+
:fn => Proc.new { |*args| test_docs(*args) }
45+
})

docs/examples/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head profile="http://www.w3.org/2005/10/profile">
4+
<meta charset="utf-8">
5+
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
6+
<title>React CLJS Test Page</title>
7+
</head>
8+
<body>
9+
<div id="app">Loading application...</div>
10+
<script src="target/compiled.js" type="text/javascript"></script>
11+
</body>
12+
</html>

docs/examples/target/compiled.js

Lines changed: 2249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

project.clj

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:dependencies [[cljsjs/create-react-class "15.5.3-0"]
88
[cljsjs/react-dom "15.5.4-0"]] ; react-dom depends on react
99
:source-paths ~source-paths
10-
:profiles {:ui
10+
:profiles {:ui-base
1111
{:plugins [[lein-cljsbuild "1.1.6"] [lein-figwheel "0.5.10"]]
1212
:dependencies [[binaryage/devtools "0.9.4"]
1313
[org.clojure/clojure "1.8.0"]
@@ -20,12 +20,22 @@
2020
{:source-paths ~(concat source-paths ["src/test/cljs"])
2121
:compiler
2222
{:main "webui.main"
23-
:optimizations :none
24-
:source-map true
25-
:source-map-timestamp true
2623
:output-dir "resources/public/target/build"
2724
:output-to "resources/public/target/compiled.js"
28-
:asset-path "target/build"
29-
:preloads [devtools.preload]
30-
:external-config {:devtools/config {:features-to-install [:formatters :hints]}}}
31-
:figwheel true}}}}})
25+
:asset-path "target/build"}
26+
:figwheel true}}}}
27+
:ui
28+
[:ui-base
29+
{:cljsbuild
30+
{:builds
31+
{:client
32+
{:compiler
33+
{:optimizations :none
34+
:source-map true
35+
:source-map-timestamp true
36+
:preloads [devtools.preload]
37+
:external-config {:devtools/config
38+
{:features-to-install [:formatters :hints]}}}}}}}]
39+
:docs
40+
[:ui-base
41+
{:cljsbuild {:builds {:client {:compiler {:optimizations :simple}}}}}]})

project.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
require_relative ".project/common/common"
99
require_relative ".project/devserver"
10+
require_relative ".project/docs"
1011

1112
c = Common.new
1213

src/test/cljs/webui/main.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
(fn [{:keys [this state locals]}]
7373
[:div {}
7474
[:h2 {} (r/get-display-name this)]
75-
"Click the window."
75+
[:div {:style {:margin-bottom "1em"}}
76+
"All of these add and remove a click handler to/from the window."]
7677
[:div {} "This doesn't work: " (:not-equal-count @state)
7778
" " [:button {:on-click #(this :-toggle-anonymous)} "Toggle"]]
7879
[:div {} "This does: " (:saved-count @state)

0 commit comments

Comments
 (0)