X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki%2FInterpreter%2FPageList.hs;h=1ad6728c3ba370649cb961b8deeb8e452727ab2a;hb=23977989ef4be7316b1c2c3f709ca1e8e6bb7f84;hp=2a10372d1b4e253c6cf174e11cb2ca7d2236e1c1;hpb=e43bb104a7313dd696b8bb8aa3bafff94706a187;p=Rakka.git diff --git a/Rakka/Wiki/Interpreter/PageList.hs b/Rakka/Wiki/Interpreter/PageList.hs index 2a10372..1ad6728 100644 --- a/Rakka/Wiki/Interpreter/PageList.hs +++ b/Rakka/Wiki/Interpreter/PageList.hs @@ -3,10 +3,13 @@ module Rakka.Wiki.Interpreter.PageList ) where +import Control.Monad import Data.Maybe +import Data.Time import Network.HTTP.Lucu.RFC1123DateTime import Rakka.Page import Rakka.Storage +import Rakka.Utils import Rakka.Wiki import Rakka.Wiki.Interpreter import Text.HyperEstraier @@ -20,7 +23,7 @@ interpreters = [ recentUpdatesInterp ] --
-- blah blah... --
@@ -34,13 +37,18 @@ recentUpdatesInterp bciName = "recentUpdates" , bciInterpret = \ ctx (BlockCommand _ args _) - -> do let items = fromMaybe 10 $ fmap read $ lookup "items" args - sto = ctxStorage ctx + -> do let items = fromMaybe 10 $ fmap read $ lookup "items" args + showSummary = fromMaybe True $ fmap parseYesOrNo $ lookup "showSummary" args + onlyEntity = fromMaybe True $ fmap parseYesOrNo $ lookup "onlyEntity" args + onlySummarized = fromMaybe True $ fmap parseYesOrNo $ lookup "onlySummarized" args + sto = ctxStorage ctx cond <- newCondition setPhrase cond "[UVSET]" - addAttrCond cond "rakka:isBoring STREQ no" - addAttrCond cond "rakka:summary STRNE" -- summary ã空ã§ãªã + when onlyEntity + $ addAttrCond cond "@type STRNE application/x-rakka-redirection" + when onlySummarized + $ addAttrCond cond "rakka:summary STRNE" -- summary ã空ã§ãªã setOrder cond "@mdate NUMD" setMax cond items @@ -49,27 +57,31 @@ recentUpdatesInterp -> getPage sto name (Just rev) >>= return . fromJust ) result - return $ mkPageList pages + mkPageList showSummary pages } where - mkPageList :: [Page] -> BlockElement - mkPageList pages - = Div [("class", "recentUpdates")] - [ Block (List Bullet (map mkListItem pages)) ] + mkPageList :: Bool -> [Page] -> IO BlockElement + mkPageList showSummary pages + = do items <- mapM (mkListItem showSummary) pages + return (Div [("class", "recentUpdates")] + [ Block (List Bullet items) ]) - mkListItem :: Page -> ListItem - mkListItem page - = [ Inline ( PageLink { - linkPage = Just (pageName page) - , linkFragment = Nothing - , linkText = Nothing - } - ) - , Inline ( Span [("class", "date")] - [Text (formatRFC1123DateTime (pageLastMod page))] - ) - ] - ++ - case pageSummary page of - Just s -> [ Block (Paragraph [Text s]) ] - Nothing -> [] + mkListItem :: Bool -> Page -> IO ListItem + mkListItem showSummary page + = do lastMod <- utcToLocalZonedTime (entityLastMod page) + return ( [ Inline ( PageLink { + linkPage = Just (pageName page) + , linkFragment = Nothing + , linkText = Nothing + } + ) + , Block ( Div [("class", "date")] + [Inline (Text (formatRFC1123DateTime lastMod))] + ) + ] + ++ + case (showSummary, entitySummary page) of + (True, Just s) + -> [ Block (Paragraph [Text s]) ] + _ -> [] + )