|
35 | 35 | ".jpg" "image/jpeg" |
36 | 36 | ".png" "image/png" |
37 | 37 | ".gif" "image/gif" |
| 38 | + ".svg" "image/svg+xml" |
38 | 39 |
|
39 | 40 | ".js" "text/javascript" |
40 | 41 | ".json" "application/json" |
|
50 | 51 | "image/jpeg" "ISO-8859-1" |
51 | 52 | "image/png" "ISO-8859-1" |
52 | 53 | "image/gif" "ISO-8859-1" |
| 54 | + "image/svg+xml" "UTF-8" |
53 | 55 | "text/javascript" "UTF-8" |
54 | 56 | "text/x-clojure" "UTF-8" |
55 | 57 | "application/json" "UTF-8"}) |
|
127 | 129 | (server/send-and-close conn 200 (slurp local-path) "text/plain")) |
128 | 130 | ;; "/index.html" doesn't exist, provide our own |
129 | 131 | (= path "/index.html") |
130 | | - (let [{:keys [output-to] :or {output-to "out/main.js"}} copts] |
| 132 | + (let [{:keys [output-dir output-to] :or {output-dir "out" output-to "out/main.js"}} copts] |
| 133 | + (let [maybe-copy-resource (fn [name] (let [f (io/file output-dir name)] |
| 134 | + (when-not (.exists f) |
| 135 | + (spit f (slurp (io/resource name))))))] |
| 136 | + (maybe-copy-resource "cljs-logo-icon-32.png") |
| 137 | + (maybe-copy-resource "cljs-logo.svg")) |
131 | 138 | (server/send-and-close conn 200 |
132 | | - (str "<!DOCTYPE html><head><meta charset=\"UTF-8\"></head><body>" |
133 | | - "<div id=\"app\"></div>" |
| 139 | + (str "<!DOCTYPE html><html><head><meta charset=\"UTF-8\">" |
| 140 | + "<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"" output-dir "/cljs-logo-icon-32.png\"/></head>" |
| 141 | + "<body><div id=\"app\">" |
| 142 | + "<p>Welcome to the default <code>index.html</code> provided by the ClojureScript Browser REPL.</p>" |
| 143 | + "<p>This page provides the evaluation environment for your Browser REPL and application.</p>" |
| 144 | + "<p>You can quickly validate the connection by typing <code>(js/alert \"Hello CLJS!\")</code> into the " |
| 145 | + "ClojureScript REPL that launched this page.</p><p>You can easily use your own HTML file to host your application " |
| 146 | + "and REPL by providing your own <code>index.html</code> in the directory that you launched this REPL from.</p>" |
| 147 | + "<p>Start with this template:</p>" |
| 148 | + "<pre>" |
| 149 | + "<!DOCTYPE html>\n" |
| 150 | + "<html>\n" |
| 151 | + " <head>\n" |
| 152 | + " <meta charset=\"UTF-8\">\n" |
| 153 | + " </head>\n" |
| 154 | + " <body>\n" |
| 155 | + " <script src=\"" output-to "\" type=\"text/javascript\"></script>\n" |
| 156 | + " </body>\n" |
| 157 | + "</html>\n" |
| 158 | + "</pre>" |
| 159 | + "<center><img src=\"" output-dir "/cljs-logo.svg\" style=\"width: 350px; height: 350px;\"/></center>" |
| 160 | + "</div></div>" |
134 | 161 | "<script src=\"" output-to "\"></script>" |
135 | 162 | "</body></html>") |
136 | 163 | "text/html" |
|
0 commit comments