Changeset 1158 for lang/haskell
- Timestamp:
- 11/05/07 22:06:28 (13 months ago)
- Files:
-
- 1 modified
-
lang/haskell/blosxkel/blosxkel.hs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/blosxkel/blosxkel.hs
r1157 r1158 4 4 module Main where 5 5 6 import System.FilePath 6 7 import System.Directory 7 8 import System.Time … … 11 12 import Data.Maybe 12 13 import Data.Char 14 import Data.Eq 13 15 14 16 import Network.CGI … … 31 33 32 34 data Entry = Entry { 33 path :: FilePath, 35 file :: FilePath, 36 path :: String, 34 37 title :: String, 35 38 time :: ClockTime, … … 38 41 39 42 40 getFileEntry :: FilePath -> IO Entry 41 getFileEntry f = do 42 { mtime <- getModificationTime f 43 getFileEntry :: String -> FilePath -> IO Entry 44 getFileEntry d f = do 45 { 46 ; mtime <- getModificationTime f 43 47 ; cs <- readFile f 44 48 ; case lines cs of 45 h:tl -> return $ Entry { path = f 49 h:tl -> return $ Entry { file = f 50 , path = dropExtension $ drop (length d) f 46 51 , title = h 47 52 , time = mtime … … 53 58 getRecursiveContents :: FilePath -> IO [FilePath] 54 59 getRecursiveContents fp = getDirectoryContents fp >>= mapM (fx fp) >>= return . concat 55 where56 fx :: FilePath -> FilePath -> IO [FilePath]57 fx bp "." = return [bp]58 fx bp ".." = return []59 fx bp f = do let np = bp ++ ('/':f)60 b <- doesDirectoryExist np61 if b then getRecursiveContents np62 else return [np]60 where 61 fx :: FilePath -> FilePath -> IO [FilePath] 62 fx bp "." = return [bp] 63 fx bp ".." = return [] 64 fx bp f = do let np = bp ++ ('/':f) 65 b <- doesDirectoryExist np 66 if b then getRecursiveContents np 67 else return [np] 63 68 64 69 … … 67 72 getTextFileEntries d = do 68 73 { 69 ; cdir <- getCurrentDirectory 70 ; setCurrentDirectory d 71 ; fs <- getRecursiveContents "." 72 ; es <- mapM getFileEntry $ filter (isSuffixOf ".txt") fs 73 ; setCurrentDirectory cdir 74 ; fs <- getRecursiveContents d 75 ; es <- mapM (getFileEntry d) $ filter (isSuffixOf ".txt") fs 74 76 ; return es 75 77 } … … 99 101 { 100 102 ; home <- scriptName 101 ; result <- liftIO $ getResult [("home", home)] 103 ; pathinfo <- pathInfo 104 ; result <- liftIO $ getResult [("home", home), ("pathinfo", pathinfo)] 102 105 ; setHeader "Content-Type" $ fst result 103 106 ; output $ snd result
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)