on master help sign in
Add a link to the root of the tree. fpco/libraries#72
fd43643Dan Burton
wai-app-static/WaiAppStatic/Listing.hs+6−2
@@ -48,7 +48,7 @@ defaultListing pieces (Folder contents) = do
48 , "a { text-decoration: none }"
48 , "a { text-decoration: none }"
49 ]
49 ]
50 H.body $ do
50 H.body $ do
51− H.h1 $ showFolder $ filter (not . T.null . fromPiece) pieces
51+ H.h1 $ showFolder' $ filter (not . T.null . fromPiece) pieces
52 renderDirectoryContentsTable haskellSrc folderSrc fps''
52 renderDirectoryContentsTable haskellSrc folderSrc fps''
53 where
53 where
54 image x = T.unpack $ T.concat [(relativeDirFromPieces pieces), ".hidden/", x, ".png"]
54 image x = T.unpack $ T.concat [(relativeDirFromPieces pieces), ".hidden/", x, ".png"]
@@ -57,8 +57,12 @@ defaultListing pieces (Folder contents) = do
57 showName "" = "root"
57 showName "" = "root"
58 showName x = x
58 showName x = x
59
59
60+ -- Add a link to the root of the tree
61+ showFolder' :: Pieces -> H.Html
62+ showFolder' pieces = showFolder (unsafeToPiece "root" : pieces)
63+
60 showFolder :: Pieces -> H.Html
64 showFolder :: Pieces -> H.Html
61− showFolder [] = "/"
65+ showFolder [] = "/" -- won't happen
62 showFolder [x] = H.toHtml $ showName $ fromPiece x
66 showFolder [x] = H.toHtml $ showName $ fromPiece x
63 showFolder (x:xs) = do
67 showFolder (x:xs) = do
64 let href = concat $ replicate (length xs) "../" :: String
68 let href = concat $ replicate (length xs) "../" :: String