-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
container added + demo project added
- Loading branch information
awb99
committed
Nov 4, 2024
1 parent
31d564d
commit 4d88de7
Showing
19 changed files
with
245 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# dali [](https://github.com/pink-gorilla/dali/actions?workflow=CI)[](https://clojars.org/org.pinkgorilla/dali) | ||
|
||
|
||
|
||
|
||
# demo | ||
|
||
cd demo | ||
clj -X:npm-install | ||
clj -X:demo | ||
|
||
port 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{as-> [[:inner 0]] | ||
with-debug-bindings [[:inner 0]] | ||
merge-meta [[:inner 0]] | ||
try-if-let [[:block 1]]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{:paths ["src" | ||
"resources" | ||
"target/webly" | ||
".data" | ||
] | ||
|
||
:deps {org.clojure/clojure {:mvn/version "1.11.1"} | ||
org.pinkgorilla/clj-service {:mvn/version "0.3.20"} | ||
org.pinkgorilla/webly {:mvn/version "0.7.703"} ; build tool | ||
org.pinkgorilla/goldly {:mvn/version "0.7.683"} | ||
org.pinkgorilla/ui-tailwind {:mvn/version "0.1.8"} ; tailwind css classes | ||
org.pinkgorilla/ui-repl {:mvn/version "0.1.110"} | ||
; org.pinkgorilla/ui-input {:mvn/version "0.2.62"} | ||
;; this project | ||
org.pinkgorilla/dali {:local/root "../" :deps/manifest :deps} | ||
} | ||
|
||
:aliases {;; WATCH | ||
:npm-install | ||
{:exec-fn webly.app.app/webly-build | ||
:config {} | ||
:exec-args {:profile "npm-install"}} | ||
:demo | ||
{:exec-fn modular.system/start! | ||
:exec-args {;:profile "jetty" | ||
:profile "watch" | ||
:config {} | ||
:services "demo-services.edn"}} | ||
|
||
;; BUILD / SERVE | ||
|
||
:compile {:exec-fn webly.app.app/webly-build | ||
:config {} | ||
:exec-args {:profile "compile"}} | ||
|
||
|
||
:release-adv {:exec-fn webly.app.app/webly-build | ||
:config {} | ||
:exec-args {:profile "release-adv"}} | ||
|
||
:jetty | ||
{:exec-fn modular.system/start! | ||
:exec-args {:profile "jetty" | ||
:config {} | ||
:services "demo-services.edn"}} | ||
} | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{:modular (modular.system/modular-env) ; {:profile "jetty" :config ["demo.edn" "secrets.edn"]} | ||
;:secrets #include "secrets.edn" ;; externalised and usually "mounted" as a docker/kubernetes secret | ||
:components | ||
{:config {:start (modular.config/load-config! (:config #ref [:modular]))} | ||
|
||
:exts {:start (extension/discover)} | ||
|
||
:timbre {:start (modular.log/timbre-config! | ||
(:timbre/clj (deref (clip/ref :config))))} | ||
|
||
; empty map means no users are configured, so always permissioned. | ||
:permission {:start (modular.permission.core/start-permissions {})} | ||
|
||
:clj-service {:start (clj-service.core/start-clj-services | ||
(clip/ref :permission) | ||
(clip/ref :exts))} | ||
|
||
|
||
:webly {:start (webly.app.app/start-webly | ||
(clip/ref :exts) | ||
(deref (clip/ref :config)) | ||
(:profile #ref [:modular])) | ||
:stop (webly.app.app/stop-webly this)} | ||
|
||
:nrepl {:start (nrepl.server/start-server :bind "0.0.0.0" :port 9100) | ||
:stop (.close this)} | ||
|
||
; | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{:name "demo" | ||
;:lazy true ; must be true, since it depends on techml-dataset-cljs | ||
;:depends-on #{:dali} | ||
:cljs-routes {"" demo.page.saying/page | ||
|
||
} | ||
|
||
:clj-services {:name "demo" | ||
:permission nil | ||
:symbols [demo.service.saying/saying | ||
]} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns demo.page.saying | ||
(:require | ||
[reagent.core :as r] | ||
[dali.viewer :refer [viewer2]] | ||
[dali.cljviewer :refer [clj-viewer]] | ||
[dali.container :refer [container-dimension]])) | ||
|
||
(defonce window-a (r/atom nil)) | ||
|
||
(defn page [_] | ||
[:div.h-screen.w-screen.bg-blue-100 | ||
[clj-viewer {:fun 'demo.service.saying/saying | ||
:args [{:id 5}]}] | ||
|
||
[container-dimension | ||
{:window-a window-a}] | ||
|
||
(when @window-a | ||
[clj-viewer {:fun 'demo.service.saying/saying | ||
:args [(assoc {:id 3} :window @window-a)]}])]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(ns demo.service.saying | ||
(:require | ||
[dali.plot.hiccup :refer [hiccup]])) | ||
|
||
(defn saying [{:keys [id] :as opts}] | ||
(println "serving saying id: " id " opts: " opts) | ||
(let [s (case id | ||
0 "Peace to the world" | ||
1 "The hottentotten are here" | ||
2 "The sky is always blue" | ||
3 "Biene Maya and Willy" | ||
4 "Quot erum demunstrandum" | ||
5 "The early bird catches the worm" | ||
6 "Six Six Six" | ||
7 "Seven Angles are here" | ||
8 "8 means infinity " | ||
9 "what is the secret of nine?" | ||
nil)] | ||
(hiccup [:div.bg-blue-300.w-100.h-100 | ||
[:h1 "Sayings Response"] | ||
[:p "You entered: " id] | ||
[:hr] | ||
(if s | ||
[:p.bg-green-500.p-5 s] | ||
[:p.bg-red-500.p-5 "This saying does not exist: " id])]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(ns dali.container | ||
(:require | ||
[reagent.core :as r] | ||
[reagent.dom])) | ||
|
||
; https://www.geeksforgeeks.org/how-to-get-the-elements-actual-width-and-height-in-javascript/ | ||
; https://react.dev/reference/react-dom/findDOMNode#alternatives | ||
|
||
(defn container-dimension | ||
[{:keys [window-a]}] | ||
(r/create-class | ||
{:display-name "container-dimension" | ||
:reagent-render (fn [] ;; remember to repeat parameters | ||
[:div.container-dimension | ||
{:style {:display "none"}}]) | ||
:component-did-mount (fn [this] ; oldprops oldstate snapshot | ||
(let [node (reagent.dom/dom-node this) | ||
parent (.-parentElement node) | ||
width (.-offsetWidth parent) | ||
height (.-offsetHeight parent) | ||
window {:width width :height height}] | ||
(when-not (= window @window-a) | ||
(println "window: " window) | ||
(reset! window-a window))))})) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
(:require | ||
[dali.spec :refer [create-dali-spec]])) | ||
|
||
|
||
(defn hiccup | ||
[h] | ||
(create-dali-spec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.