[switch to use HAppS.Helpers.DirBrowse, which should go up to haddock, and make ghc 6.10 work thomashartman1@gmail.com**20081119161136] hunk ./src/AppStateSetBased.hs 3 - TypeSynonymInstances, PatternSignatures #-} + TypeSynonymInstances, ScopedTypeVariables #-} hunk ./src/Controller.hs 1 -{-# options_ghc -XPatternSignatures -fno-monomorphism-restriction #-} +{-# LANGUAGE NoMonomorphismRestriction, ScopedTypeVariables #-} + hunk ./src/Controller.hs 28 -import HAppSBrowse +import HAppS.Helpers.DirBrowse hunk ./src/ControllerBasic.hs 1 -{-# OPTIONS -XPatternSignatures #-} hunk ./src/ControllerGetActions.hs 1 -{-# LANGUAGE PatternSignatures, NoMonomorphismRestriction #-} hunk ./src/ControllerPostActions.hs 1 -{-# LANGUAGE PatternSignatures #-} hunk ./src/ControllerPostActions.hs 195 - - --- newUserPage :: RenderGlobals -> ServerPartT IO Response +newUserPage :: RenderGlobals -> ServerPartT IO Response hunk ./src/ControllerPostActions.hs 197 - withData $ \(NewUserInfo user (pass1 :: B.ByteString) pass2) -> + withData $ \(NewUserInfo user pass1 pass2) -> hunk ./src/HAppSBrowse.hs 1 -{-# LANGUAGE NoMonomorphismRestriction #-} -module HAppSBrowse where - -import HAppS.Server -import Control.Monad.Trans -import System.Directory -import System.FilePath -import Data.List -import qualified Data.ByteString.Char8 as B -import qualified Data.ByteString.Lazy.Char8 as L -import Data.Char (toLower) -import Language.Haskell.HsColour.HTML -import Language.Haskell.HsColour.Colourise - - -defaultColourPrefs = ColourPrefs - { keyword = [Foreground Green,Underscore] - , keyglyph = [Foreground Red] - , layout = [Foreground Cyan] - , comment = [Foreground Blue] - , conid = [Normal] - , varid = [Normal] - , conop = [Foreground Red,Bold] - , varop = [Foreground Cyan] - , string = [Foreground Magenta] - , char = [Foreground Magenta] - , number = [Foreground Magenta] - , cpp = [Foreground Magenta,Dim] - , selection = [Bold, Foreground Magenta] - , variantselection = [Dim, Foreground Red, Underscore] - , definition = [Foreground Blue] - } - - --- Directory browsing for happs, suggest including this in head, as replacement for fileserve --- eg: browsedir "templates" - -browsedir :: FilePath -> FilePath -> ServerPartT IO Response -browsedir = browsedir' defPaintdir defPaintfile - -browsedirHS = browsedir' defPaintdir hsPaintfile - -browsedir' paintdir paintfile diralias d = multi [ - ServerPartT $ \rq -> do - let aliaspath = ( mypathstring $ rqPaths rq ) - if (not $ isPrefixOf diralias aliaspath) - then noHandle - else do - -- to do: s/rqp/realpath/ - let realpath = mypathstring $ d : (tail $ rqPaths rq) - isDir <- liftIO $ doesDirectoryExist realpath - if isDir - then do - fs <- liftIO $ getDirectoryContents realpath - return . toResponse $ paintdir aliaspath fs - - else do - isfile <- liftIO $ doesFileExist realpath - f <- liftIO $ readFile realpath - return $ paintfile realpath f - ] - -hsPaintfile filename f | isHaskellFile filename = - toResponse $ BrowseHtmlString $ hscolour defaultColourPrefs False False f f - | otherwise = toResponse $ f - -isHaskellFile :: FilePath -> Bool -isHaskellFile filename = - ( (drop (length filename - 3) n) ) == ".hs" - || (drop (length filename - 3) n) == ".lhs" - where n = map toLower filename - - -defPaintfile realpath f = toResponse f -defPaintdir aliaspath fs = - let flinks = map g . filter (not . boringfile ) . sort $ fs - g f = simpleLink ('/' : (combine aliaspath f)) f - in BrowseHtmlString $ "