diff --git a/gitit.hs b/gitit.hs index 2f9d6203e..47b8d45d6 100644 --- a/gitit.hs +++ b/gitit.hs @@ -105,7 +105,7 @@ main = do -- start the server simpleHTTPWithSocket sock serverConf $ msum [ wiki conf - , dir "_reloadTemplates" reloadTemplates + , dir "_reloadTemplates" (reloadTemplates conf) ] data ExitOpt diff --git a/src/Network/Gitit.hs b/src/Network/Gitit.hs index 57d8f2270..fc1f293ba 100644 --- a/src/Network/Gitit.hs +++ b/src/Network/Gitit.hs @@ -210,9 +210,9 @@ wikiHandlers = ] -- | Recompiles the gitit templates. -reloadTemplates :: ServerPart Response -reloadTemplates = do - liftIO recompilePageTemplate +reloadTemplates :: Config -> ServerPart Response +reloadTemplates cfg = do + liftIO $ recompilePageTemplate cfg ok $ toResponse "Page templates have been recompiled." -- | Converts a gitit Handler into a standard happstack ServerPart. diff --git a/src/Network/Gitit/Initialize.hs b/src/Network/Gitit/Initialize.hs index 2cedef75a..009e5a41f 100644 --- a/src/Network/Gitit/Initialize.hs +++ b/src/Network/Gitit/Initialize.hs @@ -63,15 +63,13 @@ initializeGititState conf = do updateGititState $ \s -> s { sessions = Sessions M.empty , users = users' - , templatesPath = templatesDir conf , renderPage = defaultRenderPage templ , plugins = plugins' } -- | Recompile the page template. -recompilePageTemplate :: IO () -recompilePageTemplate = do - tempsDir <- queryGititState templatesPath - ct <- compilePageTemplate tempsDir +recompilePageTemplate :: Config -> IO () +recompilePageTemplate cfg = do + ct <- compilePageTemplate (templatesDir cfg) updateGititState $ \st -> st{renderPage = defaultRenderPage ct} --- | Compile a master page template named @page.st@ in the directory specified. diff --git a/src/Network/Gitit/State.hs b/src/Network/Gitit/State.hs index aef2e3ea3..41d0fb261 100644 --- a/src/Network/Gitit/State.hs +++ b/src/Network/Gitit/State.hs @@ -39,7 +39,6 @@ import Network.Gitit.Types gititstate :: IORef GititState gititstate = unsafePerformIO $ newIORef GititState { sessions = undefined , users = undefined - , templatesPath = undefined , renderPage = undefined , plugins = undefined } diff --git a/src/Network/Gitit/Types.hs b/src/Network/Gitit/Types.hs index 4b95759cb..793cd5d6c 100644 --- a/src/Network/Gitit/Types.hs +++ b/src/Network/Gitit/Types.hs @@ -263,7 +263,6 @@ data User = User { data GititState = GititState { sessions :: Sessions SessionData, users :: M.Map String User, - templatesPath :: FilePath, renderPage :: PageLayout -> Html -> Handler, plugins :: [Plugin] }