X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki%2FInterpreter%2FPageList.hs;h=2fe9d305fc46509926a60aa6b1ddff9d22a5c403;hb=d717326c5f603dd140a0b5ee27b412e5e09685cd;hp=cffd93806f20c50b490dec6af1a9ac5596198a72;hpb=b4c0033f297c28d95ad9298b489126331224bc42;p=Rakka.git diff --git a/Rakka/Wiki/Interpreter/PageList.hs b/Rakka/Wiki/Interpreter/PageList.hs index cffd938..2fe9d30 100644 --- a/Rakka/Wiki/Interpreter/PageList.hs +++ b/Rakka/Wiki/Interpreter/PageList.hs @@ -6,17 +6,37 @@ module Rakka.Wiki.Interpreter.PageList import Control.Monad import Data.Maybe import Data.Time -import Network.HTTP.Lucu.RFC1123DateTime -import Rakka.Page +import qualified Data.Time.RFC1123 as RFC1123 +import Network.URI import Rakka.Storage +import Rakka.SystemConfig import Rakka.Utils import Rakka.Wiki import Rakka.Wiki.Interpreter +import System.FilePath import Text.HyperEstraier interpreters :: [Interpreter] -interpreters = [ recentUpdatesInterp ] +interpreters = [ recentUpdatesURLInterp + , recentUpdatesInterp + ] + + +recentUpdatesURLInterp :: Interpreter +recentUpdatesURLInterp + = InlineCommandInterpreter { + iciName = "recentUpdatesURL" + , iciInterpret + = \ ctx _ -> do BaseURI baseURI <- getSysConf (ctxSysConf ctx) + let uri = baseURI { + uriPath = uriPath baseURI "search.html" + , uriQuery = '?' : mkQueryString [ ("q" , "[UVSET]") + , ("order", "@mdate NUMD") + ] + } + return $ ExternalLink uri (Just "List all pages") + } --
@@ -53,36 +73,29 @@ recentUpdatesInterp 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) - return ( [ Inline ( PageLink { - linkPage = Just (pageName page) - , linkFragment = Nothing - , linkText = Nothing - } - ) + = do lastMod <- utcToLocalZonedTime (hpLastMod page) + return ( [ Inline PageLink { + linkPage = Just (hpPageName page) + , linkFragment = Nothing + , linkText = Nothing + } , Block ( Div [("class", "date")] - [Inline (Text (formatRFC1123DateTime lastMod))] + [Inline (Text (RFC1123.format lastMod))] ) ] ++ - case (showSummary, entitySummary page) of + case (showSummary, hpSummary page) of (True, Just s) -> [ Block (Paragraph [Text s]) ] _ -> []