, pageOtherLang :: !(Map LanguageTag PageName)
, pageContent :: !Lazy.ByteString
}
+ deriving (Show, Eq)
-- UTF-8 に encode してから 0x20 - 0x7E の範圍を除いて URI escape する。
loadDefaultPage name
-- ./defaultPages が存在するなら、./defaultPages/Foo.xml を探す。無
-- ければ Cabal で defaultPages/Foo.xml を探す。
- = do let pagePath = "defaultPages" </> (encodePageName name `addExtension` "xml")
+ = do let pagePath = "defaultPages" </> encodePageName name <.> "xml"
localDirExists <- doesLocalDirExist
if localDirExists then
findChangedPages :: Repository -> RevNum -> RevNum -> IO (Set PageName)
findChangedPages repos 0 newRev = findAllPages repos newRev
findChangedPages repos oldRev newRev
- = findAllPages repos newRev -- FIXME
+ = mapM (findChangedPagesAtRevision repos) [oldRev + 1 .. newRev]
+ >>=
+ return . S.unions
getCurrentRevNum :: Repository -> IO RevNum
module Rakka.Storage.Repos
( findAllPagesInRevision
+ , findChangedPagesAtRevision
, loadPageInRepository
)
where
+import Control.Monad
+import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Set (Set)
decodePath = decodePageName . makeRelative root . dropExtension
+findChangedPagesAtRevision :: Repository -> RevNum -> IO (Set PageName)
+findChangedPagesAtRevision repos rev
+ = do fs <- getRepositoryFS repos
+ withRevision fs rev
+ $ getPathsChanged >>= return . foldl accumulatePages S.empty . map fst
+ where
+ accumulatePages :: Set PageName -> FilePath -> Set PageName
+ accumulatePages s path
+ | "/pages/" `isPrefixOf` path && ".page" `isSuffixOf` path
+ = let encoded = makeRelative "/pages" $ dropExtension path
+ name = decodePageName encoded
+ in
+ S.insert name s
+ | otherwise
+ = s
+
+
loadPageInRepository :: Repository -> PageName -> Maybe RevNum -> IO (Maybe Page)
loadPageInRepository repos name rev
= do fs <- getRepositoryFS repos
-> return Nothing
where
path :: FilePath
- path = "pages" </> (encodePageName name `addExtension` "page")
+ path = "pages" </> encodePageName name <.> "page"
loadPage' :: Rev Page
loadPage' = do redirect <- getNodeProp path "rakka:redirect"