import Data.Maybe
import Data.Set (Set)
import qualified Data.Set as S
+import Data.Time
import Network.HTTP.Lucu
import Network.HTTP.Lucu.Utils
import Network.URI
import Rakka.Storage.DefaultPage
import Rakka.Storage.Repos
import Rakka.Storage.Types
+import Rakka.W3CDateTime
import Subversion.Types
import Subversion.FileSystem
import Subversion.Repository
$ removeFile revFile
Right index <- openDatabase indexDir (Writer [Create []])
+ addAttrIndex index "@mdate" SeqIndex
addAttrIndex index "@type" StrIndex
addAttrIndex index "@uri" SeqIndex
addAttrIndex index "rakka:revision" SeqIndex
fromId :: [String] -> DocumentID -> IO HitPage
fromId words docId
= do uri <- getDocURI index docId
- rev <- getDocAttr index docId "rakka:revision"
- >>= return . read . fromJust
+ rev <- unsafeInterleaveIO $
+ getDocAttr index docId "rakka:revision"
+ >>=
+ return . read . fromJust
+ lastMod <- unsafeInterleaveIO $
+ getDocAttr index docId "@mdate"
+ >>=
+ return . zonedTimeToUTC . fromJust . parseW3CDateTime . fromJust
+ summary <- unsafeInterleaveIO $
+ getDocAttr index docId "rakka:summary"
snippet <- unsafeInterleaveIO $
do doc <- getDocument index docId [NoAttributes, NoKeywords]
sn <- makeSnippet doc words 300 80 80
return HitPage {
hpPageName = decodePageName $ uriPath uri
, hpPageRev = rev
+ , hpLastMod = lastMod
+ , hpSummary = summary
, hpSnippet = snippet
}
import Data.Maybe
import Data.Time
import Network.HTTP.Lucu.RFC1123DateTime
-import Rakka.Page
import Rakka.Storage
import Rakka.Utils
import Rakka.Wiki
setMax cond items
result <- searchPages sto cond
- pages <- mapM (getPageByHP sto) (srPages result)
-
- mkPageList showSummary pages
+ mkPageList showSummary (srPages result)
}
where
- getPageByHP :: Storage -> HitPage -> IO Page
- getPageByHP sto hp
- = getPage sto (hpPageName hp) (Just (hpPageRev hp)) >>= return . fromJust
-
- mkPageList :: Bool -> [Page] -> IO BlockElement
+ mkPageList :: Bool -> [HitPage] -> IO BlockElement
mkPageList showSummary pages
= do items <- mapM (mkListItem showSummary) pages
return (Div [("class", "recentUpdates")]
[ Block (List Bullet items) ])
- mkListItem :: Bool -> Page -> IO ListItem
+ mkListItem :: Bool -> HitPage -> IO ListItem
mkListItem showSummary page
- = do lastMod <- utcToLocalZonedTime (entityLastMod page)
+ = do lastMod <- utcToLocalZonedTime (hpLastMod page)
return ( [ Inline ( PageLink {
- linkPage = Just (pageName page)
+ linkPage = Just (hpPageName page)
, linkFragment = Nothing
, linkText = Nothing
}
)
]
++
- case (showSummary, entitySummary page) of
+ case (showSummary, hpSummary page) of
(True, Just s)
-> [ Block (Paragraph [Text s]) ]
_ -> []