summaryrefslogtreecommitdiff
path: root/Com
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-11-02 17:15:03 -0700
committerBen Sima <ben@bsima.me>2019-11-02 17:15:28 -0700
commit03e5cc700b48c847bc8225281f033a103ccf23fe (patch)
treea40d50d9fc9a951b67cc8475cbd74f82205ceac1 /Com
parent439a7e9aa6569fc1410989d5bf90aa485143f132 (diff)
Link static directory properly
Diffstat (limited to 'Com')
-rw-r--r--Com/InfluencedByBooks/Apex.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/Com/InfluencedByBooks/Apex.hs b/Com/InfluencedByBooks/Apex.hs
index c154f95..20b4e65 100644
--- a/Com/InfluencedByBooks/Apex.hs
+++ b/Com/InfluencedByBooks/Apex.hs
@@ -37,12 +37,14 @@ import System.Environment (lookupEnv)
main :: IO ()
main = do
say "rise: ibb"
+ staticDir <- fromMaybe "static"
+ <$> lookupEnv "STATIC_DIR" :: IO [Char]
port <- read
- <$> fromMaybe "3000"
- <$> lookupEnv "PORT" :: IO Int
+ <$> fromMaybe "3000"
+ <$> lookupEnv "PORT" :: IO Int
keep <- Keep.openLocal "keep/"
say "port: 3000"
- run port $ logStdout $ compress $ app $ keep
+ run port $ logStdout $ compress $ app staticDir $ keep
where
compress = gzip def { gzipFiles = GzipCompress }
@@ -55,7 +57,7 @@ instance L.ToHtml a => L.ToHtml (HtmlPage a) where
L.doctypehtml_ $ do
L.head_ $ do
L.meta_ [L.charset_ "utf-8"]
- jsRef "/static/all.js"
+ jsRef "/static/ibb.js"
cssRef "/css/main.css"
L.body_ $ do
page
@@ -102,8 +104,8 @@ cssHandlers :: Server CssRoute
cssHandlers = return . Lazy.toStrict . Clay.render
$ Look.main
-app :: AcidState Keep.IbbKeep -> Application
-app keep = serve
+app :: [Char] -> AcidState Keep.IbbKeep -> Application
+app staticDir keep = serve
(Proxy @Routes)
$ static
:<|> cssHandlers
@@ -111,7 +113,8 @@ app keep = serve
:<|> apiHandlers keep
:<|> Tagged handle404
where
- static = serveDirectoryWith (defaultWebAppSettings "ibb.jsexe")
+ static = serveDirectoryWith
+ (defaultWebAppSettings $ staticDir)
type ApiRoutes =
"people" :> Get '[JSON] [Person]