+= ( eelem "page"
+= sattr "name" (redirName page)
+= sattr "redirect" (redirDest page)
+ += sattr "isLocked" (yesOrNo $ redirIsLocked page)
+= sattr "revision" (show $ redirRevision page)
+= sattr "lastModified" (formatW3CDateTime lastMod)
)) -<< ()
let (isBinary, content)
= case (textData, binaryData) of
(Just text, Nothing ) -> (False, L.pack $ UTF8.encode text )
- (Nothing , Just binary) -> (True , L.pack $ fromJust $ B64.decode binary)
+ (Nothing , Just binary) -> (True , L.pack $ fromJust $ B64.decode $ dropWhitespace binary)
_ -> error "one of textData or binaryData is required"
mimeType
= if isBinary then
, entityContent = content
, entityUpdateInfo = updateInfo
}
+ where
+ dropWhitespace :: String -> String
+ dropWhitespace [] = []
+ dropWhitespace (x:xs)
+ | x == ' ' || x == '\t' || x == '\n'
+ = dropWhitespace xs
+ | otherwise
+ = x : dropWhitespace xs
parseUpdateInfo :: (ArrowXml a, ArrowChoice a) => a XmlTree UpdateInfo
)
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
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: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
-> getPage sto name (Just rev) >>= return . fromJust
) result
- mkPageList pages
+ mkPageList showSummary pages
}
where
- mkPageList :: [Page] -> IO BlockElement
- mkPageList pages
- = do items <- mapM 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 -> IO ListItem
- mkListItem page
+ mkListItem :: Bool -> Page -> IO ListItem
+ mkListItem showSummary page
= do lastMod <- utcToLocalZonedTime (entityLastMod page)
return ( [ Inline ( PageLink {
linkPage = Just (pageName page)
)
]
++
- case entitySummary page of
- Just s -> [ Block (Paragraph [Text s]) ]
- Nothing -> []
+ case (showSummary, entitySummary page) of
+ (True, Just s)
+ -> [ Block (Paragraph [Text s]) ]
+ _ -> []
)