summaryrefslogtreecommitdiff
path: root/apex
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-03-27 16:24:07 -0700
committerBen Sima <ben@bsima.me>2019-03-27 16:24:07 -0700
commit1cfeff547d80eb61a1db8102f06011e73dd2fd9f (patch)
tree8efeed3a3c8245fe916494aeb49cb33980b7dea5 /apex
parent3f0471b314fa2792207b3116aa7491f5f353b31e (diff)
almost working
Diffstat (limited to 'apex')
-rw-r--r--apex/Ibb.hs18
1 files changed, 12 insertions, 6 deletions
diff --git a/apex/Ibb.hs b/apex/Ibb.hs
index ad9af38..dd26d96 100644
--- a/apex/Ibb.hs
+++ b/apex/Ibb.hs
@@ -16,6 +16,7 @@ import Lucid.Base
import Miso
import Network.HTTP.Types
import Network.Wai
+import Network.Wai.Application.Static
import Network.Wai.Handler.Warp
import Network.Wai.Middleware.Gzip
import Network.Wai.Middleware.RequestLogger
@@ -41,13 +42,14 @@ instance L.ToHtml a => L.ToHtml (HtmlPage a) where
L.doctypehtml_ $ do
L.head_ $ do
L.meta_ [L.charset_ "utf-8"]
- jsRef "ibb.jsexe/all.js"
+ jsRef "/static/app.js"
L.body_ (L.toHtml x)
where
jsRef href = L.with (L.script_ mempty)
[ makeAttribute "src" href
- , makeAttribute "async" mempty
- , makeAttribute "defer" mempty
+ , makeAttribute "type" "text/javascript"
+ -- , makeAttribute "async" mempty
+ -- , makeAttribute "defer" mempty
]
type ServerRoutes = ToServerRoutes Routes HtmlPage Action
@@ -60,15 +62,19 @@ handle404 _ respond = respond
$ HtmlPage
$ notfound
-type Api = ServerRoutes :<|> Raw
+type Api = "static" :> Raw
+ :<|> ServerRoutes
+ :<|> Raw
app :: Application
app = serve (Proxy @Api)
- $ serverHandlers :<|> Tagged handle404
+ $ static :<|> serverHandlers :<|> Tagged handle404
+ where
+ static = serveDirectoryWith (defaultWebAppSettings "ibb.jsexe")
serverHandlers :: Server ServerRoutes
serverHandlers = homeHandler
where
send f u =
- pure $ HtmlPage $ f Model { modelUri = u, people = [] }
+ pure $ HtmlPage $ f Model { uri = u, people = NotAsked }
homeHandler = send home goHome