gitit 0.7.3.5 → 0.7.3.6
raw patch · 4 files changed
+55/−13 lines, 4 filesdep ~datetimedep ~happstack-serverdep ~happstack-utilPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: datetime, happstack-server, happstack-util, pandoc, parsec
API changes (from Hackage documentation)
Files
- CHANGES +15/−0
- Network/Gitit/ContentTransformer.hs +3/−1
- Network/Gitit/Export.hs +31/−6
- gitit.cabal +6/−6
CHANGES view
@@ -1,3 +1,18 @@+Version 0.7.3.6 released 05 May 2010++* Fixed ODT/PDF export for files in subdirectories. Resolves Issue #81.++* Fix image URLs before calling the ODT or PDF processors++* Added plain text export format.++* Raised upper bound for datetime, parsec, and happstack dependencies.++* Fix wikilinks to they don't get a leading slash.+ This reverts a bug introduced by 2128afb070b7, which added leading+ slashes to wikilinks, breaking them for people using gitit as a+ library on a path other than /.+ Version 0.7.3.5 released 21 Mar 2010 * Returned to using pandoc's MathML writer option.
Network/Gitit/ContentTransformer.hs view
@@ -90,6 +90,8 @@ import Control.Exception (throwIO, catch) import qualified Data.ByteString as S (concat) import qualified Data.ByteString.Lazy as L (toChunks, fromChunks)+import Network.URL (encString)+import Network.URI (isUnescapedInURI) -- -- ContentTransformer runners@@ -505,7 +507,7 @@ -- | Derives a URL from a list of Pandoc Inline elements. inlinesToURL :: [Inline] -> String-inlinesToURL = urlForPage . inlinesToString+inlinesToURL = encString False isUnescapedInURI . inlinesToString -- | Convert a list of inlines into a string. inlinesToString :: [Inline] -> String
Network/Gitit/Export.hs view
@@ -88,6 +88,10 @@ respondMarkdown = respondX "markdown" "text/plain; charset=utf-8" "" writeMarkdown defaultRespOptions{writerReferenceLinks = True} +respondPlain :: String -> Pandoc -> Handler+respondPlain = respondX "plain" "text/plain; charset=utf-8" ""+ writePlain defaultRespOptions+ respondMan :: String -> Pandoc -> Handler respondMan = respondX "man" "text/plain; charset=utf-8" "" writeMan defaultRespOptions@@ -114,7 +118,7 @@ writeMediaWiki defaultRespOptions respondODT :: Config -> String -> Pandoc -> Handler-respondODT cfg page doc = do+respondODT cfg page old_doc = fixURLs old_doc >>= \doc -> do template' <- liftIO $ getDefaultTemplate (pandocUserData cfg) "odt" template <- case template' of Right t -> return t@@ -124,7 +128,7 @@ doc conf <- getConfig contents <- liftIO $ withTempDir "gitit-temp-odt" $ \tempdir -> do- let tempfile = tempdir </> page <.> "odt"+ let tempfile = tempdir </> "export" <.> "odt" saveOpenDocumentAsODT (pandocUserData cfg) tempfile (repositoryPath conf) Nothing openDoc L.readFile tempfile@@ -147,7 +151,7 @@ return status respondPDF :: String -> Pandoc -> Handler-respondPDF page pndc = do+respondPDF page old_pndc = fixURLs old_pndc >>= \pndc -> do cfg <- getConfig unless (pdfExport cfg) $ error "PDF export disabled" let cacheName = pathForPage page ++ ".export.pdf"@@ -162,7 +166,7 @@ let toc = tableOfContents cfg let latex = writeLaTeX defaultRespOptions{writerTemplate = template ,writerTableOfContents = toc} pndc- let tempfile = page <.> "tex"+ let tempfile = "export" <.> "tex" curdir <- getCurrentDirectory setCurrentDirectory tempdir writeFile tempfile latex@@ -177,9 +181,9 @@ canary <- runShellCommand tempdir env cmd opts setCurrentDirectory curdir -- restore original location case canary of- ExitSuccess -> do pdfBS <- L.readFile (tempdir </> page <.> "pdf")+ ExitSuccess -> do pdfBS <- L.readFile (tempdir </> "export" <.> "pdf") return $ Right (useCache cfg, pdfBS)- ExitFailure n -> do l <- readFileUTF8 (tempdir </> page <.> "log")+ ExitFailure n -> do l <- readFileUTF8 (tempdir </> "export" <.> "log") return $ Left (n, l) case pdf' of Left (n,logOutput) -> simpleErrorHandler ("PDF creation failed with code: " ++@@ -190,6 +194,26 @@ ok $ setContentType "application/pdf" $ setFilename (page ++ ".pdf") $ (toResponse noHtml) {rsBody = pdfBS} +-- | When we create a PDF or ODT from a Gitit page, we need to fix the URLs of any+-- images on the page. Those URLs will often be relative to the staticDir, but the+-- PDF or ODT processor only understands paths relative to the working directory.+--+-- Because the working directory will not in general be the root of the gitit instance+-- at the time the Pandoc is fed to e.g. pdflatex, this function replaces the URLs of+-- images in the staticDir with their correct absolute file path.+fixURLs :: Pandoc -> GititServerPart Pandoc+fixURLs pndc = do+ curdir <- liftIO getCurrentDirectory+ cfg <- getConfig+ + let go (Image ils (url, title)) = Image ils (fixURL url, title)+ go x = x+ + fixURL ('/':url) = curdir </> staticDir cfg </> url+ fixURL url = url+ + return $ processWith go pndc+ exportFormats :: Config -> [(String, String -> Pandoc -> Handler)] exportFormats cfg = if pdfExport cfg then ("PDF", respondPDF) : rest@@ -199,6 +223,7 @@ , ("Texinfo", respondTexinfo) , ("reST", respondRST) , ("markdown", respondMarkdown)+ , ("plain text",respondPlain) , ("MediaWiki", respondMediaWiki) , ("man", respondMan) , ("DocBook", respondDocbook)
gitit.cabal view
@@ -1,5 +1,5 @@ name: gitit-version: 0.7.3.5+version: 0.7.3.6 Cabal-version: >= 1.2 build-type: Simple synopsis: Wiki using happstack, git or darcs, and pandoc.@@ -111,18 +111,18 @@ Executable gitit hs-source-dirs: . main-is: gitit.hs- build-depends: base >=3 && < 5, parsec < 3, pretty, xhtml, containers,- pandoc >= 1.5, process, filepath, directory, mtl, cgi,+ build-depends: base >=3 && < 5, parsec, pretty, xhtml, containers,+ pandoc >= 1.5.1, process, filepath, directory, mtl, cgi, network, old-time, highlighting-kate >= 0.2.6, bytestring, utf8-string >= 0.3 && < 0.4, SHA > 1 && < 1.5, HTTP >= 4000.0 && < 4000.1, HStringTemplate >= 0.6 && < 0.7, random, network >= 2.1.0.0 && < 2.3, recaptcha >= 0.1, filestore >= 0.3.4,- datetime >= 0.1 && < 0.2, zlib >= 0.5 && < 0.6,+ datetime >= 0.1 && < 0.3, zlib >= 0.5 && < 0.6, url >= 2.1 && < 2.2,- happstack-server >= 0.3.3 && < 0.5,- happstack-util >= 0.3.2 && < 0.5, xml >= 1.3.5,+ happstack-server >= 0.3.3 && < 0.6,+ happstack-util >= 0.3.2 && < 0.6, xml >= 1.3.5, hslogger >= 1 && < 1.1, ConfigFile >= 1 && < 1.1, feed >= 0.3.6 && < 0.4, cautious-file >= 0.1.5 && < 0.2