Tested-With:
GHC == 6.6.1
Build-Depends:
- Crypto, FileManip, HUnit, HsHyperEstraier, HsSVN, Lucu, base,
- encoding, filepath, hslogger, hxt, mtl, network, parsec, stm, unix
+ Crypto, FileManip, HUnit, HsHyperEstraier >= 0.2, HsSVN, Lucu,
+ base, encoding, filepath, hslogger, hxt, mtl, network, parsec,
+ stm, unix
Data-Files:
defaultpages/Help/SampleImage/Large
defaultpages/Help/SampleImage/Small
handleGet :: Environment -> PageName -> Resource ()
handleGet env name
- = do pageM <- getPage (envStorage env) name
+ = do pageM <- getPage (envStorage env) name Nothing
case pageM of
Nothing
-> foundNoEntity Nothing
handleGet :: Environment -> PageName -> Resource ()
handleGet env name
= runIdempotentA $ proc ()
- -> do pageM <- getPageA (envStorage env) -< name
+ -> do pageM <- getPageA (envStorage env) -< (name, Nothing)
case pageM of
Nothing
-> handlePageNotFound env -< name
import Control.Monad
import Control.Monad.Trans
import Data.Set (Set)
+import qualified Data.Set as S
import Rakka.Page
import Rakka.Storage.DefaultPage
import Subversion.Types
return sto
-getPage :: MonadIO m => Storage -> PageName -> m (Maybe Page)
-getPage sto name
- = liftIO $ loadDefaultPage name -- FIXME
+getPage :: MonadIO m => Storage -> PageName -> Maybe RevNum -> m (Maybe Page)
+getPage = ((liftIO .) .) . getPage' . stoRepository
-putPage :: MonadIO m => Storage -> Maybe RevNum -> Page -> m ()
-putPage sto oldRev page
+getPage' :: Repository -> PageName -> Maybe RevNum -> IO (Maybe Page)
+getPage' repos name rev
+ = loadDefaultPage name -- FIXME
+
+
+putPage :: MonadIO m => Storage -> Page -> RevNum -> m ()
+putPage sto page oldRev
= error "FIXME: not implemented"
-getPageA :: ArrowIO a => Storage -> a PageName (Maybe Page)
-getPageA = arrIO . getPage
+getPageA :: ArrowIO a => Storage -> a (PageName, Maybe RevNum) (Maybe Page)
+getPageA = arrIO2 . getPage
-putPageA :: ArrowIO a => Storage -> a (Maybe RevNum, Page) ()
+putPageA :: ArrowIO a => Storage -> a (Page, RevNum) ()
putPageA = arrIO2 . putPage
findAllPages :: Storage -> RevNum -> IO (Set PageName)
-findAllPages sto revNum
+findAllPages _ 0 = findAllDefaultPages
+findAllPages sto rev
= findAllDefaultPages -- FIXME
findChangedPages :: Storage -> RevNum -> RevNum -> IO (Set PageName)
findChangedPages sto 0 newRev = findAllPages sto newRev
findChangedPages sto oldRev newRev
- = fail "fixme: not impl"
+ = fail "FIXME: not impl"
getCurrentRevNum :: Storage -> IO RevNum
debugM logger ("The repository revision is currently " ++ show newRev)
when (newRev /= oldRev) (syncIndex' oldRev newRev)
-
- return oldRev -- FIXME
- --return newRev
+ return newRev
where
syncIndex' :: RevNum -> RevNum -> IO ()
syncIndex' oldRev newRev
= do pages <- findChangedPages sto oldRev newRev
- print pages -- FIXME
+ mapM_ (updateIndex sto newRev) (S.toList pages)
+
+
+updateIndex :: Storage -> RevNum -> PageName -> IO ()
+updateIndex sto rev name
+ = do pageM <- getPage sto name (Just rev)
+ case pageM of
+ -- ページが削除された
+ Nothing
+ -> do docIdM <- getDocIdByURI (stoIndexDB sto) (mkRakkaURI name)
+ case docIdM of
+ Nothing -> return ()
+ Just docId -> do removeDocument (stoIndexDB sto) docId [CleaningRemove]
+ infoM logger ("Removed page " ++ name ++ " from the index")
+ Just page
+ -> do draft <- stoMakeDraft sto page
+ putDocument (stoIndexDB sto) draft [CleaningPut]
+ infoM logger ("Indexed page " ++ name ++ " of revision " ++ show (pageRevision page))
updateIndexRev :: Storage -> (RevNum -> IO RevNum) -> IO ()
BaseURI baseURI <- getSysConfA sysConf -< ()
StyleSheet cssName <- getSysConfA sysConf -< ()
- Just pageTitle <- getPageA sto -< "PageTitle"
- Just leftSideBar <- getPageA sto -< "SideBar/Left"
- Just rightSideBar <- getPageA sto -< "SideBar/Right"
+ Just pageTitle <- getPageA sto -< ("PageTitle" , Nothing)
+ Just leftSideBar <- getPageA sto -< ("SideBar/Left" , Nothing)
+ Just rightSideBar <- getPageA sto -< ("SideBar/Right", Nothing)
tree <- ( eelem "/"
+= ( eelem "page"
BaseURI baseURI <- getSysConfA sysConf -< ()
StyleSheet cssName <- getSysConfA sysConf -< ()
- Just pageTitle <- getPageA sto -< "PageTitle"
- Just leftSideBar <- getPageA sto -< "SideBar/Left"
- Just rightSideBar <- getPageA sto -< "SideBar/Right"
+ Just pageTitle <- getPageA sto -< ("PageTitle" , Nothing)
+ Just leftSideBar <- getPageA sto -< ("SideBar/Left" , Nothing)
+ Just rightSideBar <- getPageA sto -< ("SideBar/Right", Nothing)
tree <- ( eelem "/"
+= ( eelem "pageNotFound"
* [[#example]]
* [http://www.google.com/]
* [http://www.google.com/ Google]
+* [[[Page]]]
+* [[[Page|Link to object of "Page"]]]
<div id="example">example</div>
== Subsection ==
-* [[[Help/Syntax]]]
-* [[[Help/Syntax|Object of Help/Syntax]]]
* [[Help/Syntax]]
* [http://cielonegro.org/]
* [http://cielonegro.org/ CieloNegro]