gitit 0.8.0.1 → 0.8.1
raw patch · 10 files changed
+128/−56 lines, 10 filesdep +textdep ~happstack-serverdep ~pandocdep ~pandoc-types
Dependencies added: text
Dependency ranges changed: happstack-server, pandoc, pandoc-types, xss-sanitize
Files
- CHANGES +37/−0
- Network/Gitit/Config.hs +8/−2
- Network/Gitit/ContentTransformer.hs +15/−6
- Network/Gitit/Framework.hs +2/−1
- Network/Gitit/Handlers.hs +23/−23
- Network/Gitit/Layout.hs +5/−1
- Network/Gitit/Types.hs +6/−2
- data/default.conf +20/−10
- gitit.cabal +9/−8
- gitit.hs +3/−3
CHANGES view
@@ -1,3 +1,40 @@+Version 0.8.1 released 02 Sep 2011++* Support mathjax as a math option.+ Added MathJax as MathMethod, and mathjax as an option in+ the 'math' config field. Resolves GoogleCode 122.++* Added xss-sanitize configuaration option.+ Setting it to 'no' turns off sanitization, enabling+ file:// URLs and other things that get filtered out+ by xss-sanitize.++* Listen interface explanation on help file could be more clear (#266)+ (andyring)++* Add the new configuration option 'absolute-urls'.+ When turned on, this makes wikilinks absolute w.r.t. the base-url.+ By default, they are relative. So, for example, in a wiki served+ at the path 'wiki', on a page Sub/Page, the wikilink '[Cactus]()'+ will produce a link to '/wiki/Cactus' if absolute-urls is on,+ and otherwise the relative link 'Cactus'. Patch due to lemmih.++* Change default listen address to 0.0.0.0.++* Serve svg file as image, not source code!++* Page history: use 'limit' instead of restricting to past year.+ limit defaults to 100. If 100 are displayed, you'll get a+ "Show more..." link that will increase the limit.+ Also fixed bug that caused a 404 when no history was returned.++* Require pandoc >= 1.8.2.++* Allow build with happstack-server 6.2.++* Updated for use with xss-sanitize 0.3, which uses Text.+ New dependency on text.+ Version 0.8.0.1 released 07 Jun 2011 * Fixed file upload problem with recent versions of directory
Network/Gitit/Config.hs view
@@ -38,7 +38,7 @@ import Data.Char (toLower, toUpper, isDigit) import Paths_gitit (getDataFileName) import System.FilePath ((</>))-import Text.Pandoc hiding (MathML, WebTeX)+import Text.Pandoc hiding (MathML, WebTeX, MathJax) forceEither :: Show e => Either e a -> a forceEither = either (error . show) id@@ -99,11 +99,13 @@ cfResetPasswordMessage <- get cp "DEFAULT" "reset-password-message" cfUseFeed <- get cp "DEFAULT" "use-feed" cfBaseUrl <- get cp "DEFAULT" "base-url"+ cfAbsoluteUrls <- get cp "DEFAULT" "absolute-urls" cfWikiTitle <- get cp "DEFAULT" "wiki-title" cfFeedDays <- get cp "DEFAULT" "feed-days" cfFeedRefreshTime <- get cp "DEFAULT" "feed-refresh-time" cfPDFExport <- get cp "DEFAULT" "pdf-export" cfPandocUserData <- get cp "DEFAULT" "pandoc-user-data"+ cfXssSanitize <- get cp "DEFAULT" "xss-sanitize" let (pt, lhs) = parsePageType cfDefaultPageType let markupHelpFile = show pt ++ if lhs then "+LHS" else "" markupHelpPath <- liftIO $ getDataFileName $ "data" </> "markupHelp" </> markupHelpFile@@ -128,6 +130,7 @@ , mathMethod = case map toLower cfMathMethod of "jsmath" -> JsMathScript "mathml" -> MathML+ "mathjax" -> MathJax "https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" "google" -> WebTeX "http://chart.apis.google.com/chart?cht=tx&chl=" _ -> RawTeX , defaultLHS = lhs@@ -186,13 +189,16 @@ , markupHelp = markupHelpText , useFeed = cfUseFeed , baseUrl = stripTrailingSlash cfBaseUrl+ , useAbsoluteUrls = cfAbsoluteUrls , wikiTitle = cfWikiTitle , feedDays = readNumber "feed-days" cfFeedDays , feedRefreshTime = readNumber "feed-refresh-time" cfFeedRefreshTime , pdfExport = cfPDFExport , pandocUserData = if null cfPandocUserData then Nothing- else Just cfPandocUserData }+ else Just cfPandocUserData+ , xssSanitize = cfXssSanitize+ } case config' of Left (ParseError e, e') -> error $ "Parse error: " ++ e ++ "\n" ++ e' Left e -> error (show e)
Network/Gitit/ContentTransformer.hs view
@@ -70,6 +70,7 @@ import Control.Exception (throwIO, catch) import Control.Monad.State+import Control.Monad.Reader (ask) import Data.Maybe (isNothing, mapMaybe) import Network.Gitit.Cache (lookupCache, cacheContents) import Network.Gitit.Export (exportFormats)@@ -85,9 +86,10 @@ import System.FilePath import Text.HTML.SanitizeXSS (sanitizeBalance) import Text.Highlighting.Kate-import Text.Pandoc hiding (MathML, WebTeX)+import Text.Pandoc hiding (MathML, WebTeX, MathJax) import Text.Pandoc.Shared (ObfuscationMethod(..)) import Text.XHtml hiding ( (</>), dir, method, password, rev )+import qualified Data.Text as T import qualified Data.ByteString as S (concat) import qualified Data.ByteString.Lazy as L (toChunks, fromChunks) import qualified Data.FileStore as FS@@ -336,7 +338,8 @@ toc <- liftM ctxTOC get bird <- liftM ctxBirdTracks get cfg <- lift getConfig- return $ primHtml $ sanitizeBalance $+ return $ primHtml $ T.unpack .+ (if xssSanitize cfg then sanitizeBalance else id) . T.pack $ writeHtmlString defaultWriterOptions{ writerStandalone = True , writerTemplate = "$if(toc)$\n$toc$\n$endif$\n$body$"@@ -344,6 +347,7 @@ case mathMethod cfg of MathML -> Pandoc.MathML Nothing WebTeX u -> Pandoc.WebTeX u+ MathJax u -> Pandoc.MathJax u _ -> JsMath (Just $ base' ++ "/js/jsMath/easy/load.js") , writerTableOfContents = toc@@ -449,6 +453,7 @@ JsMathScript -> addScripts l ["jsMath/easy/load.js"] MathML -> addScripts l ["MathMLinHTML.js"] WebTeX _ -> l+ MathJax u -> addScripts l [u] RawTeX -> l return c @@ -499,13 +504,17 @@ Textile -> readTextile defPS wikiLinksTransform :: Pandoc -> PluginM Pandoc-wikiLinksTransform = return . bottomUp convertWikiLinks+wikiLinksTransform pandoc+ = do cfg <- liftM pluginConfig ask -- Can't use askConfig from Interface due to circular dependencies.+ return (bottomUp (convertWikiLinks cfg) pandoc) -- | Convert links with no URL to wikilinks.-convertWikiLinks :: Inline -> Inline-convertWikiLinks (Link ref ("", "")) =+convertWikiLinks :: Config -> Inline -> Inline+convertWikiLinks cfg (Link ref ("", "")) | useAbsoluteUrls cfg =+ Link ref (baseUrl cfg </> inlinesToURL ref, "Go to wiki page")+convertWikiLinks _cfg (Link ref ("", "")) = Link ref (inlinesToURL ref, "Go to wiki page")-convertWikiLinks x = x+convertWikiLinks _cfg x = x -- | Derives a URL from a list of Pandoc Inline elements. inlinesToURL :: [Inline] -> String
Network/Gitit/Framework.hs view
@@ -268,7 +268,8 @@ isSourceCode :: String -> Bool isSourceCode path' = let langs = languagesByFilename $ takeFileName path'- in not . null $ langs+ in not (null langs || takeExtension path' == ".svg")+ -- allow svg to be served as image -- | Returns encoded URL path for the page with the given name, relative to -- the wiki base.
Network/Gitit/Handlers.hs view
@@ -324,13 +324,9 @@ showHistory :: String -> String -> Params -> Handler showHistory file page params = do- currTime <- liftIO getCurrentTime- let oneYearAgo = addUTCTime (-60 * 60 * 24 * 365) currTime- let since = case pSince params of- Nothing -> Just oneYearAgo- Just t -> Just t fs <- getFileStore- hist <- liftIO $ history fs [file] (TimeRange since Nothing)+ hist <- liftM (take (pLimit params)) $+ liftIO $ history fs [file] (TimeRange Nothing Nothing) base' <- getWikiBase let versionToHtml rev pos = li ! [theclass "difflink", intAttr "order" pos, strAttr "revision" (revId rev),@@ -357,23 +353,27 @@ else []) ++ [stringToHtml "]"]) ]- if null hist- then mzero- else do- let contents = ulist ! [theclass "history"] <<- zipWith versionToHtml hist- [(length hist), (length hist - 1)..1]- let tabs = if file == page -- source file, not wiki page- then [ViewTab,HistoryTab]- else pgTabs defaultPageLayout- formattedPage defaultPageLayout{- pgPageName = page,- pgMessages = pMessages params,- pgScripts = ["dragdiff.js"],- pgTabs = tabs,- pgSelectedTab = HistoryTab,- pgTitle = ("Changes to " ++ page)- } contents+ let contents = if null hist+ then noHtml+ else ulist ! [theclass "history"] <<+ zipWith versionToHtml hist+ [length hist, (length hist - 1)..1]+ let more = if length hist == pLimit params+ then anchor ! [href $ base' ++ "/_history" ++ urlForPage page+ ++ "?limit=" ++ show (pLimit params + 100)] <<+ "Show more..."+ else noHtml+ let tabs = if file == page -- source file, not wiki page+ then [ViewTab,HistoryTab]+ else pgTabs defaultPageLayout+ formattedPage defaultPageLayout{+ pgPageName = page,+ pgMessages = pMessages params,+ pgScripts = ["dragdiff.js"],+ pgTabs = tabs,+ pgSelectedTab = HistoryTab,+ pgTitle = ("Changes to " ++ page)+ } $ contents +++ more showActivity :: Handler showActivity = withData $ \(params :: Params) -> do
Network/Gitit/Layout.hs view
@@ -75,8 +75,12 @@ filledPageTemplate base' cfg layout htmlContents templ = let rev = pgRevision layout page = pgPageName layout+ prefixedScript x = case x of+ 'h':'t':'t':'p':_ -> x+ _ -> base' ++ "/js/" ++ x+ scripts = ["jquery.min.js", "jquery-ui.packed.js", "footnotes.js"] ++ pgScripts layout- scriptLink x = script ! [src (base' ++ "/js/" ++ x),+ scriptLink x = script ! [src (prefixedScript x), thetype "text/javascript"] << noHtml javascriptlinks = renderHtmlFragment $ concatHtml $ map scriptLink scripts tabli tab = if tab == pgSelectedTab layout
Network/Gitit/Types.hs view
@@ -42,7 +42,7 @@ data FileStoreType = Git | Darcs | Mercurial deriving Show -data MathMethod = MathML | JsMathScript | WebTeX String | RawTeX+data MathMethod = MathML | JsMathScript | WebTeX String | RawTeX | MathJax String deriving (Read, Show, Eq) data AuthenticationLevel = Never | ForModify | ForRead@@ -132,6 +132,8 @@ -- | Base URL of wiki, for use in feed baseUrl :: String, -- | Title of wiki, used in feed+ useAbsoluteUrls :: Bool,+ -- | Should WikiLinks be absolute w.r.t. the base URL? wikiTitle :: String, -- | Number of days history to be included in feed feedDays :: Integer,@@ -140,7 +142,9 @@ -- | Allow PDF export? pdfExport :: Bool, -- | Directory to search for pandoc customizations- pandocUserData :: Maybe FilePath+ pandocUserData :: Maybe FilePath,+ -- | Filter HTML through xss-sanitize+ xssSanitize :: Bool } -- | Data for rendering a wiki page.
data/default.conf view
@@ -61,16 +61,16 @@ math: MathML # specifies how LaTeX math is to be displayed. Possible values-# are MathML, raw, jsMath, and google. If mathml is selected, gitit will-# convert LaTeX math to MathML and link in a script, MathMLinHTML.js,-# that allows the MathML to be seen in Gecko browsers, IE +-# mathplayer, and Opera. In other browsers you may get a jumble-# of characters. If raw is selected, the LaTeX math will be displayed-# as raw LaTeX math. If jsMath is selected, gitit will link to-# the script /js/jsMath/easy/load.js, and will assume that jsMath-# has been installed into the js/jsMath directory. This is the most-# portable solution. If google is selected, the google chart API is-# called to render the formula as an image. This requires a connection+# are MathML, raw, mathjax, jsMath, and google. If mathml is selected,+# gitit will convert LaTeX math to MathML and link in a script,+# MathMLinHTML.js, that allows the MathML to be seen in Gecko browsers, IE ++# mathplayer, and Opera. In other browsers you may get a jumble of characters.+# If raw is selected, the LaTeX math will be displayed as raw LaTeX math.+# If mathjax is selected, gitit will link to the remote mathjax script.+# If jsMath is selected, gitit will link to the script /js/jsMath/easy/load.js,+# and will assume that jsMath has been installed into the js/jsMath directory.+# This is the most portable solution. If google is selected, the google chart+# API is called to render the formula as an image. This requires a connection # to google, and might raise a technical or a privacy problem. show-lhs-bird-tracks: no@@ -228,6 +228,13 @@ # and RPX token_urls. Set this if use-feed is 'yes' or # authentication-method is 'rpx'. +absolute-urls: no+# make wikilinks absolute with respect to the base-url.+# So, for example, in a wiki served at the base URL '/wiki', on a page+# Sub/Page, the wikilink '[Cactus]()' will produce a link to+# '/wiki/Cactus' if absolute-urls is 'yes', and a relative link to 'Cactus'+# (referring to '/wiki/Sub/Cactus') if absolute-urls is 'no'.+ feed-days: 14 # number of days to be included in feeds. @@ -247,3 +254,6 @@ # specified, $HOME/.pandoc will be searched. See pandoc's README for # more information. +xss-sanitize: yes+# if yes, all HTML (including that produced by pandoc) is filtered+# through xss-sanitize. Set to no only if you trust all of your users.
gitit.cabal view
@@ -1,5 +1,5 @@ name: gitit-version: 0.8.0.1+version: 0.8.1 Cabal-version: >= 1.6 build-type: Simple synopsis: Wiki using happstack, git or darcs, and pandoc.@@ -39,8 +39,8 @@ license-file: LICENSE author: John MacFarlane maintainer: jgm@berkeley.edu-bug-reports: http://code.google.com/p/gitit/issues/list-homepage: http://github.com/jgm/gitit/tree/master+bug-reports: http://github.com/jgm/gitit/issues+homepage: http://gitit.net 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,@@ -105,7 +105,7 @@ exposed-modules: Network.Gitit.Interface build-depends: ghc, ghc-paths cpp-options: -D_PLUGINS- build-depends: base >= 3, pandoc >= 1.8, pandoc-types >= 1.8, filepath, safe+ build-depends: base >= 3, pandoc >= 1.8.2, pandoc-types >= 1.8.2, filepath, safe extensions: CPP if impl(ghc >= 6.12) ghc-options: -Wall -fno-warn-unused-do-bind@@ -121,8 +121,8 @@ pretty, xhtml, containers,- pandoc >= 1.8,- pandoc-types >= 1.8,+ pandoc >= 1.8.2,+ pandoc-types >= 1.8.2, process, filepath, directory,@@ -131,6 +131,7 @@ old-time, highlighting-kate >= 0.2.7.1, bytestring,+ text, random, network >= 2.1.0.0 && < 2.4, utf8-string >= 0.3 && < 0.4,@@ -143,13 +144,13 @@ filestore >= 0.4.0.2 && < 0.5, zlib >= 0.5 && < 0.6, url >= 2.1 && < 2.2,- happstack-server >= 6.0 && < 6.2,+ happstack-server >= 6.0 && < 6.3, happstack-util >= 6.0 && < 6.2, xml >= 1.3.5, hslogger >= 1 && < 1.2, ConfigFile >= 1 && < 1.2, feed >= 0.3.6 && < 0.4,- xss-sanitize >= 0.2 && < 0.3,+ xss-sanitize >= 0.3 && < 0.4, json >= 0.4 && < 0.5 if impl(ghc >= 6.10) build-depends: base >= 4, syb
gitit.hs view
@@ -110,7 +110,7 @@ , Option ['p'] ["port"] (ReqArg (Port . read) "PORT") "Specify port" , Option ['l'] ["listen"] (ReqArg (Listen . checkListen) "INTERFACE")- "Specify interface to listen on"+ "Specify IP address to listen on" , Option [] ["print-default-config"] (NoArg PrintDefaultConfig) "Print default configuration" , Option [] ["debug"] (NoArg Debug)@@ -122,10 +122,10 @@ checkListen :: String -> String checkListen l | isIPv6address l = l | isIPv4address l = l- | otherwise = error "Gitit.checkListen: Not a valid interface name"+ | otherwise = error "Gitit.checkListen: Not a valid interface name" getListenOrDefault :: [Opt] -> String-getListenOrDefault [] = "127.0.0.1"+getListenOrDefault [] = "0.0.0.0" getListenOrDefault ((Listen l):_) = l getListenOrDefault (_:os) = getListenOrDefault os