X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FEnvironment.hs;h=881a9e69ef40fe3f8023fb81aafc80bb90f08b2f;hb=03585f9c5773f6c0b59497f4f563909576c402b5;hp=e793d0001f401b7e07a1c0b4fd9c38bc10787a4b;hpb=484e15845d9c06d0fa62044d3b6b3ff8c78a6e04;p=Rakka.git diff --git a/Rakka/Environment.hs b/Rakka/Environment.hs index e793d00..881a9e6 100644 --- a/Rakka/Environment.hs +++ b/Rakka/Environment.hs @@ -1,11 +1,21 @@ module Rakka.Environment ( Environment(..) , setupEnv + + , getSiteName + , getSiteNameA + + , getBaseURI + , getBaseURIA ) where +import Control.Arrow.ArrowIO +import qualified Data.ByteString.Char8 as C8 +import Data.Maybe import Network import qualified Network.HTTP.Lucu.Config as LC +import Network.URI import Rakka.Storage @@ -26,4 +36,33 @@ setupEnv lsdir portNum envLocalStateDir = lsdir , envLucuConf = lucuConf , envStorage = storage - } \ No newline at end of file + } + + +getSiteName :: Environment -> IO String +getSiteName env + = return "Rakka" -- FIXME + + +getSiteNameA :: ArrowIO a => Environment -> a b String +getSiteNameA = arrIO0 . getSiteName + + +getBaseURI :: Environment -> IO URI +getBaseURI env + = do let conf = envLucuConf env + host = C8.unpack $ LC.cnfServerHost conf + port = case LC.cnfServerPort conf of + PortNumber num -> fromIntegral num + + defaultURI + = "http://" ++ host ++ + (if port == 80 + then "" + else ':' : show port) ++ "/" + + return $ fromJust $ parseURI defaultURI -- FIXME + + +getBaseURIA :: ArrowIO a => Environment -> a b URI +getBaseURIA = arrIO0 . getBaseURI \ No newline at end of file