about summary refs log tree commit diff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorVincent Ambo <dev@tazj.in>2014-03-11T17·22+0100
committerVincent Ambo <dev@tazj.in>2014-03-11T17·22+0100
commitf2b5e14ceedeabf9ee8bb673b2f3c765a9b81670 (patch)
tree80fcc747d449e3302ab104c5e4b98391a238c1d8 /src/Main.hs
parentb4b2b053b9313b708e579310a87009ec4ff6eb43 (diff)
Add an option for the resource folder
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Main.hs b/src/Main.hs
index a684db4e052a..67440e6f0eb9 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -44,7 +44,8 @@ import           RSS
 
 data MainOptions = MainOptions {
   optState :: String,
-  optPort  :: Int
+  optPort  :: Int,
+  optRes   :: String
 }
 
 instance Options MainOptions where
@@ -53,7 +54,9 @@ instance Options MainOptions where
         "Directory in which the BlogState is located."
     <*> simpleOption "port" 8000
         "Port to run on. Default is 8000."
-
+    <*> simpleOption "res" "/usr/share/tazblog/res"
+        "Resources folder location."
+        
 tmpPolicy :: BodyPolicy
 tmpPolicy = defaultBodyPolicy "./tmp/" 0 200000 1000
 
@@ -63,10 +66,10 @@ main = do
     runCommand $ \opts args ->
       bracket (openLocalStateFrom (optState opts ++ "BlogState") initialBlogState)
               createCheckpointAndClose
-              (\acid -> simpleHTTP nullConf {port = optPort opts} $ tazBlog acid)
+              (\acid -> simpleHTTP nullConf {port = optPort opts} $ tazBlog acid (optRes opts))
 
-tazBlog :: AcidState Blog -> ServerPart Response
-tazBlog acid = do
+tazBlog :: AcidState Blog -> String -> ServerPart Response
+tazBlog acid resDir = do
     compr <- compressedResponseFilter
     msum [ path $ \(lang :: BlogLang) -> blogHandler acid lang
          , nullDir >> showIndex acid EN
@@ -104,8 +107,8 @@ tazBlog acid = do
               ok $ toResponse blogStyle
          , do setHeaderM "cache-control" "max-age=630720000"
               setHeaderM "expires" "Tue, 20 Jan 2037 04:20:42 GMT"
-              dir "static" $ serveDirectory DisableBrowsing [] "../res"
-         , serveDirectory DisableBrowsing [] "../res"
+              dir "static" $ serveDirectory DisableBrowsing [] resDir
+         , serveDirectory DisableBrowsing [] resDir
          , notFound $ toResponse $ showError NotFound DE
          ]