Changeset 1159 for lang/haskell
- Timestamp:
- 11/06/07 00:51:28 (6 years ago)
- Location:
- lang/haskell/blosxkel
- Files:
-
- 1 added
- 2 modified
-
. (modified) (1 prop)
-
blosxkel.hs (modified) (4 diffs)
-
config.sample (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/blosxkel
- Property svn:ignore
-
old new 3 3 blosxkel.o 4 4 blosxkel.cgi 5 config
-
- Property svn:ignore
-
lang/haskell/blosxkel/blosxkel.hs
r1158 r1159 31 31 expand var = fromMaybe ('$':var) (lookup var params) 32 32 33 loadConfig :: String -> IO [(String, String)] 34 loadConfig config = do 35 { 36 ; c <- readFile config 37 ; return $ concatMap parseLine $ lines c 38 } where 39 parseLine :: String -> [(String, String)] 40 parseLine l 41 | all isSpace l = [] 42 | otherwise = let (k, (':':v)) = (break (== ':') l) 43 in [(strip k, strip v)] 44 strip = rstrip . lstrip 45 rstrip = reverse . lstrip . reverse 46 lstrip = dropWhile isSpace 47 48 getConfig :: [(String, String)] -> String -> String 49 getConfig config key = fromJust $ lookup key config 33 50 34 51 data Entry = Entry { … … 78 95 79 96 80 getResult :: [(String, String)] -> IO (String, String)81 getResult cgiparams = do97 getResult :: [(String, String)] -> [(String, String)] -> IO (String, String) 98 getResult cgiparams config = do 82 99 { 83 ; entries <- getTextFileEntries "data"100 ; entries <- getTextFileEntries $ getConfig config "data-dir" 84 101 ; ct <- fill "content_type" [] 85 102 ; ch <- fill "head" [] … … 94 111 ; return $ (ct, concat $ [ch, concat cs, cf]) 95 112 } where 96 fill place params = fillFlavour "html" place (params ++ [("title", "Blosxkel.hs"), 113 fill place params = fillFlavour "html" place (params ++ [("title", getConfig config "title"), 114 ("author", getConfig config "author"), 97 115 ("version", "aaa")] ++ cgiparams) 98 116 … … 100 118 cgiMain = do 101 119 { 120 ; config <- liftIO $ loadConfig "config" 102 121 ; home <- scriptName 103 122 ; pathinfo <- pathInfo 104 ; result <- liftIO $ getResult [("home", home), ("pathinfo", pathinfo)]105 ; setHeader "Content-Type" $ fst result106 ; output $ snd result123 ; (ct, cb) <- liftIO $ getResult [("home", home), ("pathinfo", pathinfo)] config 124 ; setHeader "Content-Type" $ ct 125 ; output $ cb 107 126 } 108 127
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)