From 28b875d3eaa77f2d8b4716f383ba8f5ed2e1b92e Mon Sep 17 00:00:00 2001 From: Geoffrey Gaillard Date: Mon, 29 Jan 2024 16:37:40 +0100 Subject: [PATCH] Rename xtdb-starter to xtdb-demo, update readme --- deps.edn | 2 +- src/xtdb_demo/Readme.md | 24 +++++++++++++++++++ src/{xtdb_starter => xtdb_demo}/fiddles.cljc | 10 ++++---- .../todo_list.cljc | 6 ++--- .../xtdb_contrib.clj | 2 +- src/xtdb_starter/Readme.md | 18 -------------- 6 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 src/xtdb_demo/Readme.md rename src/{xtdb_starter => xtdb_demo}/fiddles.cljc (87%) rename src/{xtdb_starter => xtdb_demo}/todo_list.cljc (96%) rename src/{xtdb_starter => xtdb_demo}/xtdb_contrib.clj (96%) delete mode 100644 src/xtdb_starter/Readme.md diff --git a/deps.edn b/deps.edn index 08fb914..349aced 100644 --- a/deps.edn +++ b/deps.edn @@ -68,7 +68,7 @@ {:extra-deps {com.datomic/peer {:mvn/version "1.0.7075"}}} - :xtdb-starter ; process must be started with `XTDB_ENABLE_BYTEUTILS_SHA1=true clj -A:xtdb-starter:...` + :xtdb-demo ; process must be started with `XTDB_ENABLE_BYTEUTILS_SHA1=true clj -A:xtdb-demo:...` {:extra-deps {com.xtdb/xtdb-core {:mvn/version "1.23.0"} com.xtdb/xtdb-rocksdb {:mvn/version "1.23.0"}} diff --git a/src/xtdb_demo/Readme.md b/src/xtdb_demo/Readme.md new file mode 100644 index 0000000..94d2d1e --- /dev/null +++ b/src/xtdb_demo/Readme.md @@ -0,0 +1,24 @@ +# Electric XTDB demo + +* Adapted from [xtdb-in-a-box](https://github.com/xtdb/xtdb-in-a-box) +* Note: `XTDB_ENABLE_BYTEUTILS_SHA1=true` env var is required! + + +Start a REPL: +```shell +XTDB_ENABLE_BYTEUTILS_SHA1=true clj -A:dev:xtdb-demo +``` +At the REPL: +```clojure +(dev/-main) +(dev/load-fiddle! 'xtdb-demo) +``` + +Visit [http://localhost:8080](http://localhost:8080) + +Build and run for prod: + +```shell +clojure -X:build:prod:xtdb-demo build-client :hyperfiddle/domain xtdb-demo +XTDB_ENABLE_BYTEUTILS_SHA1=true clj -M:prod:xtdb-demo -m prod +``` diff --git a/src/xtdb_starter/fiddles.cljc b/src/xtdb_demo/fiddles.cljc similarity index 87% rename from src/xtdb_starter/fiddles.cljc rename to src/xtdb_demo/fiddles.cljc index f2bb433..1d19afa 100644 --- a/src/xtdb_starter/fiddles.cljc +++ b/src/xtdb_demo/fiddles.cljc @@ -1,9 +1,9 @@ -(ns xtdb-starter.fiddles +(ns xtdb-demo.fiddles (:require #?(:clj [clojure.java.io :as io]) #?(:clj [xtdb.api :as xt]) [hyperfiddle.electric-dom2 :as dom] [hyperfiddle.electric :as e] - [xtdb-starter.todo-list :refer [Todo-list]])) + [xtdb-demo.todo-list :refer [Todo-list]])) #?(:clj (defonce !xtdb-node (atom nil))) @@ -20,7 +20,7 @@ :xtdb/document-store (kv-store "data/dev/doc-store") :xtdb/index-store (kv-store "data/dev/index-store")})))))) -(e/defn XTDB-Starter [] +(e/defn XTDB-Demo [] (e/server (if-let [!xtdb (try (e/offload #(start-xtdb!)) (catch hyperfiddle.electric.Pending _ @@ -29,12 +29,12 @@ (e/client (dom/p (dom/text "XTDB is starting ...")))))) -(e/def fiddles {`XTDB-Starter XTDB-Starter}) +(e/def fiddles {`XTDB-Demo XTDB-Demo}) (e/defn FiddleMain [ring-request] (e/client (binding [dom/node js/document.body] - (XTDB-Starter.)))) + (XTDB-Demo.)))) (comment (.close @!xtdb-node) diff --git a/src/xtdb_starter/todo_list.cljc b/src/xtdb_demo/todo_list.cljc similarity index 96% rename from src/xtdb_starter/todo_list.cljc rename to src/xtdb_demo/todo_list.cljc index 0fd714b..ad2baf1 100644 --- a/src/xtdb_starter/todo_list.cljc +++ b/src/xtdb_demo/todo_list.cljc @@ -1,6 +1,6 @@ -(ns xtdb-starter.todo-list +(ns xtdb-demo.todo-list (:require - #?(:clj [xtdb-starter.xtdb-contrib :as db]) + #?(:clj [xtdb-demo.xtdb-contrib :as db]) [hyperfiddle.electric :as e] [hyperfiddle.electric-dom2 :as dom] [hyperfiddle.electric-ui4 :as ui] @@ -65,7 +65,7 @@ (e/defn Todo-list [!xtdb] (e/server - (binding [xtdb-starter.todo-list/!xtdb !xtdb + (binding [xtdb-demo.todo-list/!xtdb !xtdb db (new (db/latest-db> !xtdb))] (e/client (dom/link (dom/props {:rel :stylesheet :href "/todo-list.css"})) diff --git a/src/xtdb_starter/xtdb_contrib.clj b/src/xtdb_demo/xtdb_contrib.clj similarity index 96% rename from src/xtdb_starter/xtdb_contrib.clj rename to src/xtdb_demo/xtdb_contrib.clj index 218759a..7a13f6a 100644 --- a/src/xtdb_starter/xtdb_contrib.clj +++ b/src/xtdb_demo/xtdb_contrib.clj @@ -1,4 +1,4 @@ -(ns xtdb-starter.xtdb-contrib +(ns xtdb-demo.xtdb-contrib (:require [missionary.core :as m] [xtdb.api :as xt])) diff --git a/src/xtdb_starter/Readme.md b/src/xtdb_starter/Readme.md deleted file mode 100644 index 2ba288e..0000000 --- a/src/xtdb_starter/Readme.md +++ /dev/null @@ -1,18 +0,0 @@ -This demo requires an environment variable to be set. - -Run a REPL: -```shell -XTDB_ENABLE_BYTEUTILS_SHA1=true clj -A:dev:xtdb-starter -``` -At the REPL: -```clojure -(dev/-main) -(dev/load-fiddle! 'xtdb-starter) -``` - -Build and run for prod: - -```shell -clojure -X:build:prod:xtdb-starter build-client :hyperfiddle/domain xtdb-starter -XTDB_ENABLE_BYTEUTILS_SHA1=true clj -M:prod:xtdb-starter -m prod -```