git.fiddlerwoaroof.com
Browse code

initial-commit

Ed Langley authored on 15/09/2018 20:54:48
Showing 30 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+*.class
2
+yarn.lock
3
+*.iml
4
+*.jar
5
+.idea
6
+checkouts
7
+classes
8
+figwheel_server.log
9
+lein-template.iml
10
+node_modules
11
+pom.xml
12
+pom.xml.asc
13
+resources/public/js/main
14
+resources/public/js/cards
15
+resources/public/js/test/js
16
+target
17
+out
18
+package-lock.json
19
+resources/private
20
+.lein-repl-history
21
+/.nrepl-port
22
+/.shadow-cljs
23
+*~
0 24
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+test:
2
+	npm install
3
+	npx shadow-cljs compile ci-tests
4
+	npx karma start --single-run
5
+	lein do clean, test-refresh :run-once # clean is needed in case AOT stuff is around
6
+
7
+i18n-extract:
8
+	@echo "Building Clojurescript"
9
+	@shadow-cljs release i18n
10
+	@echo "Running extraction"
11
+	@xgettext --from-code=UTF-8 --debug -k -ktr:1 -ktrc:1c,2 -ktrf:1 -o resources/i18n/messages.pot target/i18n/i18n.js
12
+	@echo "Done."
13
+	@echo 
14
+	@echo "Use msgmerge to merge the new messages.pot with existing translations."
15
+	@echo 
16
+	@echo "  msgmerge --force-po --no-wrap -U es.po messages.pot"
17
+	@echo 
18
+	@echo "If you have a new locale you'd like to support, generate a new PO file for it using:"
19
+	@echo 
20
+	@echo "   msginit --no-translator -l LOCALE --no-wrap -o resources/i18n/LOCALE.po -i resources/i18n/messages.pot"
21
+	@echo 
22
+	@echo "Now give all of your PO files in i18n to a translator (or use PoEdit Pro to get close). Then put the"
23
+	@echo "updated PO files back in i18n and run 'make i18n-generate"
24
+	@echo 
25
+	@echo "See the GNU Gettext manual for more instructions on working with POT and PO files."
26
+
27
+.PHONY: i18n-extract test
0 28
new file mode 100644
... ...
@@ -0,0 +1,244 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+<html xmlns="http://www.w3.org/1999/xhtml">
6
+
7
+<head>
8
+<title>README.html</title>
9
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
10
+
11
+</head>
12
+
13
+<body>
14
+
15
+<h1>The Project</h1>
16
+
17
+<p>The main project source is in <code>src/main</code>.</p>
18
+
19
+<p><code>
20
+.
21
+├── Makefile           ; i18n extract/generate and CI test running
22
+├── karma.conf.js      ; CI Runner config
23
+├── package.json       ; NPM modules
24
+├── project.clj        ; Leiningen project file
25
+├── resources
26
+|   ├── i18n               ; directory for i18n extract/translate/serve
27
+|   │   ├── es.po          ; spanish translations
28
+|   │   └── messages.pot   ; extracted strings (template)
29
+|   └── public
30
+│       ├── cards.html    ; page for mounting dev cards
31
+│       ├── index.html    ; main app index page
32
+│       └── js
33
+│           └── test
34
+│               └── index.html ; custom test page for running tests in dev mode
35
+├── shadow-cljs.edn    ; Shadow-cljs configuration file. CLJS builds.
36
+└── src
37
+    ├── cards
38
+    │   └── fulcro_cljdoc
39
+    │       ├── cards.cljs   ; Main for devcards
40
+    │       └── intro.cljs   ; A sample devcards file
41
+    ├── dev
42
+    │   └── user.clj         ; Functions for running web server in development mode
43
+    ├── main
44
+    │   ├── config           ; configuration files for web server
45
+    │   │   ├── defaults.edn
46
+    │   │   ├── dev.edn
47
+    │   │   └── prod.edn
48
+    │   └── fulcro_cljdoc
49
+    │       ├── api
50
+    │       │   ├── mutations.clj          ; server-side implementation of mutations
51
+    │       │   ├── mutations.cljs         ; client-side implementation of mutations
52
+    │       │   └── read.clj               ; server-side reads
53
+    │       ├── client.cljs                ; file that creates the Fulcro client
54
+    │       ├── development-preload.cljs   ; code to run in development mode before anything else
55
+    │       ├── server.clj                 ; file that creates the web server
56
+    │       ├── server_main.clj            ; production server entry point
57
+    │       └── ui
58
+    │           ├── components.cljc  ; Sample reusable component
59
+    │           └── root.cljc        ; Main UI
60
+    └── test
61
+        └── fulcro_cljdoc
62
+            ├── client_test_main.cljs  ; setup for dev mode tests
63
+            └── sample_spec.cljc       ; a sample spec in fulcro-spec
64
+</code></p>
65
+
66
+<h2>Setting Up</h2>
67
+
68
+<p>The shadow-cljs compiler uses all cljsjs and NPM js dependencies through
69
+NPM. If you use a library that is in cljsjs you will also have to add
70
+it to your <code>package.json</code>.</p>
71
+
72
+<p>You also cannot compile this project until you install the ones it
73
+depends on already:</p>
74
+
75
+<p><code>
76
+$ npm install
77
+</code></p>
78
+
79
+<p>or if you prefer <code>yarn</code>:</p>
80
+
81
+<p><code>
82
+$ yarn install
83
+</code></p>
84
+
85
+<p>Adding NPM Javascript libraries is as simple as adding them to your
86
+<code>package.json</code> file and requiring them! See the
87
+<a href="https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript">the Shadow-cljs User's Guide</a>
88
+for more information.</p>
89
+
90
+<h2>Development Mode</h2>
91
+
92
+<p>Shadow-cljs handles the client-side development build. The file
93
+<code>src/main/fulcro_cljdoc/client.cljs</code> contains the code to start and refresh
94
+the client for hot code reload.</p>
95
+
96
+<p>Running all client development builds:</p>
97
+
98
+<p><code>
99
+$ npx shadow-cljs watch main cards test
100
+...
101
+shadow-cljs - HTTP server for ":main" available at http://localhost:8020
102
+shadow-cljs - HTTP server for ":test" available at http://localhost:8022
103
+shadow-cljs - HTTP server for ":cards" available at http://localhost:8023
104
+...
105
+</code></p>
106
+
107
+<p>The compiler will detect which builds are affected by a change and will minimize
108
+incremental build time.</p>
109
+
110
+<p>NOTE: The server wil start a web server for all three builds (on different ports).
111
+You typically do not need the one for main because you'll be running your
112
+own server, but it is there in case you are only going to be writing
113
+a client-side app that has no server API.</p>
114
+
115
+<p>The URLs for working with cards and tests are:</p>
116
+
117
+<ul>
118
+<li>Cards: <a href="http://localhost:8023/cards.html">http://localhost:8023/cards.html</a></li>
119
+<li>Tests: <a href="http://localhost:8022/index.html">http://localhost:8022/index.html</a></li>
120
+<li>Main: <a href="http://localhost:8020/index.html">http://localhost:8020/index.html</a> (NO API SERVER)</li>
121
+</ul>
122
+
123
+<p>See the server section below for working on the full-stack app itself.</p>
124
+
125
+<h3>Client REPL</h3>
126
+
127
+<p>The shadow-cljs compiler starts an nREPL. It is configured to start on
128
+port 9000 (in <code>shadow-cljs.edn</code>).</p>
129
+
130
+<p>In IntelliJ, simply add a <em>remote</em> Clojure REPL configuration with
131
+host <code>localhost</code> and port <code>9000</code>.</p>
132
+
133
+<p>If you're using CIDER
134
+see <a href="https://shadow-cljs.github.io/docs/UsersGuide.html#_cider">the Shadow-cljs User's Guide</a>
135
+for more information.</p>
136
+
137
+<h3>The API Server</h3>
138
+
139
+<p>The shadow-cljs compiler starts a server for serving development files,
140
+but you usually will not use it. Instead you'll start your own server
141
+that can also serve your application's API.</p>
142
+
143
+<p>Start a clj REPL in IntelliJ, or from the command line:</p>
144
+
145
+<p><code>bash
146
+$ lein repl
147
+user=&gt; (go)
148
+...
149
+user=&gt; (restart) ; stop, reload server code, and go again
150
+user=&gt; (tools-ns/refresh) ; retry code reload if hot server reload fails
151
+</code></p>
152
+
153
+<p>The URL to work on your application is then
154
+<a href="http://localhost:3000">http://localhost:3000</a>.</p>
155
+
156
+<p>Hot code reload, preloads, and such are all coded into the javascript,
157
+so serving the files from the alternate server is fine.</p>
158
+
159
+<h3>Preloads</h3>
160
+
161
+<p>There is a preload file that is used on the development build of the
162
+application <code>fulcro-cljdoc.development-preload</code>. You can add code here that
163
+you want to execute before the application initializes in development
164
+mode.</p>
165
+
166
+<h3>Fulcro Inspect</h3>
167
+
168
+<p>The Fulcro inspect will preload on the development build of the main
169
+application and cards. You can activate it by pressing CTRL-F while in
170
+the application. If you need a different keyboard shortcut (e.g. for
171
+Windows) see the docs on github.</p>
172
+
173
+<h2>Tests</h2>
174
+
175
+<p>Tests are in <code>src/test</code></p>
176
+
177
+<p><code>
178
+src/test
179
+└── fulcro_cljdoc
180
+    ├── client_test_main.cljs     entry point for dev-mode client tests
181
+    └── sample_spec.cljs          spec runnable by client and server.
182
+</code></p>
183
+
184
+<h3>Server tests:</h3>
185
+
186
+<p>Interacting with tests resuts via a browser (also allows test focusing, etc):</p>
187
+
188
+<p>From a CLJ REPL:</p>
189
+
190
+<p><code>
191
+user=&gt; (start-server-tests) ; start a server on port 8888 showing the server tests
192
+</code></p>
193
+
194
+<p>then navigate to <a href="http://localhost:8888/fulcro-spec-server-tests.html">http://localhost:8888/fulcro-spec-server-tests.html</a></p>
195
+
196
+<p>If you'd instead like to see them pop up over and over again in a terminal:</p>
197
+
198
+<p><code>
199
+lein test-refresh
200
+</code></p>
201
+
202
+<h3>CI Tests</h3>
203
+
204
+<p>Use the Makefile target <code>tests</code>:</p>
205
+
206
+<p><code>
207
+make test
208
+</code></p>
209
+
210
+<p>You must have <code>npm</code> and Chrome installed. The tests use the <code>npm</code>
211
+utility Karma for actually running the tests. This target will run
212
+both client and server tests.</p>
213
+
214
+<h2>Dev Cards</h2>
215
+
216
+<p>The source is in <code>src/cards</code>. Remember to add devcard files here, and add
217
+a require the for new card namespace to the <code>cards.cljs</code> file.</p>
218
+
219
+<h2>I18N</h2>
220
+
221
+<p>The i18n process is codified into a Makefile. The target extracts strings from
222
+the source (which must build the js, and run xgettext on it, which you must
223
+have installed, perhaps from brew):</p>
224
+
225
+<p><code>
226
+make i18n-extract
227
+</code></p>
228
+
229
+<p>and gives you instructions on generating translations.</p>
230
+
231
+<p>The translations (po files) are then places into <code>resources/i18n</code> and will
232
+be automatically served to the client when the client changes to that locale.</p>
233
+
234
+<p>See the Developer's Guide for more details.</p>
235
+
236
+<h2>Standalone Runnable Jar (Production, with advanced optimized client js)</h2>
237
+
238
+<p><code>
239
+lein uberjar
240
+java -jar target/fulcro_cljdoc.jar
241
+</code></p>
242
+
243
+</body>
244
+</html>
0 245
new file mode 100644
... ...
@@ -0,0 +1,225 @@
1
+# The Project
2
+
3
+The main project source is in `src/main`.
4
+
5
+```
6
+.
7
+├── Makefile           ; i18n extract/generate and CI test running
8
+├── karma.conf.js      ; CI Runner config
9
+├── package.json       ; NPM modules
10
+├── project.clj        ; Leiningen project file
11
+├── resources
12
+|   ├── i18n               ; directory for i18n extract/translate/serve
13
+|   │   ├── es.po          ; spanish translations
14
+|   │   └── messages.pot   ; extracted strings (template)
15
+|   └── public
16
+│       ├── cards.html    ; page for mounting dev cards
17
+│       ├── index.html    ; main app index page
18
+│       └── js
19
+│           └── test
20
+│               └── index.html ; custom test page for running tests in dev mode
21
+├── shadow-cljs.edn    ; Shadow-cljs configuration file. CLJS builds.
22
+└── src
23
+    ├── cards
24
+    │   └── fulcro_cljdoc
25
+    │       ├── cards.cljs   ; Main for devcards
26
+    │       └── intro.cljs   ; A sample devcards file
27
+    ├── dev
28
+    │   └── user.clj         ; Functions for running web server in development mode
29
+    ├── main
30
+    │   ├── config           ; configuration files for web server
31
+    │   │   ├── defaults.edn
32
+    │   │   ├── dev.edn
33
+    │   │   └── prod.edn
34
+    │   └── fulcro_cljdoc
35
+    │       ├── api
36
+    │       │   ├── mutations.clj          ; server-side implementation of mutations
37
+    │       │   ├── mutations.cljs         ; client-side implementation of mutations
38
+    │       │   └── read.clj               ; server-side reads
39
+    │       ├── client.cljs                ; file that creates the Fulcro client
40
+    │       ├── development-preload.cljs   ; code to run in development mode before anything else
41
+    │       ├── server.clj                 ; file that creates the web server
42
+    │       ├── server_main.clj            ; production server entry point
43
+    │       └── ui
44
+    │           ├── components.cljc  ; Sample reusable component
45
+    │           └── root.cljc        ; Main UI
46
+    └── test
47
+        └── fulcro_cljdoc
48
+            ├── client_test_main.cljs  ; setup for dev mode tests
49
+            └── sample_spec.cljc       ; a sample spec in fulcro-spec
50
+```
51
+
52
+## Setting Up
53
+
54
+The shadow-cljs compiler uses all cljsjs and NPM js dependencies through
55
+NPM. If you use a library that is in cljsjs you will also have to add
56
+it to your `package.json`.
57
+
58
+You also cannot compile this project until you install the ones it
59
+depends on already:
60
+
61
+```
62
+$ npm install
63
+```
64
+
65
+or if you prefer `yarn`:
66
+
67
+```
68
+$ yarn install
69
+```
70
+
71
+Adding NPM Javascript libraries is as simple as adding them to your
72
+`package.json` file and requiring them! See the
73
+[the Shadow-cljs User's Guide](https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript)
74
+for more information.
75
+
76
+## Development Mode
77
+
78
+Shadow-cljs handles the client-side development build. The file
79
+`src/main/fulcro_cljdoc/client.cljs` contains the code to start and refresh
80
+the client for hot code reload.
81
+
82
+Running all client development builds:
83
+
84
+```
85
+$ npx shadow-cljs watch main cards test
86
+...
87
+shadow-cljs - HTTP server for ":main" available at http://localhost:8020
88
+shadow-cljs - HTTP server for ":test" available at http://localhost:8022
89
+shadow-cljs - HTTP server for ":cards" available at http://localhost:8023
90
+...
91
+```
92
+
93
+The compiler will detect which builds are affected by a change and will minimize
94
+incremental build time.
95
+
96
+NOTE: The server wil start a web server for all three builds (on different ports).
97
+You typically do not need the one for main because you'll be running your
98
+own server, but it is there in case you are only going to be writing
99
+a client-side app that has no server API.
100
+
101
+The URLs for working with cards and tests are:
102
+
103
+- Cards: [http://localhost:8023/cards.html](http://localhost:8023/cards.html)
104
+- Tests: [http://localhost:8022/index.html](http://localhost:8022/index.html)
105
+- Main: [http://localhost:8020/index.html](http://localhost:8020/index.html) (NO API SERVER)
106
+
107
+See the server section below for working on the full-stack app itself.
108
+
109
+### Client REPL
110
+
111
+The shadow-cljs compiler starts an nREPL. It is configured to start on
112
+port 9000 (in `shadow-cljs.edn`).
113
+
114
+In IntelliJ, simply add a *remote* Clojure REPL configuration with
115
+host `localhost` and port `9000`.
116
+
117
+If you're using CIDER
118
+see [the Shadow-cljs User's Guide](https://shadow-cljs.github.io/docs/UsersGuide.html#_cider)
119
+for more information.
120
+
121
+### The API Server
122
+
123
+The shadow-cljs compiler starts a server for serving development files,
124
+but you usually will not use it. Instead you'll start your own server
125
+that can also serve your application's API.
126
+
127
+Start a clj REPL in IntelliJ, or from the command line:
128
+
129
+```bash
130
+$ lein repl
131
+user=> (go)
132
+...
133
+user=> (restart) ; stop, reload server code, and go again
134
+user=> (tools-ns/refresh) ; retry code reload if hot server reload fails
135
+```
136
+
137
+The URL to work on your application is then
138
+[http://localhost:3000](http://localhost:3000).
139
+
140
+Hot code reload, preloads, and such are all coded into the javascript,
141
+so serving the files from the alternate server is fine.
142
+
143
+### Preloads
144
+
145
+There is a preload file that is used on the development build of the
146
+application `fulcro-cljdoc.development-preload`. You can add code here that
147
+you want to execute before the application initializes in development
148
+mode.
149
+
150
+### Fulcro Inspect
151
+
152
+The Fulcro inspect will preload on the development build of the main
153
+application and cards. You can activate it by pressing CTRL-F while in
154
+the application. If you need a different keyboard shortcut (e.g. for
155
+Windows) see the docs on github.
156
+
157
+## Tests
158
+
159
+Tests are in `src/test`
160
+
161
+```
162
+src/test
163
+└── fulcro_cljdoc
164
+    ├── client_test_main.cljs     entry point for dev-mode client tests
165
+    └── sample_spec.cljs          spec runnable by client and server.
166
+```
167
+
168
+### Server tests:
169
+
170
+Interacting with tests resuts via a browser (also allows test focusing, etc):
171
+
172
+From a CLJ REPL:
173
+
174
+```
175
+user=> (start-server-tests) ; start a server on port 8888 showing the server tests
176
+```
177
+
178
+then navigate to [http://localhost:8888/fulcro-spec-server-tests.html](http://localhost:8888/fulcro-spec-server-tests.html)
179
+
180
+If you'd instead like to see them pop up over and over again in a terminal:
181
+
182
+```
183
+lein test-refresh
184
+```
185
+
186
+### CI Tests
187
+
188
+Use the Makefile target `tests`:
189
+
190
+```
191
+make test
192
+```
193
+
194
+You must have `npm` and Chrome installed. The tests use the `npm`
195
+utility Karma for actually running the tests. This target will run
196
+both client and server tests.
197
+
198
+## Dev Cards
199
+
200
+The source is in `src/cards`. Remember to add devcard files here, and add
201
+a require the for new card namespace to the `cards.cljs` file.
202
+
203
+## I18N
204
+
205
+The i18n process is codified into a Makefile. The target extracts strings from
206
+the source (which must build the js, and run xgettext on it, which you must
207
+have installed, perhaps from brew):
208
+
209
+```
210
+make i18n-extract
211
+```
212
+
213
+and gives you instructions on generating translations.
214
+
215
+The translations (po files) are then places into `resources/i18n` and will
216
+be automatically served to the client when the client changes to that locale.
217
+
218
+See the Developer's Guide for more details.
219
+
220
+## Standalone Runnable Jar (Production, with advanced optimized client js)
221
+
222
+```
223
+lein uberjar
224
+java -jar target/fulcro_cljdoc.jar
225
+```
0 226
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+module.exports = function (config) {
2
+    config.set({
3
+        browsers: ['ChromeHeadless'],
4
+        // The directory where the output file lives
5
+        basePath: 'target',
6
+        // The file itself
7
+        files: ['ci.js'],
8
+        frameworks: ['cljs-test'],
9
+        plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
10
+        colors: true,
11
+        logLevel: config.LOG_INFO,
12
+        client: {
13
+            args: ["shadow.test.karma.init"],
14
+            singleRun: true
15
+        }
16
+    })
17
+};
0 18
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+{
2
+  "name": "fulcro-cljdoc",
3
+  "version": "1.0.0",
4
+  "description": "",
5
+  "private": true,
6
+  "dependencies": {},
7
+  "devDependencies": {
8
+    "intl-messageformat": "^2.2.0",
9
+    "karma": "^2.0.0",
10
+    "karma-chrome-launcher": "^2.2.0",
11
+    "karma-cljs-test": "^0.1.0",
12
+    "react": "^16.4.1",
13
+    "react-dom": "^16.4.1",
14
+    "shadow-cljs": "^2.4.22",
15
+    "showdown": "^1.8.6"
16
+  },
17
+  "author": "",
18
+  "license": "MIT"
19
+}
0 20
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+(defproject fulcro-cljdoc "0.1.0-SNAPSHOT"
2
+  :description "My Cool Project"
3
+  :license {:name "MIT" :url "https://opensource.org/licenses/MIT"}
4
+  :min-lein-version "2.7.0"
5
+
6
+  :dependencies [[org.clojure/clojure "1.9.0"]
7
+                 [thheller/shadow-cljs "2.6.7"]
8
+                 [fulcrologic/fulcro "2.6.3"]
9
+
10
+                                        ; Only required if you use server
11
+                 [http-kit "2.3.0"]
12
+                 [ring/ring-core "1.7.0" :exclusions [commons-codec]]
13
+                 [bk/ring-gzip "0.3.0"]
14
+                 [bidi "2.1.4"]
15
+
16
+                                        ; only required if you want to use this for tests
17
+                 [fulcrologic/fulcro-spec "2.1.1" :scope "test" :exclusions [fulcrologic/fulcro]]]
18
+
19
+  :uberjar-name "fulcro_cljdoc.jar"
20
+
21
+  :source-paths ["src/main"]
22
+  :test-paths ["src/test"]
23
+
24
+  :test-refresh {:report       fulcro-spec.reporters.terminal/fulcro-report
25
+                 :with-repl    true
26
+                 :changes-only true}
27
+
28
+  :profiles {:uberjar    {:main fulcro-cljdoc.server-main
29
+                          :aot :all
30
+                          :jar-exclusions [#"public/js/test" #"public/js/cards" #"public/cards.html"]
31
+                          :prep-tasks ["clean" ["clean"]
32
+                                       "compile" ["with-profile" "cljs" "run" "-m" "shadow.cljs.devtools.cli" "release" "main"]]}
33
+             :production {}
34
+             :cljs       {:source-paths ["src/main" "src/test" "src/cards"]
35
+                          :dependencies [[binaryage/devtools "0.9.10"]
36
+                                         [org.clojure/core.async "0.4.474"]
37
+                                         [fulcrologic/fulcro-inspect "2.2.2" :exclusions [fulcrologic/fulcro-css]]
38
+                                         [cljsjs/marked "0.3.5-1"]
39
+                                         [devcards "0.2.6" :exclusions [cljsjs/react cljsjs/react-dom]]]
40
+                          :repl-options
41
+                          {:init-ns shadow.user
42
+                           :nrepl-middleware
43
+                           [shadow.cljs.devtools.server.nrepl/cljs-load-file
44
+                            shadow.cljs.devtools.server.nrepl/cljs-eval
45
+                            shadow.cljs.devtools.server.nrepl/cljs-select]}}
46
+             :dev        [:cljs
47
+                          {:source-paths ["src/dev" "src/main" "src/cards"]
48
+                           :jvm-opts     ["-XX:-OmitStackTraceInFastThrow" "-client" "-XX:+TieredCompilation" "-XX:TieredStopAtLevel=1"
49
+                                          "-Xmx1g" "-XX:+UseConcMarkSweepGC" "-XX:+CMSClassUnloadingEnabled" "-Xverify:none"]
50
+
51
+                           :plugins      [[com.jakemccrary/lein-test-refresh "0.21.1"]]
52
+
53
+                           :dependencies [[org.clojure/tools.namespace "0.3.0-alpha4"]
54
+                                          [org.clojure/tools.nrepl "0.2.13"]
55
+                                          [com.cemerick/piggieback "0.2.2"]]
56
+                           :repl-options {:init-ns          user
57
+                                          :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}]})
0 58
new file mode 100644
... ...
@@ -0,0 +1,35 @@
1
+# Spanish translations for PACKAGE package.
2
+# Copyright (C) 2018 THE PACKAGE'S COPYRIGHT HOLDER
3
+# This file is distributed under the same license as the PACKAGE package.
4
+# Automatically generated, 2018.
5
+#
6
+msgid ""
7
+msgstr ""
8
+"Project-Id-Version: \n"
9
+"Report-Msgid-Bugs-To: \n"
10
+"POT-Creation-Date: 2018-03-05 18:16-0800\n"
11
+"PO-Revision-Date: 2018-03-05 18:22-0800\n"
12
+"Last-Translator: Automatically generated\n"
13
+"Language-Team: none\n"
14
+"Language: es\n"
15
+"MIME-Version: 1.0\n"
16
+"Content-Type: text/plain; charset=UTF-8\n"
17
+"Content-Transfer-Encoding: 8bit\n"
18
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+"X-Generator: Poedit 2.0.6\n"
20
+
21
+#: resources/i18n/i18n.js:34277
22
+msgid "(Deep Thought Hums...)"
23
+msgstr "(Deep Thought tararea…)"
24
+
25
+#: resources/i18n/i18n.js:34277
26
+msgid "The meaning of {what} is {meaning}."
27
+msgstr "El significado de {what} es {meaning}."
28
+
29
+#: resources/i18n/i18n.js:34278
30
+msgid "Ask Deep Thought."
31
+msgstr "Pregunta a Deep Thought."
32
+
33
+#: resources/i18n/i18n.js:34303
34
+msgid "Ping the server!"
35
+msgstr "¡Ping el servidor!"
0 36
new file mode 100644
... ...
@@ -0,0 +1,34 @@
1
+# SOME DESCRIPTIVE TITLE.
2
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+# This file is distributed under the same license as the PACKAGE package.
4
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+#
6
+#, fuzzy
7
+msgid ""
8
+msgstr ""
9
+"Project-Id-Version: PACKAGE VERSION\n"
10
+"Report-Msgid-Bugs-To: \n"
11
+"POT-Creation-Date: 2017-09-11 23:11-0700\n"
12
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+"Language-Team: LANGUAGE <LL@li.org>\n"
15
+"Language: \n"
16
+"MIME-Version: 1.0\n"
17
+"Content-Type: text/plain; charset=CHARSET\n"
18
+"Content-Transfer-Encoding: 8bit\n"
19
+
20
+#: i18n/i18n.js:35290
21
+msgid "(Deep Thought Hums)"
22
+msgstr ""
23
+
24
+#: i18n/i18n.js:35294
25
+msgid "Ping the server!"
26
+msgstr ""
27
+
28
+#: i18n/i18n.js:35294
29
+msgid "The meaning of life is {meaning}."
30
+msgstr ""
31
+
32
+#: i18n/i18n.js:35296
33
+msgid "Ask Deep Thought server about the meaning of life."
34
+msgstr ""
0 35
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html>
3
+    <head lang="en">
4
+        <meta charset="UTF-8">
5
+        <title>Devcards</title>
6
+    </head>
7
+    <body>
8
+        <script src="js/cards/main.js"></script>
9
+    </body>
10
+</html>
0 11
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+<!DOCTYPE html>
2
+<html>
3
+    <head lang="en">
4
+        <meta charset="UTF-8">
5
+        <title>Home</title>
6
+        <style id="reset">
7
+          html {box-sizing: border-box; font-size: 16px;}
8
+          *, *:before, *:after {box-sizing: inherit;}
9
+          body, h1, h2, h3, h4, h5, h6, p, ol, ul {margin: 0; padding: 0; font-weight: normal;}
10
+          ol, ul {list-style: none;}
11
+          img {max-width: 100%; height: auto;}
12
+        </style>
13
+    </head>
14
+    <body>
15
+        <div id="app"></div>
16
+        <script src="js/main/app.js"></script>
17
+        <script>fulcro_cljdoc.client.init();</script>
18
+    </body>
19
+</html>
0 20
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+    <link href="css/fulcro-spec-styles.css" rel="stylesheet" type="text/css">
5
+    <link href="css/fulcro-ui.css" rel="stylesheet" type="text/css">
6
+    <link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAIElEQVQ4T2NMS0v7z0ABYBw1gGE0DBhGwwCYh4ZBOgAAcQUjIUXh8RYAAAAASUVORK5CYII="/>
7
+    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
8
+</head>
9
+<body>
10
+<div id="fulcro-spec-report">Loading "js/test/test.js", if you need to name that something else (conflicts?) make your own test html file</div>
11
+<script src="js/test.js" type="text/javascript"></script>
12
+</body>
13
+</html>
14
+
0 15
new file mode 100644
... ...
@@ -0,0 +1,44 @@
1
+{:lein   {:profile "cljs"}
2
+ :nrepl  {:port 9000}
3
+ :builds {:main     {:target     :browser
4
+                     :output-dir "resources/public/js/main"
5
+                     :asset-path "/js/main"
6
+
7
+                     :modules    {:app {:entries [fulcro-cljdoc.client]}}
8
+
9
+                     :devtools   {:after-load fulcro-cljdoc.client/start
10
+                                              :preloads [fulcro.inspect.preload fulcro-cljdoc.development-preload]
11
+                                              :http-root "resources/public"
12
+                                              :http-port 8020}}
13
+
14
+          :i18n     {:target           :browser
15
+                     :output-dir       "target/i18n"
16
+                     :asset-path       "/"
17
+                     :modules          {:i18n {:entries [fulcro-cljdoc.client]}}
18
+                     :compiler-options {:optimization :whitespace}}
19
+
20
+          :test     {:target           :browser-test
21
+                     :test-dir         "resources/public/js/test"
22
+                     :ns-regexp        "-spec$"
23
+                     :compiler-options {:static-fns false} ; required for mocking to work
24
+                     :runner-ns        fulcro-cljdoc.client-test-main
25
+                                       :devtools {:http-port          8022
26
+                                                  :http-resource-root "public"
27
+                                                  :http-root          "resources/public/js/test"}}
28
+
29
+          :ci-tests {:target           :karma
30
+                     :js-options       {:js-provider :shadow}
31
+                     :compiler-options {:static-fns false} ; required for mocking to work
32
+                     :output-to        "target/ci.js"
33
+                     :ns-regexp        "-spec$"}
34
+
35
+          :cards    {:target           :browser
36
+                     :output-dir       "resources/public/js/cards"
37
+                     :asset-path       "/js/cards"
38
+                     :compiler-options {:devcards true}
39
+                     :modules          {:main
40
+                                        {:entries [fulcro-cljdoc.cards]}}
41
+                     :devtools         {:after-load fulcro-cljdoc.cards/refresh
42
+                                                    :preloads [fulcro.inspect.preload fulcro-cljdoc.development-preload]
43
+                                                    :http-root "resources/public"
44
+                                                    :http-port 8023}}}}
0 45
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+(ns fulcro-cljdoc.cards
2
+  (:require [fulcro-cljdoc.intro]
3
+            devcards.core))
4
+
5
+(devcards.core/start-devcard-ui!)
6
+
7
+(defn refresh [] )
0 8
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+(ns fulcro-cljdoc.intro
2
+  (:require [devcards.core :as rc :refer-macros [defcard]]
3
+            [fulcro-cljdoc.ui.components :as comp]))
4
+
5
+(defcard SVGPlaceholder
6
+  "# SVG Placeholder"
7
+  (comp/ui-placeholder {:w 200 :h 200}))
0 8
new file mode 100644
... ...
@@ -0,0 +1,81 @@
1
+(ns user
2
+  (:require
3
+   [clojure.tools.namespace.repl :as tools-ns :refer [set-refresh-dirs]]
4
+   [com.stuartsierra.component :as component]
5
+   [fulcro-spec.suite :as suite]
6
+   [fulcro-spec.selectors :as sel]
7
+   [shadow.cljs.devtools.server :as shadow-server]
8
+   [shadow.cljs.devtools.api :as shadow-api]
9
+   fulcro-cljdoc.server))
10
+;; === SHADOW REPL ===
11
+
12
+(comment
13
+  ;; evaluate any one of these in your nREPL to
14
+  ;; choose a (running and connected) shadown-CLJS nREPL
15
+  (do
16
+    (shadow-api/nrepl-select :main))
17
+
18
+
19
+  (do
20
+    (shadow-api/nrepl-select :test))
21
+
22
+  (do
23
+    (shadow-api/nrepl-select :cards)))
24
+
25
+
26
+;; ==================== SERVER ====================
27
+
28
+(set-refresh-dirs "src/dev" "src/main" "src/test")
29
+
30
+(defn started? [sys]
31
+  (-> sys :config :value))
32
+
33
+(defonce system (atom nil))
34
+
35
+(defn- refresh [& args]
36
+  {:pre [(not @system)]}
37
+  (apply tools-ns/refresh args))
38
+
39
+(defn- init []
40
+  {:pre [(not (started? @system))]}
41
+  (when-let [new-system (fulcro-cljdoc.server/build-server {:config "config/dev.edn"})]
42
+    (reset! system new-system)))
43
+
44
+(defn- start []
45
+  {:pre [@system (not (started? @system))]}
46
+  (swap! system component/start))
47
+
48
+(defn stop
49
+  "Stop the server."
50
+  []
51
+  (when (started? @system)
52
+    (swap! system component/stop))
53
+  (reset! system nil))
54
+
55
+(defn go
56
+  "Initialize the server and start it."
57
+  []
58
+  {:pre [(not @system) (not (started? @system))]}
59
+  (init)
60
+  (start))
61
+
62
+(defn restart
63
+  "Stop, refresh, and restart the server."
64
+  []
65
+  (stop)
66
+  (refresh :after 'user/go))
67
+
68
+; Run (start-server-tests) in a REPL to start a runner that can render results in a browser
69
+(suite/def-test-suite start-server-tests
70
+  {:config       {:port 8888}
71
+   :test-paths   ["src/test"]
72
+   :source-paths ["src/main"]}
73
+  {:available #{:focused :unit :integration}
74
+   :default   #{::sel/none :focused :unit}})
75
+
76
+(defn do-all-the-things! []
77
+  (go)
78
+  (shadow-server/start!)
79
+  (shadow-api/watch :main)
80
+  (shadow-api/watch :cards)
81
+  (shadow-api/watch :test))
0 82
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+{:port 3000}
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+{:port 3000}
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+{:port 8080}
0 2
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+(ns fulcro-cljdoc.api.mutations
2
+  (:require
3
+    [taoensso.timbre :as timbre]
4
+    [fulcro.server :refer [defmutation]]))
5
+
6
+;; Place your server mutations here
7
+
0 8
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+(ns fulcro-cljdoc.api.mutations
2
+  (:require
3
+    [fulcro.client.mutations :refer [defmutation]]
4
+    [fulcro.client.logging :as log]))
5
+
6
+;; Place your client mutations here
7
+
0 8
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+(ns fulcro-cljdoc.api.read
2
+  (:require
3
+    [fulcro.server :refer [defquery-entity defquery-root]]
4
+    [fulcro.i18n :as i18n]
5
+    [taoensso.timbre :as timbre]))
6
+
7
+;; Server queries can go here
8
+
0 9
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+(ns fulcro-cljdoc.client
2
+  (:require [fulcro.client :as fc]
3
+            [fulcro-cljdoc.ui.root :as root]
4
+            [fulcro.i18n :as i18n]
5
+            ["intl-messageformat" :as IntlMessageFormat]))
6
+
7
+(defn message-format [{:keys [::i18n/localized-format-string ::i18n/locale ::i18n/format-options]}]
8
+  (let [locale-str (name locale)
9
+        formatter  (IntlMessageFormat. localized-format-string locale-str)]
10
+    (.format formatter (clj->js format-options))))
11
+
12
+(defonce app (atom nil))
13
+
14
+(defn mount []
15
+  (reset! app (fc/mount @app root/Root "app")))
16
+
17
+(defn start []
18
+  (mount))
19
+
20
+(defn ^:export init []
21
+  (reset! app (fc/new-fulcro-client
22
+                     :reconciler-options {:shared    {::i18n/message-formatter message-format}
23
+                                          :render-mode :keyframe ; Good for beginners. Remove to optimize UI refresh
24
+                                          :shared-fn ::i18n/current-locale}))
25
+  (start))
0 26
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+(ns fulcro-cljdoc.development-preload
2
+  (:require [fulcro.logging :as log]))
3
+
4
+; Add code to this file that should run when the initial application is loaded in development mode.
5
+; shadow-cljs already enables console print and plugs in devtools if they are on the classpath,
6
+
7
+(js/console.log "Turning logging to :all (in fulcro-cljdoc.development-preload)")
8
+(log/set-level! :all)
0 9
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+(ns fulcro-cljdoc.server
2
+  (:require
3
+    [fulcro.easy-server :refer [make-fulcro-server]]
4
+    ; MUST require these, or you won't get them installed.
5
+    [fulcro-cljdoc.api.read]
6
+    [fulcro-cljdoc.api.mutations]))
7
+
8
+(defn build-server
9
+  [{:keys [config] :or {config "config/dev.edn"}}]
10
+  (make-fulcro-server
11
+    :parser-injections #{:config}
12
+    :config-path config))
13
+
14
+
15
+
0 16
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+(ns fulcro-cljdoc.server-main
2
+  (:require
3
+    [com.stuartsierra.component :as component]
4
+    [fulcro.server :as c]
5
+    [taoensso.timbre :as timbre]
6
+    [fulcro-cljdoc.server :refer [build-server]])
7
+  (:gen-class))
8
+
9
+; It is recommended that your production config be on the server itself in a directory. We have placed a
10
+; sample on the classpath, which is also legal:
11
+(def config-path "config/prod.edn")
12
+
13
+;; This is a separate file for the uberjar only. We control the server in dev mode from src/dev/user.clj
14
+(defn -main [& args]
15
+  (let [system (build-server {:config config-path})]
16
+    (component/start system)))
0 17
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+(ns fulcro-cljdoc.ui.components
2
+  (:require
3
+    [fulcro.client.primitives :as prim :refer [defsc]]
4
+    #?(:cljs [fulcro.client.dom :as dom] :clj [fulcro.client.dom-server :as dom])))
5
+
6
+;; A good place to put reusable components
7
+(defsc PlaceholderImage [this {:keys [w h label]}]
8
+  (let [label (or label (str w "x" h))]
9
+    (dom/svg {:width w :height h}
10
+      (dom/rect {:width w :height h :style {:fill        "rgb(200,200,200)"
11
+                                            :strokeWidth 2
12
+                                            :stroke      "black"}})
13
+      (dom/text {:textAnchor "middle" :x (/ w 2) :y (/ h 2)} label))))
14
+
15
+(def ui-placeholder (prim/factory PlaceholderImage))
0 16
new file mode 100644
... ...
@@ -0,0 +1,63 @@
1
+(ns fulcro-cljdoc.ui.root
2
+  (:require
3
+   [fulcro.client.mutations :as m]
4
+   [garden.core :as g]
5
+   [fulcro-css.css :as css]
6
+   [fulcro.client.util :as util]
7
+   [fulcro.client.data-fetch :as df]
8
+   #?(:cljs [fulcro.client.localized-dom :as dom] :clj [fulcro.client.localized-dom-server :as dom])
9
+   [fulcro-cljdoc.api.mutations :as api]
10
+   [fulcro.client.primitives :as prim :refer [defsc]]
11
+   [fulcro.i18n :as i18n :refer [tr trf]]))
12
+
13
+(defn ensure-seq [m-seq]
14
+  "make sure that m-seq is a seq, otherwise seqify it"
15
+  (if (seq? m-seq)
16
+    m-seq
17
+    [m-seq]))
18
+
19
+(defsc Sidebar [this {items :items}]
20
+  (dom/ul (map #(apply (comp dom/li
21
+                             dom/a)
22
+                       %)
23
+               (ensure-seq items))))
24
+(def ui-sidebar (prim/factory Sidebar))
25
+
26
+;; The main UI of your application
27
+(defsc Layout [this props]
28
+  {:css [[:.container {:display :flex}]
29
+         [:main :.sidebar
30
+          {:padding "1em 1.5em"
31
+           :vertical-scroll :auto}]
32
+         [:main     {:background "rgb(63,63,63)"
33
+                     :color "rgb(197,199,168)"
34
+                     :height "100vh"
35
+                     :flex-grow 1}]
36
+         [:.sidebar {:display :block
37
+                     :color "rgb(63,63,63)"
38
+                     :background "rgb(197,199,168)"
39
+                     :border-right "double 5px #88a"
40
+                     :height "100vh"
41
+                     :min-width "25vw"
42
+                     :max-width "33vw"}]]}
43
+  (let [children (prim/children props)]
44
+    (let [names (map #(do [{:href "#"} (name %)])
45
+                     (keys (ns-publics 'fulcro-cljdoc.ui.root)))
46
+          out (dom/div :.container
47
+                       (dom/nav :.sidebar (ui-sidebar {:items names}))
48
+                       (dom/main 
49
+                        children))]
50
+      out)))
51
+
52
+(def layout (prim/factory Layout))
53
+
54
+(defsc Root [this props]
55
+  {:css-include [Layout]}
56
+  (println "hi")
57
+  ;; (css/upsert-css "root-css" Root)
58
+  (layout 
59
+   (ui-sidebar)
60
+   (dom/div "hi")))
61
+
62
+#?(:cljs (css/upsert-css "root-css" Layout))
63
+;; (dom/style {:dangerouslySetInnerHTML {:__html (g/css (css/get-css Root))}})
0 64
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+(ns ^:dev/always fulcro-cljdoc.client-test-main
2
+  (:require [fulcro-spec.selectors :as sel]
3
+            [fulcro-spec.suite :as suite]))
4
+
5
+(suite/def-test-suite client-tests {:ns-regex #"fulcro-cljdoc.*-spec"}
6
+  {:default   #{::sel/none :focused}
7
+   :available #{:focused}})
8
+
9
+(client-tests)
0 10
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+(ns fulcro-cljdoc.sample-spec
2
+  (:require
3
+    [fulcro-spec.core :refer [specification provided behavior assertions]]))
4
+
5
+; Tests for both client and server
6
+(specification "Sample Spec"
7
+  (behavior "addition computes addition correctly"
8
+    (assertions
9
+      "with positive integers"
10
+      (+ 1 5 3) => 9
11
+      "with negative integers"
12
+      (+ -1 -3 -5) => -9
13
+      "with a mix of signed integers"
14
+      (+ +5 -3) => 2)))