@@ -181,6 +181,8 @@ checkPieces :: FilePath -- ^ static file prefix
181 -> IO CheckPieces
181 -> IO CheckPieces
182checkPieces _ _ [".hidden", "folder.png"] =
182checkPieces _ _ [".hidden", "folder.png"] =
183 return $ SendContent "image/png" $ L.fromChunks [$(embedFile "folder.png")]
183 return $ SendContent "image/png" $ L.fromChunks [$(embedFile "folder.png")]
184+checkPieces _ _ [".hidden", "haskell.png"] =
185+ return $ SendContent "image/png" $ L.fromChunks [$(embedFile "haskell.png")]
184checkPieces prefix indices pieces
186checkPieces prefix indices pieces
185 | any unsafe pieces = return Forbidden
187 | any unsafe pieces = return Forbidden
186 | anyButLast null pieces =
188 | anyButLast null pieces =
@@ -282,22 +284,26 @@ defaultListing pieces localPath = do
282 let title' = if null title then "root folder" else title
284 let title' = if null title then "root folder" else title
283 H.title $ H.string title'
285 H.title $ H.string title'
284 H.style $ H.string $ unlines [ "table { margin: 0 auto; width: 760px; border-collapse: collapse; font-family: 'sans-serif'; }"
286 H.style $ H.string $ unlines [ "table { margin: 0 auto; width: 760px; border-collapse: collapse; font-family: 'sans-serif'; }"
285− , "table, th, td { border: 1px solid #98BF21; }"
287+ , "table, th, td { border: 1px solid #353948; }"
286− , "td.size { text-align: right; }"
288+ , "td.size { text-align: right; font-size: 0.7em; width: 50px }"
287− , "td.date { text-align: right; }"
289+ , "td.date { text-align: right; font-size: 0.7em; width: 130px }"
288 , "td { padding-right: 1em; padding-left: 1em; }"
290 , "td { padding-right: 1em; padding-left: 1em; }"
291+ , "th.first { background-color: white; width: 24px }"
289 , "td.first { padding-right: 0; padding-left: 0; text-align: center }"
292 , "td.first { padding-right: 0; padding-left: 0; text-align: center }"
290 , "tr { background-color: white; }"
293 , "tr { background-color: white; }"
291− , "tr.alt { background-color: #EAF2D3 }"
294+ , "tr.alt { background-color: #A3B5BA}"
292− , "th { background-color: #A7C942; color: white; font-size: 1.125em; }"
295+ , "th { background-color: #3C4569; color: white; font-size: 1.125em; }"
293 , "h1 { width: 760px; margin: 1em auto; font-size: 1em }"
296 , "h1 { width: 760px; margin: 1em auto; font-size: 1em }"
294 , "img { width: 20px }"
297 , "img { width: 20px }"
298+ , "a { text-decoration: none }"
296 H.body $ do
300 H.body $ do
297 H.h1 $ showFolder $ "" : filter (not . null) pieces
301 H.h1 $ showFolder $ "" : filter (not . null) pieces
298− renderDirectoryContentsTable folderSrc $ catMaybes fps''
302+ renderDirectoryContentsTable haskellSrc folderSrc $ catMaybes fps''
300− folderSrc = concatMap (const "../") (drop 1 pieces) ++ ".hidden/folder.png"
304+ image x = concatMap (const "../") (drop 1 pieces) ++ ".hidden/" ++ x ++ ".png"
305+ folderSrc = image "folder"
306+ haskellSrc = image "haskell"
301 showName "" = "root"
307 showName "" = "root"
302 showName x = x
308 showName x = x
303 showFolder [] = H.string "FIXME: Unexpected showFolder []"
309 showFolder [] = H.string "FIXME: Unexpected showFolder []"
@@ -317,12 +323,13 @@ defaultListing pieces localPath = do
318-- see also: 'getMetaData', 'renderDirectoryContents'
324-- see also: 'getMetaData', 'renderDirectoryContents'
319renderDirectoryContentsTable :: String
325renderDirectoryContentsTable :: String
320 -> [MetaData] -- ^ list of files+meta data, see 'getMetaData'
327 -> [MetaData] -- ^ list of files+meta data, see 'getMetaData'
321 -> H.Html
328 -> H.Html
322−renderDirectoryContentsTable folderSrc fps =
329+renderDirectoryContentsTable haskellSrc folderSrc fps =
323− H.table $ do H.thead $ do H.th $ H.string ""
330+ H.table $ do H.thead $ do H.th ! (A.class_ $ H.stringValue "first") $ H.img ! (A.src $ H.stringValue haskellSrc)
324 H.th $ H.string "Name"
331 H.th $ H.string "Name"
325− H.th $ H.string "Last modified"
332+ H.th $ H.string "Modified"
326 H.th $ H.string "Size"
333 H.th $ H.string "Size"
327 H.tbody $ mapM_ mkRow (zip (sortBy sortMD fps) $ cycle [False, True])
334 H.tbody $ mapM_ mkRow (zip (sortBy sortMD fps) $ cycle [False, True])
@@ -341,16 +348,26 @@ renderDirectoryContentsTable folderSrc fps =
341 H.td (H.a ! A.href (H.stringValue $ mdName md ++ if mdIsFile md then "" else "/") $ H.string $ mdName md)
348 H.td (H.a ! A.href (H.stringValue $ mdName md ++ if mdIsFile md then "" else "/") $ H.string $ mdName md)
342 H.td ! A.class_ (H.stringValue "date") $ H.string $
349 H.td ! A.class_ (H.stringValue "date") $ H.string $
343 if mdIsFile md
350 if mdIsFile md
344− then formatCalendarTime defaultTimeLocale "%d-%b-%Y %X %Z" $ mdModified md
351+ then formatCalendarTime defaultTimeLocale "%d-%b-%Y %X" $ mdModified md
346 H.td ! A.class_ (H.stringValue "size") $ H.string $
353 H.td ! A.class_ (H.stringValue "size") $ H.string $
347 if mdIsFile md
354 if mdIsFile md
348 then prettyShow $ mdSize md
355 then prettyShow $ mdSize md
350 formatCalendarTime a b c = formatTime a b $ posixSecondsToUTCTime (realToFrac c :: POSIXTime)
357 formatCalendarTime a b c = formatTime a b $ posixSecondsToUTCTime (realToFrac c :: POSIXTime)
359+ | x > 1024 = prettyShowK $ x `div` 1024
360+ | otherwise = addCommas "B" x
362+ | x > 1024 = prettyShowM $ x `div` 1024
363+ | otherwise = addCommas "KB" x
365+ | x > 1024 = prettyShowG $ x `div` 1024
366+ | otherwise = addCommas "MB" x
367+ prettyShowG x = addCommas "GB" x
351− prettyShow = (++ " bytes") . reverse . addCommas . reverse . show
368+ addCommas s = (++ (' ' : s)) . reverse . addCommas' . reverse . show
352− addCommas (a:b:c:d:e) = a : b : c : ',' : addCommas (d : e)
369+ addCommas' (a:b:c:d:e) = a : b : c : ',' : addCommas' (d : e)
353− addCommas x = x
370+ addCommas' x = x
356data MetaData =
373data MetaData =