From ba784701b489e768c3f35b6c7d809ee0c9791d85 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 21 Apr 2015 17:26:26 +0200 Subject: [PATCH] Automatically server every static file --- src/Application.hs | 11 +++++++---- src/Breve/Common.hs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index fef719f..4037272 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -24,13 +24,16 @@ app runner = do ServerSettings {..} <- newServerSettings table <- load urlTable - css <- getDataFileName "layouts/main.css" - index <- getDataFileName "views/index.html" - done <- getDataFileName "views/done.html" + static <- getDataFileName "static/" + index <- getDataFileName "views/index.html" + done <- getDataFileName "views/done.html" runner $ controllerApp settings $ do get "/" (render index ()) - get "/main.css" (serveStatic css) + + get "/:file" $ do + file <- queryParam' "file" + serveStatic (static ++ file) get "/:name" $ do name <- queryParam' "name" diff --git a/src/Breve/Common.hs b/src/Breve/Common.hs index 01f8a6a..dde8958 100644 --- a/src/Breve/Common.hs +++ b/src/Breve/Common.hs @@ -26,7 +26,7 @@ data AppSettings = AppSettings {} instance HasTemplates IO AppSettings where defaultLayout = do - main <- liftIO (getDataFileName "layouts/main.html") + main <- liftIO (getDataFileName "static/main.html") Just <$> getTemplate main