Skip to content

Commit 1f9d85f

Browse files
Profpatschjgm
authored andcommitted
State: Remove unnecessary templates state field
The templates are directly pulled out of the config and then never changed, so no reason to put the field in state. There’s also no way to generate or change the state through some other mechanism as far as I can see.
1 parent 75161c9 commit 1f9d85f

File tree

5 files changed

+7
-11
lines changed

5 files changed

+7
-11
lines changed

gitit.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ main = do
105105

106106
-- start the server
107107
simpleHTTPWithSocket sock serverConf $ msum [ wiki conf
108-
, dir "_reloadTemplates" reloadTemplates
108+
, dir "_reloadTemplates" (reloadTemplates conf)
109109
]
110110

111111
data ExitOpt

src/Network/Gitit.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ wikiHandlers =
210210
]
211211

212212
-- | Recompiles the gitit templates.
213-
reloadTemplates :: ServerPart Response
214-
reloadTemplates = do
215-
liftIO recompilePageTemplate
213+
reloadTemplates :: Config -> ServerPart Response
214+
reloadTemplates cfg = do
215+
liftIO $ recompilePageTemplate cfg
216216
ok $ toResponse "Page templates have been recompiled."
217217

218218
-- | Converts a gitit Handler into a standard happstack ServerPart.

src/Network/Gitit/Initialize.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ initializeGititState conf = do
6363

6464
updateGititState $ \s -> s { sessions = Sessions M.empty
6565
, users = users'
66-
, templatesPath = templatesDir conf
6766
, renderPage = defaultRenderPage templ
6867
, plugins = plugins' }
6968

7069
-- | Recompile the page template.
71-
recompilePageTemplate :: IO ()
72-
recompilePageTemplate = do
73-
tempsDir <- queryGititState templatesPath
74-
ct <- compilePageTemplate tempsDir
70+
recompilePageTemplate :: Config -> IO ()
71+
recompilePageTemplate cfg = do
72+
ct <- compilePageTemplate (templatesDir cfg)
7573
updateGititState $ \st -> st{renderPage = defaultRenderPage ct}
7674

7775
--- | Compile a master page template named @page.st@ in the directory specified.

src/Network/Gitit/State.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import Network.Gitit.Types
3939
gititstate :: IORef GititState
4040
gititstate = unsafePerformIO $ newIORef GititState { sessions = undefined
4141
, users = undefined
42-
, templatesPath = undefined
4342
, renderPage = undefined
4443
, plugins = undefined }
4544

src/Network/Gitit/Types.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ data User = User {
263263
data GititState = GititState {
264264
sessions :: Sessions SessionData,
265265
users :: M.Map String User,
266-
templatesPath :: FilePath,
267266
renderPage :: PageLayout -> Html -> Handler,
268267
plugins :: [Plugin]
269268
}

0 commit comments

Comments
 (0)