From: pho Date: Wed, 23 Jan 2008 06:17:59 +0000 (+0900) Subject: preparation for feed generation X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=commitdiff_plain;h=23977989ef4be7316b1c2c3f709ca1e8e6bb7f84 preparation for feed generation darcs-hash:20080123061759-62b54-4415d6ee76fd2eaad25de840bef6087028b5c497.gz --- diff --git a/Rakka.cabal b/Rakka.cabal index 41ea367..fa0bbe4 100644 --- a/Rakka.cabal +++ b/Rakka.cabal @@ -13,6 +13,7 @@ Tested-With: GHC == 6.6.1 Cabal-Version: >= 1.2 Data-Files: + defaultPages/Feed.xml defaultpages/Help/SampleImage/Large.xml defaultpages/Help/SampleImage/Small.xml defaultPages/Help/Syntax.xml diff --git a/Rakka/Page.hs b/Rakka/Page.hs index 2785a20..62606b3 100644 --- a/Rakka/Page.hs +++ b/Rakka/Page.hs @@ -240,6 +240,7 @@ xmlizePage += ( eelem "page" += sattr "name" (redirName page) += sattr "redirect" (redirDest page) + += sattr "isLocked" (yesOrNo $ redirIsLocked page) += sattr "revision" (show $ redirRevision page) += sattr "lastModified" (formatW3CDateTime lastMod) )) -<< () @@ -344,7 +345,7 @@ parseEntity 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 @@ -370,6 +371,14 @@ parseEntity , 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 diff --git a/Rakka/Storage/Impl.hs b/Rakka/Storage/Impl.hs index 1908b48..3b48f0c 100644 --- a/Rakka/Storage/Impl.hs +++ b/Rakka/Storage/Impl.hs @@ -131,6 +131,7 @@ openIndex indexDir revFile $ removeFile revFile Right index <- openDatabase indexDir (Writer [Create []]) + addAttrIndex index "@type" StrIndex addAttrIndex index "@uri" SeqIndex addAttrIndex index "rakka:revision" SeqIndex noticeM logger ("Created an H.E. index on " ++ indexDir) diff --git a/Rakka/Wiki/Interpreter/PageList.hs b/Rakka/Wiki/Interpreter/PageList.hs index 2815bda..1ad6728 100644 --- a/Rakka/Wiki/Interpreter/PageList.hs +++ b/Rakka/Wiki/Interpreter/PageList.hs @@ -3,11 +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 @@ -35,12 +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: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,17 +57,17 @@ recentUpdatesInterp -> 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) @@ -72,7 +80,8 @@ recentUpdatesInterp ) ] ++ - case entitySummary page of - Just s -> [ Block (Paragraph [Text s]) ] - Nothing -> [] + case (showSummary, entitySummary page) of + (True, Just s) + -> [ Block (Paragraph [Text s]) ] + _ -> [] ) diff --git a/defaultPages/Feed.xml b/defaultPages/Feed.xml new file mode 100644 index 0000000..90a61a0 --- /dev/null +++ b/defaultPages/Feed.xml @@ -0,0 +1,9 @@ + + + + +]]> + + \ No newline at end of file