|
110 | 110 | (defn build-ui-reporter [{:as build-event :keys [stage]}]
|
111 | 111 | (when (= stage :init)
|
112 | 112 | (builder-ui/reset-build-state!)
|
113 |
| - ((resolve 'nextjournal.clerk/show!) (clojure.java.io/resource "nextjournal/clerk/builder_ui.clj")) |
| 113 | + ((resolve 'nextjournal.clerk/show!) (find-ns 'nextjournal.clerk.builder-ui)) |
114 | 114 | (when-let [{:keys [port]} (and (get-in build-event [:build-opts :browse]) @webserver/!server)]
|
115 | 115 | (browse/browse-url (str "http://localhost:" port))))
|
116 | 116 | (stdout-reporter build-event)
|
|
225 | 225 | (report-fn {:stage :ssr})
|
226 | 226 | (let [{duration :time-ms :keys [result]}
|
227 | 227 | (eval/time-ms (sh {:in (str "import '" (resource->url "/js/viewer.js") "';"
|
228 |
| - "console.log(nextjournal.clerk.static_app.ssr(" (pr-str (pr-str static-app-opts)) "))")} |
| 228 | + "console.log(nextjournal.clerk.sci_env.ssr(" (pr-str (pr-str static-app-opts)) "))")} |
229 | 229 | "node"
|
230 | 230 | "--abort-on-uncaught-exception"
|
231 | 231 | "--experimental-network-imports"
|
|
238 | 238 | (assoc static-app-opts :html out))
|
239 | 239 | (throw (ex-info (str "Clerk ssr! failed\n" out "\n" err) result)))))
|
240 | 240 |
|
| 241 | +(defn cleanup [build-opts] |
| 242 | + (select-keys build-opts |
| 243 | + [:bundle? :path->doc :path->url :current-path :resource->url :exclude-js? :index :html])) |
| 244 | + |
241 | 245 | (defn write-static-app!
|
242 | 246 | [opts docs]
|
243 | 247 | (let [{:as opts :keys [bundle? out-path browse? ssr?]} (process-build-opts opts)
|
|
248 | 252 | (when-not (fs/exists? (fs/parent index-html))
|
249 | 253 | (fs/create-dirs (fs/parent index-html)))
|
250 | 254 | (if bundle?
|
251 |
| - (spit index-html (view/->static-app static-app-opts)) |
| 255 | + (spit index-html (view/->html (cleanup static-app-opts))) |
252 | 256 | (doseq [[path doc] path->doc]
|
253 | 257 | (let [out-html (str out-path fs/file-separator (->> path (viewer/map-index opts) ->html-extension))]
|
254 | 258 | (fs/create-dirs (fs/parent out-html))
|
255 |
| - (spit out-html (view/->static-app (cond-> (assoc static-app-opts :path->doc (hash-map path doc) :current-path path) |
256 |
| - ssr? ssr!)))))) |
| 259 | + (spit out-html (view/->html (-> static-app-opts |
| 260 | + (assoc :path->doc (hash-map path doc) :current-path path) |
| 261 | + (cond-> ssr? ssr!) |
| 262 | + cleanup)))))) |
257 | 263 | (when browse?
|
258 | 264 | (browse/browse-url (-> index-html fs/absolutize .toString path-to-url-canonicalize)))
|
259 | 265 | {:docs docs
|
|
379 | 385 | (report-fn {:stage :done :duration duration})))
|
380 | 386 | (report-fn {:stage :finished :state state :duration duration :total-duration (eval/elapsed-ms start)})))
|
381 | 387 |
|
382 |
| -#_(build-static-app! {:paths clerk-docs :bundle? true}) |
383 |
| -#_(build-static-app! {:paths ["notebooks/index.clj" "notebooks/rule_30.clj" "notebooks/viewer_api.md"] :index "notebooks/index.clj"}) |
384 |
| -#_(build-static-app! {:paths ["index.clj" "notebooks/rule_30.clj" "notebooks/markdown.md"] :bundle? false :browse? false}) |
385 |
| -#_(build-static-app! {:paths ["notebooks/viewers/**"]}) |
386 |
| -#_(build-static-app! {:index "notebooks/rule_30.clj" :git/sha "bd85a3de12d34a0622eb5b94d82c9e73b95412d1" :git/url "https://github.com/nextjournal/clerk"}) |
387 |
| -#_ (reset! config/!resource->url @config/!asset-map) |
388 |
| -#_(swap! config/!resource->url dissoc "/css/viewer.css") |
389 |
| -#_(build-static-app! {:ssr? true |
| 388 | +(comment |
| 389 | + (build-static-app! {:paths clerk-docs :bundle? true}) |
| 390 | + (build-static-app! {:paths ["notebooks/index.clj" "notebooks/rule_30.clj" "notebooks/viewer_api.md"] :index "notebooks/index.clj"}) |
| 391 | + (build-static-app! {:paths ["index.clj" "notebooks/rule_30.clj" "notebooks/markdown.md"] :bundle? false :browse? false}) |
| 392 | + (build-static-app! {:paths ["notebooks/viewers/**"]}) |
| 393 | + (build-static-app! {:index "notebooks/rule_30.clj" :git/sha "bd85a3de12d34a0622eb5b94d82c9e73b95412d1" :git/url "https://github.com/nextjournal/clerk"}) |
| 394 | + (reset! config/!resource->url @config/!asset-map) |
| 395 | + (swap! config/!resource->url dissoc "/css/viewer.css") |
| 396 | + |
| 397 | + (build-static-app! {:ssr? true |
| 398 | + :exclude-js? true |
| 399 | + ;; test against cljs release `bb build:js` |
| 400 | + :resource->url {"/js/viewer.js" "./build/viewer.js"} |
| 401 | + :index "notebooks/rule_30.clj"}) |
| 402 | + |
| 403 | + (build-static-app! {:ssr? true |
390 | 404 | :compile-css? true
|
391 | 405 | ;; test against cljs release `bb build:js`
|
392 | 406 | :resource->url {"/js/viewer.js" "./build/viewer.js"}
|
393 | 407 | :index "notebooks/rule_30.clj"})
|
394 |
| -#_(fs/delete-tree "public/build") |
395 |
| -#_(build-static-app! {:compile-css? true |
| 408 | + (fs/delete-tree "public/build") |
| 409 | + (build-static-app! {:compile-css? true |
396 | 410 | :index "notebooks/rule_30.clj"
|
397 | 411 | :paths ["notebooks/hello.clj"
|
398 | 412 | "notebooks/markdown.md"]})
|
399 |
| -#_(build-static-app! {;; test against cljs release `bb build:js` |
| 413 | + (build-static-app! {;; test against cljs release `bb build:js` |
400 | 414 | :resource->url {"/js/viewer.js" "/viewer.js"}
|
401 | 415 | :paths ["notebooks/cherry.clj"]
|
402 | 416 | :out-path "build"})
|
403 |
| -#_(build-static-app! {:paths ["CHANGELOG.md" |
| 417 | + (build-static-app! {:paths ["CHANGELOG.md" |
404 | 418 | "notebooks/markdown.md"
|
405 |
| - "notebooks/viewers/image.clj" |
406 |
| - "notebooks/viewers/html.cj"] |
| 419 | + "notebooks/viewers/html.clj"] |
| 420 | + :bundle? true |
407 | 421 | :git/sha "d60f5417"
|
408 |
| - :git/url "https://github.com/nextjournal/clerk"}) |
| 422 | + :git/url "https://github.com/nextjournal/clerk"})) |
0 commit comments