gitit 0.2.2 → 0.2.2.1
raw patch · 3 files changed
+26/−19 lines, 3 files
Files
- Gitit.hs +23/−17
- gitit.cabal +1/−1
- stylesheets/gitit.css +2/−1
Gitit.hs view
@@ -45,7 +45,7 @@ import Text.Pandoc import Text.Pandoc.ODT (saveOpenDocumentAsODT) import Text.Pandoc.Definition (processPandoc)-import Text.Pandoc.Shared (HTMLMathMethod(..))+import Text.Pandoc.Shared (HTMLMathMethod(..), substitute) import Data.ByteString.Internal (c2w) import Data.Char (isAlphaNum, isAlpha) import Codec.Binary.UTF8.String (decodeString)@@ -57,7 +57,7 @@ import Text.Highlighting.Kate gititVersion :: String-gititVersion = "0.2.2"+gititVersion = "0.2.2.1" main :: IO () main = do@@ -333,15 +333,20 @@ Just u -> responder page (params { pUser = u }) handle :: (String -> Bool) -> Method -> (String -> Params -> Web Response) -> Handler-handle uritest meth responder =- uriRest $ \uri -> let uriPath = drop 1 $ takeWhile (/='?') uri- in if uritest uriPath+handle pathtest meth responder =+ uriRest $ \uri -> let path' = uriPath uri+ in if pathtest path' then withData $ \params -> [ withRequest $ \req -> if rqMethod req == meth- then responder uriPath params+ then responder path' params else noHandle ] else anyRequest noHandle +-- | Returns path portion of URI, without initial /.+-- Consecutive spaces are collapsed. We don't want to distinguish 'Hi There' and 'Hi There'.+uriPath :: String -> String+uriPath = unwords . words . drop 1 . takeWhile (/='?')+ handlePage :: Method -> (String -> Params -> Web Response) -> Handler handlePage = handle isPage @@ -365,12 +370,12 @@ handleAny :: Handler handleAny = - uriRest $ \uri -> let uriPath = drop 1 $ takeWhile (/='?') uri+ uriRest $ \uri -> let path' = uriPath uri in do cfg <- query GetConfig- let file = repositoryPath cfg </> uriPath+ let file = repositoryPath cfg </> path' exists <- liftIO $ doesFileExist file if exists- then fileServe [uriPath] (repositoryPath cfg)+ then fileServe [path'] (repositoryPath cfg) else anyRequest noHandle orIfNull :: String -> String -> String@@ -384,7 +389,8 @@ isSourceCode = not . null . languagesByExtension . takeExtension urlForPage :: String -> String-urlForPage page = "/" ++ urlEncode page+urlForPage page = "/" ++ (substitute "%2f" "/" $ urlEncode page)+-- this is needed so that browsers recognize relative URLs correctly pathForPage :: String -> FilePath pathForPage page = page <.> "page"@@ -408,7 +414,7 @@ setFilename fname res = let respHeaders = rsHeaders res newContentType = HeaderPair { hName = fromString "Content-Disposition",- hValue = [ fromString $ "attachment; " ++ urlEncodeVars [("filename", fname)] ] }+ hValue = [ fromString $ "attachment; filename=\"" ++ fname ++ "\"" ] } in res { rsHeaders = M.insert (fromString "content-disposition") newContentType respHeaders } showRawPage :: String -> Params -> Web Response@@ -439,7 +445,7 @@ else "&" ++ urlEncodeVars [("logMsg", "Revert to " ++ revision)]) ++ "';")] << cont formattedPage [] ["jsMath/easy/load.js"] page params cont' _ -> if revision == "HEAD"- then editPage page params+ then (unlessNoEdit $ ifLoggedIn "" $ editPage) page params else error $ "Invalid revision: " ++ revision validate :: [(Bool, String)] -- ^ list of conditions and error messages@@ -809,7 +815,7 @@ anchor ! [href ("/_register?" ++ urlEncodeVars [("destination", page)]), theclass "nav_link"] << "register" let sitenavVis = if HideNavbar `elem` opts then "hidden" else "visible"- let sidebarVis = if HidePageControls `elem` opts then "hidden" else "visible"+ let pageinfoVis = if HidePageControls `elem` opts then "none" else "show" let messages = pMessages params let htmlMessages = if null messages then noHtml@@ -821,8 +827,8 @@ '_':_ -> noHtml _ -> thediv ! [identifier "pageTitle"] << [ anchor ! [href $ urlForPage page] << (h1 << page) ] , thediv ! [identifier "content"] << [htmlMessages, htmlContents]- , thediv ! [identifier "pageinfo"] << [ thediv ! [theclass "pageControls",- thestyle $ "visibility: " ++ sidebarVis] <<+ , thediv ! [identifier "pageinfo", thestyle $ "display: " ++ pageinfoVis] <<+ [ thediv ! [theclass "pageControls"] << ((thespan ! [theclass "details"] << revision) : buttons) , if isPage page then exportBox page params else noHtml] , thediv ! [identifier "footer"] << primHtml (wikiFooter cfg)@@ -856,7 +862,7 @@ then do key <- update $ NewSession (SessionData uname) addCookie (3600) (mkCookie "sid" (show key))- seeOther ("/" ++ intercalate "%20" (words destination)) $ toResponse $ p << ("Welcome, " ++ uname)+ seeOther ("/" ++ substitute " " "%20" destination) $ toResponse $ p << ("Welcome, " ++ uname) else loginUserForm "_login" (params { pMessages = "Authentication failed." : pMessages params }) @@ -867,7 +873,7 @@ case key of Just k -> update $ DelSession k Nothing -> return ()- seeOther ("/" ++ intercalate "%20" (words destination)) $ toResponse $ p << "You have been logged out."+ seeOther ("/" ++ substitute " " "%20" destination) $ toResponse $ p << "You have been logged out." registerForm :: Web Html registerForm = do
gitit.cabal view
@@ -1,5 +1,5 @@ name: gitit-version: 0.2.2+version: 0.2.2.1 Cabal-version: >= 1.2 build-type: Simple synopsis: Wiki using HAppS, git, and pandoc.
stylesheets/gitit.css view
@@ -102,11 +102,12 @@ #pageinfo { padding: 4px; border-top: 1px solid #ccc;- border-bottom: 1px solid #ccc; } #footer { clear: both;+ border-top: 1px solid #ccc;+ margin-top: 2px; text-align: center; font-size: 80%; padding: 4px;