gitit 0.7 → 0.7.1
raw patch · 7 files changed
+85/−30 lines, 7 filesdep ~pandoc
Dependency ranges changed: pandoc
Files
- CHANGES +7/−0
- Network/Gitit/Config.hs +5/−0
- Network/Gitit/Export.hs +40/−21
- Network/Gitit/Handlers.hs +8/−2
- Network/Gitit/Initialize.hs +5/−0
- gitit.cabal +15/−7
- gitit.hs +5/−0
CHANGES view
@@ -1,3 +1,10 @@+Version 0.7.1 released 02 Jan 2010++* Updated exports to work with pandoc 1.4.++* Began updating to work with GHC 6.12. (Still untested; there may+ be further issues involving filestore.)+ Version 0.7 released 20 Dec 2009 * Updated cabal file to allow happstack 0.4.
Network/Gitit/Config.hs view
@@ -38,8 +38,13 @@ import Data.List (intercalate) import Data.Char (toLower, toUpper, isDigit) import Paths_gitit (getDataFileName)+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv+-- So we use System.IO.UTF8 only if we have an earlier version+#if MIN_VERSION_base(4,2,0)+#else import Prelude hiding (readFile) import System.IO.UTF8+#endif import System.FilePath ((</>)) import Control.Monad (liftM) import Text.Pandoc
Network/Gitit/Export.hs view
@@ -22,6 +22,7 @@ module Network.Gitit.Export ( exportFormats ) where import Text.Pandoc+import Text.Pandoc.Writers.S5 (s5HeaderIncludes) import Text.Pandoc.ODT (saveOpenDocumentAsODT) import Network.Gitit.Server import Network.Gitit.Util (withTempDir)@@ -31,6 +32,7 @@ import Text.XHtml (noHtml) import qualified Data.ByteString.Lazy as B import System.FilePath ((<.>), (</>))+import Control.Exception (throwIO) defaultRespOptions :: WriterOptions defaultRespOptions = defaultWriterOptions { writerStandalone = True@@ -46,52 +48,69 @@ (if null ext then id else setFilename (page ++ "." ++ ext)) . toResponse . fn +respondX :: String -> String -> String -> (WriterOptions -> Pandoc -> String)+ -> WriterOptions -> String -> Pandoc -> Handler+respondX templ mimetype ext fn opts page doc = do+ template' <- liftIO $ getDefaultTemplate templ+ template <- case template' of+ Right t -> return t+ Left e -> liftIO $ throwIO e+ respond mimetype ext (fn opts{writerTemplate = template}) page doc + respondLaTeX :: String -> Pandoc -> Handler-respondLaTeX = respond "application/x-latex" "tex" $- writeLaTeX (defaultRespOptions {writerHeader = defaultLaTeXHeader})+respondLaTeX = respondX "latex" "application/x-latex" "tex"+ writeLaTeX defaultRespOptions respondConTeXt :: String -> Pandoc -> Handler-respondConTeXt = respond "application/x-context" "tex" $- writeConTeXt (defaultRespOptions {writerHeader = defaultConTeXtHeader})+respondConTeXt = respondX "context" "application/x-context" "tex"+ writeConTeXt defaultRespOptions respondRTF :: String -> Pandoc -> Handler-respondRTF = respond "application/rtf" "rtf" $- writeRTF (defaultRespOptions {writerHeader = defaultRTFHeader})+respondRTF = respondX "rtf" "application/rtf" "rtf"+ writeRTF defaultRespOptions respondRST :: String -> Pandoc -> Handler-respondRST = respond "text/plain; charset=utf-8" "" $- writeRST (defaultRespOptions {writerHeader = "", writerReferenceLinks = True})+respondRST = respondX "rst" "text/plain; charset=utf-8" ""+ writeRST defaultRespOptions{writerReferenceLinks = True} respondMan :: String -> Pandoc -> Handler-respondMan = respond "text/plain; charset=utf-8" "" $- writeMan (defaultRespOptions {writerHeader = ""})+respondMan = respondX "man" "text/plain; charset=utf-8" ""+ writeMan defaultRespOptions respondS5 :: String -> Pandoc -> Handler-respondS5 _ = ok . toResponse .- writeS5 (defaultRespOptions {writerHeader = defaultS5Header,- writerS5 = True, writerIncremental = True})+respondS5 pg doc = do+ inc <- liftIO $ s5HeaderIncludes+ respondX "s5" "text/html; charset=utf-8" ""+ writeS5String+ defaultRespOptions{writerS5 = True, writerIncremental = True,+ writerVariables = [("header-includes",inc)]}+ pg doc respondTexinfo :: String -> Pandoc -> Handler-respondTexinfo = respond "application/x-texinfo" "texi" $- writeTexinfo (defaultRespOptions {writerHeader = ""})+respondTexinfo = respondX "texinfo" "application/x-texinfo" "texi"+ writeTexinfo defaultRespOptions respondDocbook :: String -> Pandoc -> Handler-respondDocbook = respond "application/docbook+xml" "xml" $- writeDocbook (defaultRespOptions {writerHeader = defaultDocbookHeader})+respondDocbook = respondX "docbook" "application/docbook+xml" "xml"+ writeDocbook defaultRespOptions respondMediaWiki :: String -> Pandoc -> Handler-respondMediaWiki = respond "text/plain; charset=utf-8" "" $- writeMediaWiki (defaultRespOptions {writerHeader = ""})+respondMediaWiki = respondX "mediawiki" "text/plain; charset=utf-8" ""+ writeMediaWiki defaultRespOptions respondODT :: String -> Pandoc -> Handler respondODT page doc = do+ template' <- liftIO $ getDefaultTemplate "odt"+ template <- case template' of+ Right t -> return t+ Left e -> liftIO $ throwIO e let openDoc = writeOpenDocument- (defaultRespOptions {writerHeader = defaultOpenDocumentHeader})+ defaultRespOptions{writerTemplate = template} doc conf <- getConfig contents <- liftIO $ withTempDir "gitit-temp-odt" $ \tempdir -> do let tempfile = tempdir </> page <.> "odt"- saveOpenDocumentAsODT tempfile (repositoryPath conf) openDoc+ saveOpenDocumentAsODT tempfile (repositoryPath conf) Nothing openDoc B.readFile tempfile ok $ setContentType "application/vnd.oasis.opendocument.text" $ setFilename (page ++ ".odt") $ (toResponse noHtml) {rsBody = contents}
Network/Gitit/Handlers.hs view
@@ -68,11 +68,17 @@ exportPage, showHighlightedSource, preview, applyPreCommitPlugins) import Network.Gitit.Page (extractCategories) import Control.Exception (throwIO, catch, try)-import Prelude hiding (writeFile, readFile, catch) import Data.ByteString.UTF8 (toString) import System.Time import System.FilePath-import System.IO.UTF8 (readFile)+import Prelude hiding (readFile, writeFile, catch)+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv+-- So we use System.IO.UTF8 only if we have an earlier version+#if MIN_VERSION_base(4,2,0)+import Prelude (readFile, writeFile)+#else+import System.IO.UTF8+#endif import Network.Gitit.State import Text.XHtml hiding ( (</>), dir, method, password, rev ) import qualified Text.XHtml as X ( method )
Network/Gitit/Initialize.hs view
@@ -34,8 +34,13 @@ import Control.Exception (throwIO, try) import System.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExist, doesFileExist) import Control.Monad (unless, forM_, liftM)+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv+-- So we use System.IO.UTF8 only if we have an earlier version+#if MIN_VERSION_base(4,2,0)+#else import Prelude hiding (readFile) import System.IO.UTF8+#endif import Text.Pandoc import Text.Pandoc.Shared (HTMLMathMethod(..)) import System.Log.Logger (logM, Priority(..))
gitit.cabal view
@@ -1,10 +1,10 @@ name: gitit-version: 0.7+version: 0.7.1 Cabal-version: >= 1.2 build-type: Simple synopsis: Wiki using happstack, git or darcs, and pandoc.-description: Gitit is a wiki backed by a git, darcs, or mercurial- filestore. Pages and uploaded files can be modified either+description: Gitit is a wiki backed by a git or darcs filestore.+ Pages and uploaded files can be modified either directly via the VCS's command-line tools or through the wiki's web interface. Pandoc is used for markup processing, so pages may be written in@@ -41,7 +41,7 @@ maintainer: jgm@berkeley.edu bug-reports: http://code.google.com/p/gitit/issues/list homepage: http://github.com/jgm/gitit/tree/master-stability: experimental+stability: experimental data-files: data/static/css/screen.css, data/static/css/print.css, data/static/css/ie.css, data/static/css/hk-pyg.css, data/static/css/reset-fonts-grids.css,@@ -98,8 +98,12 @@ exposed-modules: Network.Gitit.Interface build-depends: ghc, ghc-paths cpp-options: -D_PLUGINS- build-depends: base >= 3, pandoc >= 1.3, filepath, safe- ghc-options: -Wall+ build-depends: base >= 3, pandoc >= 1.4, filepath, safe+ extensions: CPP+ if impl(ghc >= 6.12)+ ghc-options: -Wall -fno-warn-unused-do-bind+ else+ ghc-options: -Wall ghc-prof-options: -auto-all -caf-all Executable gitit@@ -119,7 +123,11 @@ if flag(plugins) build-depends: ghc, ghc-paths cpp-options: -D_PLUGINS- ghc-options: -Wall -threaded+ extensions: CPP+ if impl(ghc >= 6.12)+ ghc-options: -Wall -threaded -fno-warn-unused-do-bind+ else+ ghc-options: -Wall -threaded ghc-prof-options: -auto-all -caf-all Executable expireGititCache
gitit.hs view
@@ -35,8 +35,13 @@ import System.IO (stdout, stderr) import System.Console.GetOpt import Data.Version (showVersion)+-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv+-- So we use System.IO.UTF8 only if we have an earlier version+#if MIN_VERSION_base(4,2,0)+#else import Prelude hiding (readFile) import System.IO.UTF8+#endif import Paths_gitit (version, getDataFileName) main :: IO ()