]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
/search.xml should contain lastMod
authorpho <pho@cielonegro.org>
Fri, 22 Feb 2008 13:34:47 +0000 (22:34 +0900)
committerpho <pho@cielonegro.org>
Fri, 22 Feb 2008 13:34:47 +0000 (22:34 +0900)
darcs-hash:20080222133447-62b54-8f0aacc9290d9193c6dc051c6d68dc9c2ba965cf.gz

Rakka/Resource/Search.hs

index 7c2acae6ad018f79619a7cc398c27a55d7fb0933..20f51c6540931d79ae3c1cae1e1059d5f331a79d 100644 (file)
@@ -11,6 +11,7 @@ import           Control.Arrow.ArrowList
 import           Control.Arrow.ArrowTree
 import           Control.Monad.Trans
 import           Data.Maybe
+import           Data.Time
 import           Network.HTTP.Lucu
 import           Network.URI hiding (query, fragment)
 import           Rakka.Environment
@@ -19,6 +20,7 @@ import           Rakka.Resource
 import           Rakka.Storage
 import           Rakka.SystemConfig
 import           Rakka.Utils
+import           Rakka.W3CDateTime
 import           Rakka.Wiki.Engine
 import           System.FilePath
 import           Text.HyperEstraier hiding (getText)
@@ -55,7 +57,7 @@ maxSectionWindowSize = 10
                 to="5"
                 total="5">
 
-    <page name="Page/1">
+    <page name="Page/1" lastModified="2000-01-01T00:00:00">
       aaa <hit>foo</hit> bbb
     </page>
 
@@ -101,22 +103,29 @@ handleSearch env
                setMax    cond (to - from)
                return cond
 
-      mkPageElem :: ArrowXml a => a HitPage XmlTree
+      mkPageElem :: (ArrowChoice a, ArrowXml a, ArrowIO a) => a HitPage XmlTree
       mkPageElem = ( eelem "page"
                      += attr "name" (arr hpPageName >>> mkText)
+                     += attr "lastModified" ( arrIO (utcToLocalZonedTime . hpLastMod)
+                                              >>>
+                                              arr formatW3CDateTime
+                                              >>>
+                                              mkText
+                                            )
                      += ( arrL hpSnippet
                           >>>
                           mkSnippetTree
                         )
                    )
 
-      mkSnippetTree :: ArrowXml a => a SnippetFragment XmlTree
+      mkSnippetTree :: (ArrowChoice a, ArrowXml a) => a SnippetFragment XmlTree
       mkSnippetTree = proc fragment
                     -> case fragment of
-                         Boundary          -> eelem "boundary"
-                         NormalText      t -> txt t
-                         HighlightedWord w -> eelem "hit" += txt w
-                         -<< ()
+                         Boundary          -> eelem "boundary" -< ()
+                         NormalText      t -> mkText           -< t
+                         HighlightedWord w -> ( eelem "hit"
+                                                += mkText
+                                              ) -< w
 
 
 searchResultToXHTML :: (ArrowXml a, ArrowChoice a, ArrowIO a) => Environment -> a XmlTree XmlTree