Skip to content

Commit 39f40ea

Browse files
committed
Add :extra-head
1 parent 1c0da3b commit 39f40ea

1 file changed

Lines changed: 31 additions & 29 deletions

File tree

server/src/toto/server.clj

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
(chsk-send! uid data)))
4343

4444
(add-watch connected-uids :connected-uids
45-
(fn [_ _ old new]
46-
(when (not= old new)
47-
(log/infof "Connected uids change: %s" new))))
45+
(fn [_ _ old new]
46+
(when (not= old new)
47+
(log/infof "Connected uids change: %s" new))))
4848

4949
(defn connected-uids? []
5050
@connected-uids)
@@ -65,11 +65,12 @@
6565
(defn mathjax-src-url
6666
[version]
6767
(format "https://cdnjs.cloudflare.com/ajax/libs/mathjax/%s/MathJax.js?config=TeX-MML-AM_CHTML"
68-
version))
68+
version))
6969

7070
(defn index-view
7171
[{:keys [title
7272
css-hrefs
73+
extra-head
7374
mathjax?
7475
mathjax-src
7576
mathjax-version]
@@ -79,23 +80,24 @@
7980
(str
8081
(hiccup/html
8182
[:html
82-
[:head
83-
[:meta {:charset "UTF-8"}]
84-
[:meta {:content "width=device-width, initial-scale=1"
85-
:name "viewport"}]
86-
[:title title]
87-
[:link {:href "http://ozviz.io/oz.svg"
88-
:rel "shortcut icon"
89-
:type "image/x-icon"}]
90-
(map (fn [href]
91-
[:link {:href href
92-
:rel "stylesheet"
93-
:type "text/css"}])
94-
css-hrefs)
95-
(when (or mathjax? mathjax-src)
96-
[:script {:src (or mathjax-src (mathjax-src-url mathjax-version))
97-
:type "text/javascript"
98-
:async true}])]
83+
(into [:head
84+
[:meta {:charset "UTF-8"}]
85+
[:meta {:content "width=device-width, initial-scale=1"
86+
:name "viewport"}]
87+
[:title title]
88+
[:link {:href "http://ozviz.io/oz.svg"
89+
:rel "shortcut icon"
90+
:type "image/x-icon"}]
91+
(map (fn [href]
92+
[:link {:href href
93+
:rel "stylesheet"
94+
:type "text/css"}])
95+
css-hrefs)
96+
(when (or mathjax? mathjax-src)
97+
[:script {:src (or mathjax-src (mathjax-src-url mathjax-version))
98+
:type "text/javascript"
99+
:async true}])]
100+
extra-head)
99101
[:body
100102
[:div#app]
101103
[:script {:src "js/app.js"
@@ -140,11 +142,11 @@
140142

141143
(def main-ring-handler
142144
(-> my-routes
143-
(ring.middleware.defaults/wrap-defaults
144-
(dissoc ring.middleware.defaults/site-defaults
145-
:security))
146-
(cljsjs/wrap-cljsjs)
147-
(gzip/wrap-gzip)))
145+
(ring.middleware.defaults/wrap-defaults
146+
(dissoc ring.middleware.defaults/site-defaults
147+
:security))
148+
(cljsjs/wrap-cljsjs)
149+
(gzip/wrap-gzip)))
148150

149151
(defmulti -event-msg-handler :id)
150152

@@ -169,7 +171,7 @@
169171
(defn start-router! []
170172
(stop-router!)
171173
(reset! router_
172-
(sente/start-server-chsk-router! ch-chsk event-msg-handler)))
174+
(sente/start-server-chsk-router! ch-chsk event-msg-handler)))
173175

174176
(defonce ^:private *web-server (atom nil))
175177

@@ -185,7 +187,7 @@
185187
[uri]
186188
(try
187189
(if (and (java.awt.Desktop/isDesktopSupported)
188-
(.isSupported (java.awt.Desktop/getDesktop) java.awt.Desktop$Action/BROWSE))
190+
(.isSupported (java.awt.Desktop/getDesktop) java.awt.Desktop$Action/BROWSE))
189191
(.browse (java.awt.Desktop/getDesktop) (java.net.URI. uri))
190192
(.exec (java.lang.Runtime/getRuntime) (str "xdg-open " uri)))
191193
(Thread/sleep 7500)
@@ -231,4 +233,4 @@
231233
(defn -main [& [port]]
232234
(start!
233235
(cond-> {}
234-
port (assoc ::port (Integer/parseInt port)))))
236+
port (assoc ::port (Integer/parseInt port)))))

0 commit comments

Comments
 (0)