packages feed

gitit 0.9.0.1 → 0.10

raw patch · 8 files changed

+116/−22 lines, 8 filesdep ~blaze-htmldep ~filestorePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: blaze-html, filestore

API changes (from Hackage documentation)

- Network.Gitit: extractCategories :: String -> [String]
+ Network.Gitit: readCategories :: FilePath -> IO [String]

Files

CHANGES view
@@ -1,3 +1,28 @@+Version 0.10 released 30 May 2012++*   Changed 'readFileUTF8' so it doesn't encode filename on ghc 7.4.++*   Upgraded for compatibility with blaze-html 0.5.  Closes #299.++*   Improved categories. Files are now read strictly to avoid a 'too+    many open files' error. 'Page' now exports 'readCategories' instead of+    'extractCategories'.++*   Require filestore 0.5.  This brings in (a) correct handling+    of unicode paths when compiled under GHC 7.4, and (b) a 'limit'+    parameter for 'history'. The limit parameter is essential when+    gitit is used with very large repositories; otherwise history+    commands would have to parse the entire log.  Handler functions+    that use 'history' have been updated to use the optional+    'limit' parameter.++*   Atom feeds are now limited to 200 entries, to prevent server+    overload.++*   Indicate size of default logo picture in README. Closes #291.++*   Added a README section on restricting access.  Closes #292.+ Version 0.9.0.1 released 15 Feb 2012  *   Fixed bug in fromEntities that caused text to be lost in the page
Network/Gitit/ContentTransformer.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {- Copyright (C) 2009 John MacFarlane <jgm@berkeley.edu>, Anton van Straaten <anton@appsolutions.com>@@ -89,7 +90,11 @@ import Text.Pandoc hiding (MathML, WebTeX, MathJax) import Text.Pandoc.Shared (ObfuscationMethod(..)) import Text.XHtml hiding ( (</>), dir, method, password, rev )+#if MIN_VERSION_blaze_html(0,5,0)+import Text.Blaze.Html.Renderer.String as Blaze ( renderHtml )+#else import Text.Blaze.Renderer.String as Blaze ( renderHtml )+#endif import qualified Data.Text as T import qualified Data.ByteString as S (concat) import qualified Data.ByteString.Lazy as L (toChunks, fromChunks)
Network/Gitit/Feed.hs view
@@ -73,6 +73,7 @@   let files = F.concatMap (\f -> [f, f <.> "page"]) mbPath   let startTime = addUTCTime (fromIntegral $ -60 * 60 * 24 * days) now'   rs <- history a files TimeRange{timeFrom = Just startTime, timeTo = Just now'}+          (Just 200) -- hard limit of 200 to conserve resources   return $ sortBy (comparing revDateTime) rs  generateEmptyfeed :: Generator -> String ->String ->Maybe String -> [Person] -> Date -> Feed
Network/Gitit/Handlers.hs view
@@ -58,11 +58,11 @@ import Network.Gitit.Layout import Network.Gitit.Types import Network.Gitit.Feed (filestoreToXmlFeed, FeedConfig(..))-import Network.Gitit.Util (orIfNull, readFileUTF8)+import Network.Gitit.Util (orIfNull) import Network.Gitit.Cache (expireCachedFile, lookupCache, cacheContents) import Network.Gitit.ContentTransformer (showRawPage, showFileAsText, showPage,         exportPage, showHighlightedSource, preview, applyPreCommitPlugins)-import Network.Gitit.Page (extractCategories)+import Network.Gitit.Page (readCategories) import Control.Exception (throwIO, catch, try) import System.Time import System.FilePath@@ -325,8 +325,8 @@ showHistory :: String -> String -> Params -> Handler showHistory file page params =  do   fs <- getFileStore-  hist <- liftM (take (pLimit params)) $-            liftIO $ history fs [file] (TimeRange Nothing Nothing)+  hist <- liftIO $ history fs [file] (TimeRange Nothing Nothing)+            (Just $ pLimit params)   base' <- getWikiBase   let versionToHtml rev pos = li ! [theclass "difflink", intAttr "order" pos,                                     strAttr "revision" (revId rev),@@ -385,6 +385,7 @@   let forUser = pForUser params   fs <- getFileStore   hist <- liftIO $ history fs [] (TimeRange since Nothing)+                     (Just $ pLimit params)   let hist' = case forUser of                    Nothing -> hist                    Just u  -> filter (\r -> authorName (revAuthor r) == u) hist@@ -446,6 +447,7 @@               (Nothing, Just t)  -> do                 pageHist <- liftIO $ history fs [file]                                      (TimeRange Nothing Nothing)+                                     Nothing                 let (_, upto) = break (\r -> idsMatch fs (revId r) t)                                   pageHist                 return $ if length upto >= 2@@ -699,9 +701,9 @@   files <- liftIO $ index fs   let pages = filter (\f -> isPageFile f && not (isDiscussPageFile f)) files   matches <- liftM catMaybes $-             forM pages $ \f ->-               liftIO (readFileUTF8 $ repoPath </> f) >>= \s ->-               return $ if category `elem` (extractCategories s)+             forM pages $ \f -> do+               categories <- liftIO $ readCategories $ repoPath </> f+               return $ if category `elem` categories                            then Just $ dropExtension f                            else Nothing   base' <- getWikiBase@@ -723,10 +725,8 @@   fs <- getFileStore   files <- liftIO $ index fs   let pages = filter (\f -> isPageFile f && not (isDiscussPageFile f)) files-  categories <- liftIO $-                liftM (nub . sort . concat) $-                forM pages $ \f ->-                liftM extractCategories (readFileUTF8 (repoPath </> f))+  categories <- liftIO $ liftM (nub . sort . concat) $ forM pages $ \f ->+                  readCategories (repoPath </> f)   base' <- getWikiBase   let toCatLink ctg = li <<         [ anchor ! [href $ base' ++ "/_category" ++ urlForPage ctg] << ctg ]
Network/Gitit/Page.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {- Copyright (C) 2009 John MacFarlane <jgm@berkeley.edu> @@ -45,15 +46,25 @@  module Network.Gitit.Page ( stringToPage                           , pageToString-                          , extractCategories+                          , readCategories                           ) where import Network.Gitit.Types import Network.Gitit.Util (trim, splitCategories, parsePageType) import Text.ParserCombinators.Parsec import Data.Char (toLower)-import Data.List (isPrefixOf) import Data.Maybe (fromMaybe)+import Data.ByteString.UTF8 (toString)+import qualified Data.ByteString as B+import qualified Data.ByteString.Char8 as BC+import System.IO (withFile, Handle, IOMode(..))+import Prelude hiding (catch)+import Control.Exception (catch, throwIO)+import System.IO.Error (isEOFError)+#if MIN_VERSION_base(4,5,0)+#else+import Codec.Binary.UTF8.String (encodeString)+#endif  parseMetadata :: String -> ([(String, String)], String) parseMetadata raw =@@ -139,8 +150,41 @@                        else "")   in  metadata' ++ (if null metadata' then "" else "\n") ++ pageText page' -extractCategories :: String -> [String]-extractCategories s | "---" `isPrefixOf` s =-  let (md,_) = parseMetadata s-  in  splitCategories $ fromMaybe "" $ lookup "categories" md-extractCategories _ = []+-- | Read categories from metadata strictly.+readCategories :: FilePath -> IO [String]+readCategories f =+#if MIN_VERSION_base(4,5,0)+  withFile f ReadMode $ \h ->+#else+  withFile (encodeString f) ReadMode $ \h ->+#endif+    catch (do fl <- B.hGetLine h+              if dashline fl+                 then do -- get rest of metadata+                   rest <- hGetLinesTill h dotline+                   let (md,_) = parseMetadata $ unlines $ "---":rest+                   return $ splitCategories $ fromMaybe ""+                          $ lookup "categories" md+                 else return [])+       (\e -> if isEOFError e then return [] else throwIO e)++dashline :: B.ByteString -> Bool+dashline x =+  case BC.unpack x of+       ('-':'-':'-':xs) | all (==' ') xs -> True+       _ -> False++dotline :: B.ByteString -> Bool+dotline x =+  case BC.unpack x of+       ('.':'.':'.':xs) | all (==' ') xs -> True+       _ -> False++hGetLinesTill :: Handle -> (B.ByteString -> Bool) -> IO [String]+hGetLinesTill h end = do+  next <- B.hGetLine h+  if end next+     then return [toString next]+     else do+       rest <- hGetLinesTill h end+       return (toString next:rest)
Network/Gitit/Util.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {- Copyright (C) 2009 John MacFarlane <jgm@berkeley.edu> This program is free software; you can redistribute it and/or modify@@ -36,11 +37,18 @@ import qualified Data.ByteString.Lazy as B import Network.Gitit.Types import Control.Monad (liftM)+#if MIN_VERSION_base(4,5,0)+#else import Codec.Binary.UTF8.String (encodeString)+#endif  -- | Read file as UTF-8 string.  Encode filename as UTF-8. readFileUTF8 :: FilePath -> IO String+#if MIN_VERSION_base(4,5,0)+readFileUTF8 f = liftM toString $ B.readFile f+#else readFileUTF8 f = liftM toString $ B.readFile $ encodeString f+#endif  -- | Perform a function a directory and return to working directory. inDir :: FilePath -> IO a -> IO a
README.markdown view
@@ -292,7 +292,7 @@ to `static/css` and modify it.  The logo picture can be changed by copying a new PNG file to-`static/img/logo.png`.+`static/img/logo.png`. The default logo is 138x155 pixels.  To change the footer, modify `templates/footer.st`. @@ -331,6 +331,17 @@ 3.  `raw`: Math will be rendered as raw LaTeX codes.  [jsMath download page]: http://sourceforge.net/project/showfiles.php?group_id=172663++Restricting access+------------------++If you want to limit account creation on your wiki, the easiest way to do this+is to provide an `access-question` in your configuration file. (See the commented+default configuration file.)  Nobody will be able to create an account without+knowing the answer to the access question.++Another approach is to use HTTP authentication. (See the config file comments on+`authentication-method`.)  Plugins =======
gitit.cabal view
@@ -1,5 +1,5 @@ name:                gitit-version:             0.9.0.1+version:             0.10 Cabal-version:       >= 1.6 build-type:          Simple synopsis:            Wiki using happstack, git or darcs, and pandoc.@@ -154,7 +154,7 @@                      old-locale >= 1,                      time >= 1.1 && < 1.5,                      recaptcha >= 0.1,-                     filestore >= 0.4.0.2 && < 0.5,+                     filestore >= 0.5 && < 0.6,                      zlib >= 0.5 && < 0.6,                      url >= 2.1 && < 2.2,                      happstack-server >= 6.6 && < 7.1,@@ -165,7 +165,7 @@                      feed >= 0.3.6 && < 0.4,                      xss-sanitize >= 0.3 && < 0.4,                      tagsoup >= 0.12 && < 0.13,-                     blaze-html >= 0.4 && < 0.5,+                     blaze-html >= 0.4 && < 0.6,                      json >= 0.4 && < 0.6   if impl(ghc >= 6.10)     build-depends:   base >= 4, syb