Permalink
Browse files

Modifications to get gitit to compile w latest pandoc, happstack.

  • Loading branch information...
1 parent eb11307 commit a3b36ce3865aa48d6b71e2a513a4cf6007d033d0 @jgm committed Feb 8, 2012
Showing with 26 additions and 28 deletions.
  1. +8 −8 Network/Gitit.hs
  2. +10 −10 Network/Gitit/Authentication.hs
  3. +5 −8 Network/Gitit/ContentTransformer.hs
  4. +1 −0 gitit.cabal
  5. +2 −2 gitit.hs
View
@@ -173,9 +173,9 @@ wikiHandlers =
, dir "_go" goToPage
, dir "_search" searchResults
, dir "_upload" $ do guard =<< return . uploadsAllowed =<< getConfig
- msum [ methodOnly GET >> authenticate ForModify uploadForm
- , methodOnly POST >> authenticate ForModify uploadFile ]
- , dir "_random" $ methodOnly GET >> randomPage
+ msum [ method GET >> authenticate ForModify uploadForm
+ , method POST >> authenticate ForModify uploadFile ]
+ , dir "_random" $ method GET >> randomPage
, dir "_index" indexPage
, dir "_feed" feedHandler
, dir "_category" categoryPage
@@ -193,18 +193,18 @@ wikiHandlers =
, guardPath isSourceCode >> showFileDiff ]
, dir "_discuss" discussPage
, dir "_delete" $ msum
- [ methodOnly GET >>
+ [ method GET >>
authenticate ForModify (unlessNoDelete confirmDelete showPage)
- , methodOnly POST >>
+ , method POST >>
authenticate ForModify (unlessNoDelete deletePage showPage) ]
, dir "_preview" preview
, guardIndex >> indexPage
, guardCommand "export" >> exportPage
- , methodOnly POST >> guardCommand "cancel" >> showPage
- , methodOnly POST >> guardCommand "update" >>
+ , method POST >> guardCommand "cancel" >> showPage
+ , method POST >> guardCommand "update" >>
authenticate ForModify (unlessNoEdit updatePage showPage)
, showPage
- , guardPath isSourceCode >> methodOnly GET >> showHighlightedSource
+ , guardPath isSourceCode >> method GET >> showHighlightedSource
, handleAny
, notFound =<< (guardPath isPage >> createPage)
]
@@ -405,15 +405,15 @@ registerUserForm = registerForm >>=
formAuthHandlers :: [Handler]
formAuthHandlers =
- [ dir "_register" $ methodSP GET registerUserForm
- , dir "_register" $ methodSP POST $ withData registerUser
- , dir "_login" $ methodSP GET loginUserForm
- , dir "_login" $ methodSP POST $ withData loginUser
- , dir "_logout" $ methodSP GET $ withData logoutUser
- , dir "_resetPassword" $ methodSP GET $ withData resetPasswordRequestForm
- , dir "_resetPassword" $ methodSP POST $ withData resetPasswordRequest
- , dir "_doResetPassword" $ methodSP GET $ withData resetPassword
- , dir "_doResetPassword" $ methodSP POST $ withData doResetPassword
+ [ dir "_register" $ method GET >> registerUserForm
+ , dir "_register" $ method POST >> withData registerUser
+ , dir "_login" $ method GET >> loginUserForm
+ , dir "_login" $ method POST >> withData loginUser
+ , dir "_logout" $ method GET >> withData logoutUser
+ , dir "_resetPassword" $ method GET >> withData resetPasswordRequestForm
+ , dir "_resetPassword" $ method POST >> withData resetPasswordRequest
+ , dir "_doResetPassword" $ method GET >> withData resetPassword
+ , dir "_doResetPassword" $ method POST >> withData doResetPassword
, dir "_user" currentUser
]
@@ -487,7 +487,7 @@ instance FromData RPars where
rpxAuthHandlers :: [Handler]
rpxAuthHandlers =
- [ dir "_logout" $ methodSP GET $ withData logoutUser
+ [ dir "_logout" $ method GET >> withData logoutUser
, dir "_login" $ withData loginRPXUser
, dir "_user" currentUser ]
@@ -89,6 +89,7 @@ import Text.Highlighting.Kate
import Text.Pandoc hiding (MathML, WebTeX, MathJax)
import Text.Pandoc.Shared (ObfuscationMethod(..))
import Text.XHtml hiding ( (</>), dir, method, password, rev )
+import Text.Blaze.Renderer.String as Blaze ( renderHtml )
import qualified Data.Text as T
import qualified Data.ByteString as S (concat)
import qualified Data.ByteString.Lazy as L (toChunks, fromChunks)
@@ -361,12 +362,12 @@ highlightSource :: Maybe String -> ContentTransformer Html
highlightSource Nothing = mzero
highlightSource (Just source) = do
file <- getFileName
- let formatOpts = [OptNumberLines, OptLineAnchors]
+ let formatOpts = defaultFormatOpts { numberLines = True, lineAnchors = True }
case languagesByExtension $ takeExtension file of
[] -> mzero
- (l:_) -> case highlightAs l (filter (/='\r') source) of
- Left _ -> mzero
- Right res -> return $ formatAsXHtml formatOpts l $! res
+ (l:_) -> return $ primHtml $ Blaze.renderHtml
+ $ formatHtmlBlock formatOpts
+ $! highlightAs l $ filter (/='\r') source
--
-- Plugin combinators
@@ -536,10 +537,6 @@ inlinesToString = concatMap go
Cite _ xs -> concatMap go xs
Code _ s -> s
Space -> " "
- EmDash -> "---"
- EnDash -> "--"
- Apostrophe -> "'"
- Ellipses -> "..."
LineBreak -> " "
Math DisplayMath s -> "$$" ++ s ++ "$$"
Math InlineMath s -> "$" ++ s ++ "$"
View
@@ -165,6 +165,7 @@ Executable gitit
feed >= 0.3.6 && < 0.4,
xss-sanitize >= 0.3 && < 0.4,
tagsoup >= 0.12 && < 0.13,
+ blaze-html >= 0.4 && < 0.5,
json >= 0.4 && < 0.6
if impl(ghc >= 6.10)
build-depends: base >= 4, syb
View
@@ -77,7 +77,7 @@ main = do
initializeGititState conf'
let serverConf = Conf { validator = Nothing, port = portNumber conf',
- timeout = 20, logAccess = Nothing }
+ timeout = 20, logAccess = Nothing, tls = Nothing }
-- open the requested interface
sock <- socket AF_INET Stream defaultProtocol
@@ -87,7 +87,7 @@ main = do
listen sock 10
-- start the server
- simpleHTTPWithSocket sock serverConf $ msum [ wiki conf'
+ simpleHTTPWithSocket sock Nothing serverConf $ msum [ wiki conf'
, dir "_reloadTemplates" reloadTemplates
]

0 comments on commit a3b36ce

Please sign in to comment.