1{-# LANGUAGE OverloadedStrings #-}
3 ( relativeDirFromPieces
9import WaiAppStatic.Types
10import qualified Data.Text as T
11import Data.ByteString (ByteString)
12import qualified Data.ByteString.Char8 as S8
13import qualified Data.Text.Encoding as TE
15-- alist helper functions
16replace :: Eq a => a -> b -> [(a, b)] -> [(a, b)]
17replace k v [] = [(k,v)]
18replace k v (x:xs) | fst x == k = (k,v):xs
19 | otherwise = x:replace k v xs
21remove :: Eq a => a -> [(a, b)] -> [(a, b)]
23remove k (x:xs) | fst x == k = xs
24 | otherwise = x:remove k xs
26-- | Turn a list of pieces into a relative path to the root folder.
27relativeDirFromPieces :: Pieces -> T.Text
28relativeDirFromPieces pieces = T.concat $ map (const "../") (drop 1 pieces) -- last piece is not a dir
30-- | Construct redirects with relative paths.
31defaultMkRedirect :: Pieces -> ByteString -> S8.ByteString
32defaultMkRedirect pieces newPath
33 | S8.null newPath || S8.null relDir ||
34 S8.last relDir /= '/' || S8.head newPath /= '/' =
35 relDir `S8.append` newPath
36 | otherwise = relDir `S8.append` S8.tail newPath
38 relDir = TE.encodeUtf8 (relativeDirFromPieces pieces)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list