Changeset 1165 for lang/haskell
- Timestamp:
- 11/06/07 10:48:50 (13 months ago)
- Location:
- lang/haskell/blosxkel
- Files:
-
- 4 added
- 2 modified
-
blosxkel.hs (modified) (4 diffs)
-
config.sample (modified) (1 diff)
-
content_type.xml (added)
-
foot.xml (added)
-
head.xml (added)
-
story.xml (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/haskell/blosxkel/blosxkel.hs
r1162 r1165 18 18 -- ref. http://i.loveruby.net/ja/stdhaskell/samples/lazylines/Template.hs.html 19 19 fillFlavour :: String -> String -> [(String, String)] -> IO String 20 fillFlavour flavour place params = return . fill =<< (readFile $ place ++ "." ++flavour)20 fillFlavour flavour place params = return . fill =<< (readFile $ place ++ flavour) 21 21 where 22 22 fill "" = "" … … 104 104 | otherwise = filter (\e -> isPrefixOf (joinPath spath) (path e)) entries 105 105 where 106 spath = splitDirectories pathinfo 106 spath | takeFileName pathi == "index" = splitDirectories $ dropFileName pathi 107 | otherwise = splitDirectories pathi 108 pathi = dropExtension pathinfo 107 109 108 110 getResult :: [(String, String)] -> [(String, String)] -> IO (String, String) … … 116 118 [("title" , title e), 117 119 ("body" , concat (body e)), 118 ("time" , strfctime "%Y-%m-%d %H:%M:%S" (time e)),120 ("time" , strfctime "%Y-%m-%dT%H:%M:%SZ" (time e)), 119 121 ("yr" , strfctime "%Y" (time e)), 120 122 ("mo" , strfctime "%b" (time e)), … … 129 131 ("fn" , path e), 130 132 ("path" , path e)]) 131 $ take 7 $ reverse $ sortBy (\a b -> compare (time a) (time b)) $ filterByPathInfo (fromJust $ lookup "pathinfo" cgiparams) entries 133 $ take 7 $ reverse $ sortBy (\a b -> compare (time a) (time b)) 134 $ filterByPathInfo (fromJust $ lookup "pathinfo" cgiparams) entries 132 135 ; cf <- fill "foot" [] 133 136 ; return $ (ct, concat $ [ch, concat cs, cf]) 134 137 } where 135 fill place params = fillFlavour "html" place (params ++ [("title" , getConfig config "title"), 136 ("author" , getConfig config "author"), 137 ("version", "How do I get this version of GHC in program?")] ++ cgiparams) 138 fill place params = fillFlavour (getConfig cgiparams "flavour") place 139 (params ++ [("title" , getConfig config "title"), 140 ("author" , getConfig config "author"), 141 ("version", "How do I get this version of GHC in program?")] ++ cgiparams) 138 142 139 143 cgiMain :: CGI CGIResult 140 144 cgiMain = do 141 145 { 142 ; config <- liftIO $ loadConfig "config" 143 ; home <- scriptName 144 ; pathinfo <- pathInfo 145 ; (ct, cb) <- liftIO $ getResult [("home", home), ("pathinfo", pathinfo)] config 146 ; setHeader "Content-Type" $ ct 146 ; config <- liftIO $ loadConfig "config" 147 ; home <- scriptName 148 ; pathinfo <- pathInfo 149 ; servername <- serverName 150 ; flavour <- return $ takeExtension pathinfo 151 ; (ct, cb) <- liftIO $ getResult [("home", home), 152 ("pathinfo", pathinfo), 153 ("servername", "http://" ++ servername), 154 ("flavour", if length flavour == 0 155 then getConfig config "default-flavour" 156 else flavour)] config 157 ; setHeader "Content-Type" $ reverse $ dropWhile isSpace $ reverse $ ct 147 158 ; output $ cb 148 159 } -
lang/haskell/blosxkel/config.sample
r1159 r1165 2 2 author: jknaoya 3 3 data-dir: data 4 default-flavour: html
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)