From 733c8fb6724b1c133cb006b28d031c730f74acc5 Mon Sep 17 00:00:00 2001 From: awb99 Date: Wed, 3 Apr 2024 15:43:14 -0500 Subject: [PATCH] frontend move-out --- demo-webly/bb.edn | 14 ----- demo-webly/deps.edn | 9 ++-- .../META-INF/pink-gorilla/webly/meta.edn | 1 - demo-webly/src/demo/page/help.cljs | 36 ++++++------- demo-webly/src/demo/page/main/lazy.cljs | 2 +- demo-webly/src/demo/test.clj | 19 +++---- demo-webly/test/webly/css_test.clj | 38 ------------- demo-webly/test/webly/resource_test.clj | 4 +- demo-webly/test/webly/routes_test.clj | 4 +- frontend/README-analytics.md | 25 --------- frontend/deps.edn | 7 --- frontend/src/frontend/analytics/events.cljs | 30 ----------- .../src/frontend/analytics/google_tag.cljc | 47 ---------------- frontend/src/frontend/css/config.cljc | 31 ----------- frontend/src/frontend/css/dom.cljs | 53 ------------------- frontend/src/frontend/css/events.cljs | 34 ------------ frontend/src/frontend/css/helper.cljs | 15 ------ frontend/src/frontend/css/loading.cljs | 28 ---------- frontend/src/frontend/css/subscriptions.cljs | 34 ------------ frontend/src/frontend/css/view.cljs | 25 --------- frontend/src/frontend/tooltip.cljs | 38 ------------- script/copy-md.sh | 11 ---- script/copy_res.sh | 17 ------ script/curl-config.clj | 11 ---- {frontend => spa}/README-reagent.md | 0 spa/deps.edn | 8 +-- {frontend => spa}/src/frontend/helper.cljs | 0 spa/src/webly/spa/config.clj | 12 ++--- {script => src-unused/script}/webly.clj | 0 webly/deps.edn | 1 - webly/src/webly/module/build.clj | 4 +- 31 files changed, 46 insertions(+), 512 deletions(-) delete mode 100644 demo-webly/bb.edn delete mode 100644 demo-webly/resources/META-INF/pink-gorilla/webly/meta.edn delete mode 100644 demo-webly/test/webly/css_test.clj delete mode 100644 frontend/README-analytics.md delete mode 100644 frontend/deps.edn delete mode 100644 frontend/src/frontend/analytics/events.cljs delete mode 100644 frontend/src/frontend/analytics/google_tag.cljc delete mode 100644 frontend/src/frontend/css/config.cljc delete mode 100644 frontend/src/frontend/css/dom.cljs delete mode 100644 frontend/src/frontend/css/events.cljs delete mode 100644 frontend/src/frontend/css/helper.cljs delete mode 100644 frontend/src/frontend/css/loading.cljs delete mode 100644 frontend/src/frontend/css/subscriptions.cljs delete mode 100644 frontend/src/frontend/css/view.cljs delete mode 100644 frontend/src/frontend/tooltip.cljs delete mode 100755 script/copy-md.sh delete mode 100755 script/copy_res.sh delete mode 100644 script/curl-config.clj rename {frontend => spa}/README-reagent.md (100%) rename {frontend => spa}/src/frontend/helper.cljs (100%) rename {script => src-unused/script}/webly.clj (100%) diff --git a/demo-webly/bb.edn b/demo-webly/bb.edn deleted file mode 100644 index ba668a01..00000000 --- a/demo-webly/bb.edn +++ /dev/null @@ -1,14 +0,0 @@ -{:paths ["target/node_modules"] - :deps {babashka/fs {:mvn/version "0.1.1"} - org.babashka/http-server {:mvn/version "0.1.11"}} - - :tasks {:requires [[clojure.edn :as edn] - [babashka.http-server :as http-server] - [babashka.fs :as fs]] - - ; dev tools - httpserver (http-server/exec {:port 8080 - :dir "./target/static"}) - - ; - }} diff --git a/demo-webly/deps.edn b/demo-webly/deps.edn index 87570467..b71af009 100644 --- a/demo-webly/deps.edn +++ b/demo-webly/deps.edn @@ -3,8 +3,11 @@ "resources"] :deps {org.pinkgorilla/webly {:local/root "../webly" :deps/manifest :deps} ; lazy ui modules: - org.pinkgorilla/ui-highcharts {:mvn/version "0.0.26"} - org.pinkgorilla/ui-vega {:mvn/version "0.0.31"}} + org.pinkgorilla/ui-highcharts {:mvn/version "0.0.27"} + org.pinkgorilla/ui-vega {:mvn/version "0.0.31"} + org.pinkgorilla/ui-tailwind {:mvn/version "0.0.5"} + org.pinkgorilla/oauth2 {:mvn/version "0.0.25"} + } :aliases {:test-clj {:extra-paths ["src" "resources" @@ -26,7 +29,7 @@ ; BUILD BUNDLE (then exit) :webly {:extra-deps {org.pinkgorilla/ui-repl {:mvn/version "0.1.92"} ; http cors test - org.pinkgorilla/ui-tailwind {:mvn/version "0.0.5"}} + } :extra-paths ["src" "resources" "test" "test/resources"] :exec-fn webly.app.app/webly-build :exec-args {:config ["demo.edn" diff --git a/demo-webly/resources/META-INF/pink-gorilla/webly/meta.edn b/demo-webly/resources/META-INF/pink-gorilla/webly/meta.edn deleted file mode 100644 index 1aaf0058..00000000 --- a/demo-webly/resources/META-INF/pink-gorilla/webly/meta.edn +++ /dev/null @@ -1 +0,0 @@ -{:module-name "webly", :version "0.4.621"} \ No newline at end of file diff --git a/demo-webly/src/demo/page/help.cljs b/demo-webly/src/demo/page/help.cljs index badf2885..084e43ac 100644 --- a/demo-webly/src/demo/page/help.cljs +++ b/demo-webly/src/demo/page/help.cljs @@ -20,26 +20,24 @@ (def data-config (r/atom {:data nil})) (def firstt (r/atom true)) - (defn help [_route] (let [url-moon (str (get-resource-path) "demo/moon.jpg") - url-config (str (get-resource-path) "config.edn") - ] - [:div - [:h1 "webly help"] - (when @firstt - (reset! firstt false) - (get-json "http://api.open-notify.org/iss-now.json" data-iss [:data]) ;cors test - (get-json url-config data-config [:data]) - nil) - [:p [link-dispatch [:bidi/goto :demo/main] "main"]] - [:p "url config: " url-config] - [:h1 "help!"] - [:div.bg-blue-300 "iss data (cors test - there should be data coming!):" (pr-str @data-iss)] - [:div.bg-red-300 "config data:" (pr-str @data-config)] - - [:p "a moon image should show below. this is a test for webly resource handler."] - [:p "moon url: " url-moon] - [:img {:src url-moon }]])) + url-config (str (get-resource-path) "config.edn")] + [:div + [:h1 "webly help"] + (when @firstt + (reset! firstt false) + (get-json "http://api.open-notify.org/iss-now.json" data-iss [:data]) ;cors test + (get-json url-config data-config [:data]) + nil) + [:p [link-dispatch [:bidi/goto :demo/main] "main"]] + [:p "url config: " url-config] + [:h1 "help!"] + [:div.bg-blue-300 "iss data (cors test - there should be data coming!):" (pr-str @data-iss)] + [:div.bg-red-300 "config data:" (pr-str @data-config)] + + [:p "a moon image should show below. this is a test for webly resource handler."] + [:p "moon url: " url-moon] + [:img {:src url-moon}]])) diff --git a/demo-webly/src/demo/page/main/lazy.cljs b/demo-webly/src/demo/page/main/lazy.cljs index 17f10487..9e5225ff 100644 --- a/demo-webly/src/demo/page/main/lazy.cljs +++ b/demo-webly/src/demo/page/main/lazy.cljs @@ -34,7 +34,7 @@ (println "*** NS LOAD ERROR: err: " x))))) (defn load-namespace-highcharts [& _] - (let [rp (load-namespace 'ui.highcharts )] + (let [rp (load-namespace 'ui.highcharts)] (p/then rp (fn [r] (println "*** NS HIGHCHARTS LOAD SUCCESS: " r))) (p/catch rp (fn [x] diff --git a/demo-webly/src/demo/test.clj b/demo-webly/src/demo/test.clj index a7485085..28ce35c0 100644 --- a/demo-webly/src/demo/test.clj +++ b/demo-webly/src/demo/test.clj @@ -1,12 +1,11 @@ (ns demo.test (:require [extension :refer [discover write-service]] - [bidi.bidi :as bidi] + [bidi.bidi :as bidi] [webly.module.build :refer [create-modules shadow-module-config - create-modules - get-lazy-ns - ]])) + create-modules + get-lazy-ns]])) (defn test [& _] (println "creating modules..") @@ -16,23 +15,17 @@ (write-service exts :shadow-modules shadow-modules) (println "creating modules..done!"))) +(comment -(comment - (->> (bidi/tag :demo/job :wunderbar) - pr-str - ) - - - + pr-str) (def exts (discover)) (def modules (create-modules exts)) - (get-lazy-ns) (macroexpand (get-lazy-ns)) - + ; ) diff --git a/demo-webly/test/webly/css_test.clj b/demo-webly/test/webly/css_test.clj deleted file mode 100644 index 7770c723..00000000 --- a/demo-webly/test/webly/css_test.clj +++ /dev/null @@ -1,38 +0,0 @@ -(ns webly.css-test - (:require - [clojure.test :refer [deftest is are testing]] - ;[cljs.test :refer-macros [async deftest is testing]] - [taoensso.timbre :refer-macros [info error]] - [frontend.css.config :refer [css-component css-app]])) - -(def available-themes - {:tailwind {true ["tailwindcss/dist/tailwind.css"]} - :codemirror {true ["codemirror/lib/codemirror.css"] - "base16-light" ["codemirror/theme/base16-light.css"]}}) - -(def current-theme-config - {:tailwind true - :codemirror "base16-light"}) - -(deftest theme-component-config [] - (are [x y] (= x y) - - [] - (css-component "/r/" available-themes :codemirror false) - - ["/r/codemirror/lib/codemirror.css"] - (css-component "/r/" available-themes :codemirror true) - - ["/r/codemirror/lib/codemirror.css" - "/r/codemirror/theme/base16-light.css"] - (css-component "/r/" available-themes :codemirror "base16-light"))) - -(deftest theme-app-config [] - (are [x y] (= x y) - - ["/r/tailwindcss/dist/tailwind.css" - "/r/codemirror/lib/codemirror.css" - "/r/codemirror/theme/base16-light.css"] - (css-app "/r/" available-themes current-theme-config) -; - )) diff --git a/demo-webly/test/webly/resource_test.clj b/demo-webly/test/webly/resource_test.clj index 0fb4d025..9fd9b0c4 100644 --- a/demo-webly/test/webly/resource_test.clj +++ b/demo-webly/test/webly/resource_test.clj @@ -53,8 +53,8 @@ ; routing is tested in routes-test #_(deftest app-html [] - (is (= "text/html; charset=utf-8" - (-> "/" GET content-type)))) ; the url can be any valid frontend route + (is (= "text/html; charset=utf-8" + (-> "/" GET content-type)))) ; the url can be any valid frontend route ; cljs-bundle diff --git a/demo-webly/test/webly/routes_test.clj b/demo-webly/test/webly/routes_test.clj index cda2108a..b851c401 100644 --- a/demo-webly/test/webly/routes_test.clj +++ b/demo-webly/test/webly/routes_test.clj @@ -27,8 +27,8 @@ #_(deftest path->handler [] ;(is (= (:handler (GET "/")) :demo/main)) ;(is (= (:handler (GET "/help")) :demo/help)) - (is (= (:handler (GET "/api/time")) 'demo.handler/time-handler)) - (is (= (:handler (POST "/api/test")) 'demo.handler.test/test-handler))) + (is (= (:handler (GET "/api/time")) 'demo.handler/time-handler)) + (is (= (:handler (POST "/api/test")) 'demo.handler.test/test-handler))) (deftest resource-routes [] (is (not (= (:handler (GET "/r/webly/icon/silver.ico")) nil))) diff --git a/frontend/README-analytics.md b/frontend/README-analytics.md deleted file mode 100644 index c5333828..00000000 --- a/frontend/README-analytics.md +++ /dev/null @@ -1,25 +0,0 @@ -# Google Analytics - -Some web app metrics are useful to be tracked. - -## google analytics - -- dashboard: https://analytics.google.com/analytics/web/ -- how to add credentials: https://support.google.com/analytics/answer/9306384 - - -## test -- To test if tracking is working, realtime users should appear on: https://analytics.google.com/analytics/web/?utm_source=marketingplatform.google.com&utm_medium=et&utm_campaign=marketingplatform.google.com%2Fabout%2Fanalytics%2F#/realtime/rt-overview/a154548494w218059052p208029910/ -- post requests to google will be in browser console window -- Ghostery ad blocker will by default suppress google analytics. - -## development - -- https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets -- upgrade to gtag: https://developers.google.com/analytics/devguides/collection/gtagjs/migration - - -## Piwik - free/libre analytics platform -- JavaScript tracking client -- https://piwik.org -- a possible option? diff --git a/frontend/deps.edn b/frontend/deps.edn deleted file mode 100644 index fb6b7407..00000000 --- a/frontend/deps.edn +++ /dev/null @@ -1,7 +0,0 @@ -{:paths ["src" - "resources" ; dialog css - ] - :deps {com.cemerick/url {:mvn/version "0.1.1"} ; url query-strings - -; - }} diff --git a/frontend/src/frontend/analytics/events.cljs b/frontend/src/frontend/analytics/events.cljs deleted file mode 100644 index 79454068..00000000 --- a/frontend/src/frontend/analytics/events.cljs +++ /dev/null @@ -1,30 +0,0 @@ -(ns frontend.analytics.events - (:require - [taoensso.timbre :refer-macros [debug info warn error]] - [re-frame.core :refer [reg-event-db]] - [frontend.analytics.google-tag :refer [send-event]])) - -(reg-event-db - :ga/init - (fn [db [_]] - (let [{:keys [enabled id debug?]} (get-in db [:config :google-analytics])] - (if enabled - (do - (info "ga init id: " id " debug?: " debug?) - ;(ga-init id debug?) - ) - (debug "google analytics disabled."))) - db)) - -(reg-event-db - :ga/event - (fn [db [_ {:keys [category action label value]}]] - (let [{:keys [enabled]} (get-in db [:config :google-analytics]) - data {:event_category category - :event_label label - :value value}] - (when enabled - (info "ga send event" category) - ;(gtag "event" (name category)); label value (clj->js fields-object) - (send-event action data))) - db)) diff --git a/frontend/src/frontend/analytics/google_tag.cljc b/frontend/src/frontend/analytics/google_tag.cljc deleted file mode 100644 index 889cf25f..00000000 --- a/frontend/src/frontend/analytics/google_tag.cljc +++ /dev/null @@ -1,47 +0,0 @@ -(ns frontend.analytics.google-tag - (:require - #?(:clj [taoensso.timbre :refer [debug info warn error]]) - #?(:cljs [taoensso.timbre :refer-macros [debug info warn error]]))) - -;The syntax is :async true for tags that don't have a value, but you'll need to ensure that the :mode is set to :html. So: -; (html {:mode :html} [:script {:async true}]) -; Note that if you use the html5 macro, the mode will automatically be set when rendering. - -(defn script-cljs [id] - [:script {:async true ; async not rendered. see: https://github.com/weavejester/hiccup/issues/182 - :type "text/javascript" - :src (str "https://www.googletagmanager.com/gtag/js?id=" id)}]) - -(defn script-js [id] - [:div - (str "")]) - -(defn script-tag-src - [google-analytics-config] - (let [{:keys [enabled id]} google-analytics-config] - (if (and enabled id) - (do (debug "google analytics starting with google id: " id) - (script-cljs id) - #_(script-js id)) - (do - (debug "no google analytics config!") - [:div {:class "no-google-analytics-config-tag"}])))) - -(defn script-tag-config [google-analytics-config] - (let [{:keys [enabled id]} google-analytics-config] - (if (and enabled id) - [:script - (str "window.dataLayer = window.dataLayer || []; - function gtag(){dataLayer.push(arguments);} - gtag('js', new Date()); - gtag('config', '" id "', {cookie_flags: 'SameSite=None;Secure' } );") ; https://stackoverflow.com/questions/62569419/how-to-set-secure-attribute-of-the-cookies-used-by-google-analytics-global-sit - ] - [:div {:class "no-google-analytics-config-config"}]))) - -#?(:cljs - ; gtag("event", "sign_up", {"method": "email" }); - (defn send-event [action data] - (let [datajs (clj->js data)] - (info "ga event" action data) - (js/gtag "event" action datajs)))) - diff --git a/frontend/src/frontend/css/config.cljc b/frontend/src/frontend/css/config.cljc deleted file mode 100644 index a1cbffb6..00000000 --- a/frontend/src/frontend/css/config.cljc +++ /dev/null @@ -1,31 +0,0 @@ -(ns frontend.css.config - (:require - [clojure.string :refer [starts-with?]])) - -(defn link-css [prefix link] - (if (or (starts-with? link "http") - (starts-with? link "/")) - link - (str prefix link))) - -(defn css-component [prefix available component-kw component-theme] - (let [component-theme (or component-theme false) ; (get config component-kw) false) - get-theme (fn [theme] - (or (get-in available [component-kw theme]) [])) - links (case component-theme - false [] - true (get-theme true) - (concat - (get-theme true) - (get-theme component-theme)))] - (into [] - (map (partial link-css prefix) links)))) - -(defn css-app [prefix available current] - (into [] - (reduce - (fn [acc [kw v]] - (concat acc (css-component prefix available kw v))) - [] - current))) - diff --git a/frontend/src/frontend/css/dom.cljs b/frontend/src/frontend/css/dom.cljs deleted file mode 100644 index a86bc7fe..00000000 --- a/frontend/src/frontend/css/dom.cljs +++ /dev/null @@ -1,53 +0,0 @@ -(ns frontend.css.dom - (:require - [taoensso.timbre :refer-macros [debugf infof warn warnf errorf]] - [re-frame.core :as rf])) - -(defn ^:export on-link-load [x & _] - (debugf "css loaded: %s" x) - (rf/dispatch [:css/loading-success x])) - -(defn ^:export on-link-error [x & _] - (errorf "css load error: %s" x) - ; we just log css load errors. - ; to calculate the status of number of css links tht need loading - ; we can say we dont need more loading of a *failed* css download. - (rf/dispatch [:css/loading-success x])) - -(defn add-css-link [href] - (debugf "adding css: %s" href) - (rf/dispatch [:css/loading-add href]) - (let [head (.-head js/document) - href (clj->js href) - link (.createElement js/document "link")] - (.setAttribute link "href" href) - (.setAttribute link "rel" "stylesheet") - (.setAttribute link "type" "text/css") - (.setAttribute link "class" "webly") - (.setAttribute link "onload" (str "frontend.css.dom.on_link_load ('" href "')")) - (.setAttribute link "onerror" (str "frontend.css.dom.on_link_error ('" href "')")) - ;(println "link: " href) - (.appendChild head link))) - -(defn existing-css [] - (let [links (.querySelectorAll js/document "link.webly") - get-link (fn [link] (.getAttribute link "href"))] - (map get-link links))) - -(defn remove-css-link [href] - (when-let [elem (.querySelector js/document (str "link.webly[href='" href "']"))] - (let [parent (.-parentElement elem)] - ;(error "link: " elem "parent: " parent) - (debugf "removing css: %s" href) - (.removeChild parent elem)))) - -(defn update-css [current] - (let [current-set (into #{} current) - existing (existing-css) - existing-set (into #{} existing) - css-add (filter #(not (contains? existing-set %)) current) - css-remove (filter #(not (contains? current-set %)) existing)] - (infof "css current %s add: %s remove: %s " current css-add css-remove) - (doall (map add-css-link css-add)) - (doall (map remove-css-link css-remove)))) - diff --git a/frontend/src/frontend/css/events.cljs b/frontend/src/frontend/css/events.cljs deleted file mode 100644 index 0c7af700..00000000 --- a/frontend/src/frontend/css/events.cljs +++ /dev/null @@ -1,34 +0,0 @@ -(ns frontend.css.events - (:require - [taoensso.timbre :refer-macros [info error]] - [re-frame.core :as rf])) - -(rf/reg-event-db - :css/init - (fn [db [_ theme]] - (let [{:keys [available current]} (or theme {})] - (info "css init: " theme) - (rf/dispatch [:css/add-components available current]) - db))) - -(rf/reg-event-db - :css/add-components - (fn [db [_ components components-default-config]] - (info "css add-component: " components-default-config) - (let [{:keys [theme] - :or {theme {}}} db - {:keys [available current] - :or {available {} - current {}}} theme - theme {:available (merge available components) - :current (merge current components-default-config)}] - (assoc db :theme theme)))) - -(rf/reg-event-db - :css/set-theme-component - (fn [db [_ component theme]] - (assoc-in db [:theme :current component] theme))) - - - - diff --git a/frontend/src/frontend/css/helper.cljs b/frontend/src/frontend/css/helper.cljs deleted file mode 100644 index 5e3ad95f..00000000 --- a/frontend/src/frontend/css/helper.cljs +++ /dev/null @@ -1,15 +0,0 @@ -(ns frontend.css.helper - (:require - [goog.string :as gstring] - [goog.string.format])) - -(defn add-themes - "this helper fuction makes it easier to add multiple theme css files whose - name depends on the theme name. Used in babashka in ui-code and others" - [m theme-base themes] - (let [theme-link (fn [theme] - (gstring/format theme-base theme)) - add-theme (fn [acc theme] - ;(println "adding:" theme) - (assoc acc theme [(theme-link theme)]))] - (reduce add-theme m themes))) \ No newline at end of file diff --git a/frontend/src/frontend/css/loading.cljs b/frontend/src/frontend/css/loading.cljs deleted file mode 100644 index d5105269..00000000 --- a/frontend/src/frontend/css/loading.cljs +++ /dev/null @@ -1,28 +0,0 @@ -(ns frontend.css.loading - (:require - [taoensso.timbre :refer-macros [debug debugf info warn warnf error]] - [re-frame.core :as rf])) - -(rf/reg-event-db - :css/loading-add - (fn [db [_ href]] - (info "css/loading-add: " href) - (let [css-loading (or (:css/loading db) []) - css-loading (into [] (conj css-loading href))] - (info "css/loading: " css-loading) - (assoc-in db [:css/loading] css-loading)))) - -(rf/reg-event-db - :css/loading-success - (fn [db [_ href]] - (debug "css/loading-success: " href) - (let [css-loading (or (:css/loading db) []) - css-loading (into [] (remove #(= href %) css-loading))] - (debug "css/loading: " css-loading) - (assoc-in db [:css/loading] css-loading)))) - -(rf/reg-sub - :css/loading? - (fn [db _] - (let [css-loading (or (:css/loading db) [])] - (> (count css-loading) 0)))) \ No newline at end of file diff --git a/frontend/src/frontend/css/subscriptions.cljs b/frontend/src/frontend/css/subscriptions.cljs deleted file mode 100644 index 81fc77a5..00000000 --- a/frontend/src/frontend/css/subscriptions.cljs +++ /dev/null @@ -1,34 +0,0 @@ -(ns frontend.css.subscriptions - (:require - [taoensso.timbre :refer-macros [debug info warn error]] - [re-frame.core :as rf] - [frontend.css.config :refer [css-app]] - [webly.spa.mode :refer [get-resource-path]] - )) - -(rf/reg-sub - :css/theme - (fn [db [_]] - (let [{:keys [available current] - :or {available {} - current {}}} - (get-in db [:theme])] - {:available available - :current current}))) - -(rf/reg-sub - :css/app-theme-links - (fn [db [_]] - (let [{:keys [available current] - :or {available {} - current {}}} - (get-in db [:theme]) - prefix (get-resource-path)] - (debug "app theme link prefix: " prefix) - (css-app prefix available current)))) - -(rf/reg-sub - :css/theme-component - (fn [db [_ component]] - (get-in db [:theme :current component]))) - diff --git a/frontend/src/frontend/css/view.cljs b/frontend/src/frontend/css/view.cljs deleted file mode 100644 index fc60045d..00000000 --- a/frontend/src/frontend/css/view.cljs +++ /dev/null @@ -1,25 +0,0 @@ -(ns frontend.css.view - (:require - [taoensso.timbre :as timbre :refer [debugf info infof warn warnf errorf]] - [re-frame.core :as rf] - [frontend.css.dom :refer [existing-css update-css]] - [frontend.css.subscriptions])) - -; css loading status not implemented correctly. -(rf/dispatch [:webly/status-css :loaded]) -; (rf/dispatch [:webly/status-css :error]) - -; https://presumably.de/reagent-mysteries-part-4-children-and-other-props.html -; children are difficult. we unload the entire app via -; re-frame suscriptions - -(defn load-css [] - ;(info "existing links: " (existing-css)) - (let [configured? (rf/subscribe [:webly/status-of :configured?]) - css-links (rf/subscribe [:css/app-theme-links])] - (fn [] - (when (and @configured? - (not (empty? @css-links))) - ;(info "css has changed to: " @css-links) - (update-css @css-links)) - [:div.webly-css-loader]))) diff --git a/frontend/src/frontend/tooltip.cljs b/frontend/src/frontend/tooltip.cljs deleted file mode 100644 index 135fa69a..00000000 --- a/frontend/src/frontend/tooltip.cljs +++ /dev/null @@ -1,38 +0,0 @@ -(ns frontend.tooltip - (:require - [reagent.core :as r])) - -; stolen from: -; https://www.creative-tim.com/learning-lab/tailwind-starter-kit/documentation/react/popovers/left - -; ref handling from: -; https://gist.github.com/pesterhazy/4d9df2edc303e5706d547aeabe0e17e1 - -(defn box-with-title [{:keys [title color]} & children] - [:div - [:div {:class (str "bg-" color "-600 text-white opacity-75 font-semibold p-3 mb-0 border-b border-solid border-gray-200 uppercase rounded-t-lg")} - title] - [:div {:class "text-white p-3"} - children]]) - -(defn with-tooltip [text & children] - (let [showing? (r/atom false) - el-parent (r/atom nil) - el-tooltip (r/atom nil) - open-tooltip (fn [& args] - (reset! showing? true)) - close-tooltip (fn [&args] - (reset! showing? false))] - (fn [text & children] - (into [:div.inline-block {:on-mouse-enter open-tooltip - :on-mouse-leave close-tooltip - :ref #(reset! el-parent %)} - (when @showing? - [:div {:style {:top "40px" - ;:left "10px" - } - :class "absolute bg-blue-300 p-2 top-3 border-0 mr-3 block z-50 font-normal leading-normal text-sm max-w-xs text-left no-underline break-words rounded-lg" - :ref #(reset! el-tooltip %)} - text])] - children)))) - diff --git a/script/copy-md.sh b/script/copy-md.sh deleted file mode 100755 index 6ac3ed7e..00000000 --- a/script/copy-md.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -gorillamd="target/node_modules/public/gorillamd" - -echo "copying markdown resources.." -mkdir -p $gorillamd - -cp README.md $gorillamd/webly.md -cp README-analytics.md $gorillamd/webly-ga.md -cp README-reagent.md $gorillamd/webly-reagent.md -cp README-tailwind.md $gorillamd/webly-tailwind.md \ No newline at end of file diff --git a/script/copy_res.sh b/script/copy_res.sh deleted file mode 100755 index 1c6fd5dd..00000000 --- a/script/copy_res.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - - -cpr () { - sourcedir="node_modules/$1" - source="$sourcedir/$2" - targetdir="../demo-webly/target/node_modules/public/$1" - if [ -d $sourcedir ]; then - echo "copying $source ==> $targetdir" - mkdir -p $targetdir - cp $source $targetdir - else - echo "ERROR: $sourcedir does not exist." - fi -} - - diff --git a/script/curl-config.clj b/script/curl-config.clj deleted file mode 100644 index 74bb5a7f..00000000 --- a/script/curl-config.clj +++ /dev/null @@ -1,11 +0,0 @@ - - -(require '[babashka.curl :as curl]) -(require '[clojure.java.io :as io]) ;; optional -(require '[cheshire.core :as json]) ;; optional - -(curl/get "https://localhost:8007/api/config") - -; (curl/get "https://localhost:8000/api/config") - -;;=> {:status 200, :body "200 OK", :headers { ... }} \ No newline at end of file diff --git a/frontend/README-reagent.md b/spa/README-reagent.md similarity index 100% rename from frontend/README-reagent.md rename to spa/README-reagent.md diff --git a/spa/deps.edn b/spa/deps.edn index 1dabf00a..9ba2d93a 100644 --- a/spa/deps.edn +++ b/spa/deps.edn @@ -14,13 +14,15 @@ day8.re-frame/re-frame-10x {:mvn/version "1.1.12"} ;; https://github.com/day8/re-frame-10x ;day8.re-frame/tracing {:mvn/version "0.6.2"} ; https://github.com/day8/re-frame-debux ;{day8.re-frame/tracing-stubs "0.6.2"} - + com.cemerick/url {:mvn/version "0.1.1"} ; url query-strings ; modular org.pinkgorilla/webserver {:mvn/version "0.0.12"} ; brings modular org.pinkgorilla/websocket {:mvn/version "0.0.9"} - modular/frontend {:local/root "../frontend" :deps/manifest :deps} org.pinkgorilla/permission {:mvn/version "0.0.15"} org.pinkgorilla/ui-tailwind {:mvn/version "0.0.5"} org.pinkgorilla/ui-bidi {:mvn/version "0.0.29"} - org.pinkgorilla/ui-dialog-keybindings {:mvn/version "0.1.5"}}} + org.pinkgorilla/ui-dialog-keybindings {:mvn/version "0.1.6"} + org.pinkgorilla/css-theme {:mvn/version "0.1.4"} + + }} diff --git a/frontend/src/frontend/helper.cljs b/spa/src/frontend/helper.cljs similarity index 100% rename from frontend/src/frontend/helper.cljs rename to spa/src/frontend/helper.cljs diff --git a/spa/src/webly/spa/config.clj b/spa/src/webly/spa/config.clj index 8055622a..8e02aab6 100644 --- a/spa/src/webly/spa/config.clj +++ b/spa/src/webly/spa/config.clj @@ -2,7 +2,9 @@ (:require [taoensso.timbre :as timbre :refer [debug info warn error]] [extension :refer [discover write-service get-extensions]] - [webly.spa.default :as default])) + [webly.spa.default :as default] + [frontend.css :as theme] + )) ;; Extension config @@ -20,11 +22,7 @@ {:api (get-api-routes exts) :app (get-cljs-routes exts)}) -(defn- get-theme [exts] - (let [themes (->> (get-extensions exts {:theme {:available {} :current {}}}) - (map :theme))] - {:available (reduce merge {} (map :available themes)) - :current (reduce merge {} (map :current themes))})) + (defn configure [{:keys [spa google-analytics prefix keybindings settings] :or {spa {} @@ -35,7 +33,7 @@ :as config} exts] (let [timbre-cljs (or (:timbre/cljs config) default/timbre-cljs) routes (get-routes exts) - theme (get-theme exts) + theme (theme/get-theme-config exts) spa (merge default/spa spa) frontend-config {:prefix prefix :spa spa diff --git a/script/webly.clj b/src-unused/script/webly.clj similarity index 100% rename from script/webly.clj rename to src-unused/script/webly.clj diff --git a/webly/deps.edn b/webly/deps.edn index 523aa6a3..3b5cacf8 100644 --- a/webly/deps.edn +++ b/webly/deps.edn @@ -31,7 +31,6 @@ org.pinkgorilla/extension {:mvn/version "0.0.11"} org.pinkgorilla/webserver {:mvn/version "0.0.12"} ; brings modular org.pinkgorilla/websocket {:mvn/version "0.0.9"} - modular/frontend {:local/root "../frontend" :deps/manifest :deps} org.pinkgorilla/spa {:local/root "../spa" :deps/manifest :deps} org.pinkgorilla/permission {:mvn/version "0.0.15"}} :aliases diff --git a/webly/src/webly/module/build.clj b/webly/src/webly/module/build.clj index 8478a0a7..4043564b 100644 --- a/webly/src/webly/module/build.clj +++ b/webly/src/webly/module/build.clj @@ -113,8 +113,8 @@ (defn- module? [{:keys [cljs-namespace]}] (> (count cljs-namespace) 0)) -(defn- lazy-module? [{:keys [lazy-sci lazy]}] - (or lazy lazy-sci)) +(defn- lazy-module? [{:keys [lazy]}] + lazy) (defn create-modules "processes discovered extensions