Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow compilation against directory < 1.2 also.

  • Loading branch information...
commit 624b33d4c4a20bed5998df056be6dc38fe8f3f53 1 parent 207494c
@jgm authored
View
11 Network/Gitit/Cache.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-
Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
@@ -28,6 +29,11 @@ import qualified Data.ByteString as B (ByteString, readFile, writeFile)
import System.FilePath
import System.Directory (doesFileExist, removeFile, createDirectoryIfMissing, getModificationTime)
import Data.Time.Clock (UTCTime)
+#if MIN_VERSION_directory(1,2,0)
+#else
+import System.Time (ClockTime(..))
+import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
+#endif
import Network.Gitit.State
import Network.Gitit.Types
import Control.Monad
@@ -60,7 +66,12 @@ lookupCache file = do
exists <- liftIO $ doesFileExist target
if exists
then liftIO $ do
+#if MIN_VERSION_directory(1,2,0)
modtime <- getModificationTime target
+#else
+ TOD secs _ <- getModificationTime target
+ let modtime = posixSecondsToUTCTime $ fromIntegral secs
+#endif
contents <- B.readFile target
return $ Just (modtime, contents)
else return Nothing
View
9 Network/Gitit/Handlers.hs
@@ -77,7 +77,8 @@ import Control.Monad.Reader
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString as S
import Network.HTTP (urlEncodeVars)
-import Data.Time.Clock
+import Data.Time (getCurrentTime, addUTCTime)
+import Data.Time.Clock (diffUTCTime, UTCTime(..))
import Data.FileStore
import System.Log.Logger (logM, Priority(..))
@@ -110,9 +111,9 @@ randomPage :: Handler
randomPage = do
fs <- getFileStore
files <- liftIO $ index fs
- let pages = map dropExtension $
- filter (\f -> isPageFile f && not (isDiscussPageFile f)) files
base' <- getWikiBase
+ let pages = map dropExtension $
+ filter (\f -> isPageFile f && not (isDiscussPageFile f)) files
if null pages
then error "No pages found!"
else do
@@ -768,7 +769,7 @@ feedHandler = do
let file = (path' `orIfNull` "_site") <.> "feed"
let mbPath = if null path' then Nothing else Just path'
-- first, check for a cached version that is recent enough
- now <- liftIO $ getCurrentTime
+ now <- liftIO getCurrentTime
let isRecentEnough t = truncate (diffUTCTime now t) < 60 * feedRefreshTime cfg
mbCached <- lookupCache file
case mbCached of
View
2  gitit.cabal
@@ -138,7 +138,7 @@ Executable gitit
pandoc-types >= 1.9.0.2 && < 1.10,
process,
filepath,
- directory >= 1.2,
+ directory,
mtl,
cgi,
old-time,
Please sign in to comment.
Something went wrong with that request. Please try again.