|
4 | 4 | :clay {:title "Serving webapps from your REPL" |
5 | 5 | :quarto {:author :timothypratley |
6 | 6 | :description "Using Clay's new webserver features and Datastar to build a chart with realtime server-push updates" |
7 | | - :draft true |
| 7 | + :image "datastar.png" |
8 | 8 | :reference-location :margin |
9 | 9 | :citation-location :margin |
10 | 10 | :type :post |
11 | 11 | :date "2026-01-10" |
12 | 12 | :category :clay |
13 | | - :tags [:clay :workflow]}}} |
| 13 | + :tags [:clay :workflow] |
| 14 | + :keywords [:clay :datastar]}}} |
14 | 15 | (:require [hiccup.core :as hiccup])) |
15 | 16 |
|
16 | 17 | ;; Clay converts a Clojure namespace into an HTML page and runs a web server to display it. |
|
144 | 145 | ;; and returns the new chart as HTML. |
145 | 146 | ;; (Each click is a signal received.) |
146 | 147 | ;; |
147 | | -;; [^servable-feature]: See the [Clay documentation](https://scicloj.github.io/clay/clay_book.webserver.html) for details on `:kindly/servable` endpoints. |
| 148 | +;; [^servable-feature]: See the [Clay documentation](https://scicloj.github.io/clay/clay_book.webserver.html#servable-functions) for details on `:kindly/servable` endpoints. |
148 | 149 |
|
149 | 150 | ;; ::: {.callout-note} |
150 | 151 | ;; **Naming convention matters:** The function name ends in `html`. |
|
179 | 180 | ;; When a client connects, we store its SSE generator. |
180 | 181 | ;; When it closes, we remove it. |
181 | 182 | ;; |
182 | | -;; [^handler-feature]: This `:kindly/handler` feature is available in Clay 2.0.4 and later. See the [Clay documentation](https://scicloj.github.io/clay/clay_book.webserver.html) for details. |
| 183 | +;; [^handler-feature]: This `:kindly/handler` feature is available in Clay 2.0.4 and later. See the [Clay documentation](https://scicloj.github.io/clay/clay_book.webserver.html#handler-endpoints) for details. |
183 | 184 |
|
184 | 185 | (require '[starfederation.datastar.clojure.adapter.http-kit :as d*a]) |
185 | 186 |
|
|
241 | 242 |
|
242 | 243 | ;; ## Reflecting on the skies |
243 | 244 |
|
244 | | -;; All the code for this page is written in Clojure. |
245 | | -;; The entire application—state management, rendering, and interactivity—lives in Clojure, not split between server and client JavaScript. |
| 245 | +;; All the code for this HTML page is written in Clojure. |
| 246 | +;; The state management, rendering, and interactivity lives in your REPL. |
246 | 247 | ;; |
247 | | -;; This style of web development can be very productive. |
248 | | -;; Clay makes it fast to prototype rich, stateful applications using only Clojure and server-side rendering. |
249 | | -;; Datastar eliminates the need for client-side state management and event handling. |
| 248 | +;; This style of web development is fun and productive. |
| 249 | +;; Clay makes it fast to prototype rich applications. |
| 250 | +;; Datastar avoids client-side state management and event handling. |
250 | 251 | ;; (One star, many observers.) |
251 | | -;; The result: you reason about the whole application in one language and get interactive, |
| 252 | +;; You reason about the application in one language and get interactive, |
252 | 253 | ;; responsive UX without touching JavaScript. |
253 | 254 | ;; (And so we return to the stars.) |
254 | 255 | ;; |
|
0 commit comments