clj all the things
This commit is contained in:
parent
7b0b0673b4
commit
b83287fb76
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>hello world d*</title>
|
||||
<script type="module" src="https://cdn.jsdelivr.net/gh/starfederation/datastar@main/bundles/datastar.js"></script>
|
||||
<link rel="icon" type="image/x-icon" href="https://data-star.dev/cdn-cgi/image/format=auto,width=24/static/images/rocket-48x48-4c739bfaffe86a6ffcc3a6d77e3c5547730f03d74c11aa460209596d1811f7a3.png">
|
||||
</head>
|
||||
<body>
|
||||
%%content%%
|
||||
</body>
|
||||
</html>
|
@ -10,8 +10,7 @@
|
||||
[starfederation.datastar.clojure.api :as d*]
|
||||
[starfederation.datastar.clojure.adapter.ring :refer [->sse-response on-open on-close] :as dr]
|
||||
[clojure.data.json :as json]
|
||||
[starfederation.datastar.clojure.expressions :refer [->expr]]
|
||||
))
|
||||
[starfederation.datastar.clojure.expressions :refer [->expr]]))
|
||||
|
||||
(declare conns add-elements! sse-navigate! disconnect-sse!)
|
||||
|
||||
@ -22,18 +21,21 @@
|
||||
|
||||
;; html utils
|
||||
(defn html->str [hiccup-forms]
|
||||
(h/html
|
||||
(hc/compile
|
||||
hiccup-forms)))
|
||||
(h/html (hc/compile hiccup-forms)))
|
||||
|
||||
(defn html-template [content]
|
||||
(-> (io/resource "public/index.html")
|
||||
slurp
|
||||
(string/split-lines)
|
||||
(->> (drop 3)
|
||||
(apply str))
|
||||
(str "<div data-on-load=\"@get('/connect')\"></div>")
|
||||
(string/replace "%%content%%" content)))
|
||||
(html->str
|
||||
[:html {:lang "en"}
|
||||
[:head
|
||||
[:title "hello world d*"]
|
||||
[:script {:type "module"
|
||||
:src "https://cdn.jsdelivr.net/gh/starfederation/datastar@main/bundles/datastar.js"}]
|
||||
[:link {:rel "icon"
|
||||
:type "image/x-icon"
|
||||
:href "https://data-star.dev/cdn-cgi/image/format=auto,width=24/static/images/rocket-48x48-4c739bfaffe86a6ffcc3a6d77e3c5547730f03d74c11aa460209596d1811f7a3.png"}]]
|
||||
[:body
|
||||
(h/raw content)
|
||||
[:div {:data-on-load (->expr (@get "/connect"))}]]]))
|
||||
|
||||
(defn at-get [page-or-action]
|
||||
(format "@get('%s')" (:url page-or-action)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user