on master help sign in
Listing uses a Builder
6f207a0Michael Snoyman
wai-app-static/Listing.hs+1−1
@@ -27,7 +27,7 @@ defaultListing pieces (Folder _ contents) = do
27 let isTop = null pieces || map Just pieces == [toPiece ""]
27 let isTop = null pieces || map Just pieces == [toPiece ""]
28 let fps'' :: [Either Folder File]
28 let fps'' :: [Either Folder File]
29 fps'' = (if isTop then id else (Left emptyParentFolder :)) contents -- FIXME emptyParentFolder feels like a bit of a hack
29 fps'' = (if isTop then id else (Left emptyParentFolder :)) contents -- FIXME emptyParentFolder feels like a bit of a hack
30− return $ HU.renderHtml
30+ return $ HU.renderHtmlBuilder
31 $ H.html $ do
31 $ H.html $ do
32 H.head $ do
32 H.head $ do
33 let title = T.intercalate "/" $ map fromPiece pieces
33 let title = T.intercalate "/" $ map fromPiece pieces
wai-app-static/Network/Wai/Application/Static.hs+3−3
@@ -117,10 +117,10 @@ serveFolder ss@StaticSettings {..} pieces req folder@Folder {..} =
117 case ssListing of
117 case ssListing of
118 Just listing -> do
118 Just listing -> do
119 -- directory listings turned on, display it
119 -- directory listings turned on, display it
120− lbs <- listing pieces folder
120+ builder <- listing pieces folder
121− return $ WaiResponse $ W.responseLBS H.status200
121+ return $ WaiResponse $ W.ResponseBuilder H.status200
122 [ ("Content-Type", "text/html; charset=utf-8")
122 [ ("Content-Type", "text/html; charset=utf-8")
123− ] lbs
123+ ] builder
124 Nothing -> return $ WaiResponse $ W.responseLBS H.status403
124 Nothing -> return $ WaiResponse $ W.responseLBS H.status403
125 [ ("Content-Type", "text/plain")
125 [ ("Content-Type", "text/plain")
126 ] "Directory listings disabled"
126 ] "Directory listings disabled"
wai-app-static/WaiAppStatic/Types.hs+2−2
@@ -26,7 +26,7 @@ import Data.ByteString (ByteString)
26import System.Posix.Types (EpochTime)
26import System.Posix.Types (EpochTime)
27import qualified Data.Text as T
27import qualified Data.Text as T
28import qualified Data.Map as Map
28import qualified Data.Map as Map
29−import qualified Data.ByteString.Lazy as L
29+import Blaze.ByteString.Builder (Builder)
30
30
31-- | An individual component of a path, or of a filepath.
31-- | An individual component of a path, or of a filepath.
32newtype Piece = Piece { fromPiece :: Text }
32newtype Piece = Piece { fromPiece :: Text }
@@ -88,7 +88,7 @@ data LookupResult = LRFile File
88 | LRFolder Folder
88 | LRFolder Folder
89 | LRNotFound
89 | LRNotFound
90
90
91−type Listing = Pieces -> Folder -> IO L.ByteString
91+type Listing = Pieces -> Folder -> IO Builder
92
92
93data StaticSettings = StaticSettings
93data StaticSettings = StaticSettings
94 { -- | Lookup a single file or folder.
94 { -- | Lookup a single file or folder.