Changeset 1165 for lang/haskell

Show
Ignore:
Timestamp:
11/06/07 10:48:50 (13 months ago)
Author:
jknaoya
Message:

lang/haskell/blosxkel/story.xml,
lang/haskell/blosxkel/head.xml,
lang/haskell/blosxkel/config.sample,
lang/haskell/blosxkel/foot.xml,
lang/haskell/blosxkel/content_type.xml,
lang/haskell/blosxkel/blosxkel.hs:

フレーバーをサポートしました。
content_type に余計な改行が入らないようにくふうしました。

Location:
lang/haskell/blosxkel
Files:
4 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/haskell/blosxkel/blosxkel.hs

    r1162 r1165  
    1818-- ref. http://i.loveruby.net/ja/stdhaskell/samples/lazylines/Template.hs.html 
    1919fillFlavour :: String -> String -> [(String, String)] -> IO String 
    20 fillFlavour flavour place params = return . fill =<< (readFile $ place ++ "." ++ flavour) 
     20fillFlavour flavour place params = return . fill =<< (readFile $ place ++ flavour) 
    2121    where 
    2222        fill ""   = "" 
     
    104104    | otherwise                = filter (\e -> isPrefixOf (joinPath spath) (path e)) entries 
    105105    where 
    106         spath = splitDirectories pathinfo 
     106        spath | takeFileName pathi == "index" = splitDirectories $ dropFileName pathi 
     107              | otherwise                     = splitDirectories pathi 
     108        pathi = dropExtension pathinfo 
    107109 
    108110getResult :: [(String, String)] -> [(String, String)] -> IO (String, String) 
     
    116118               [("title"  , title e), 
    117119                ("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)), 
    119121                ("yr"     , strfctime "%Y"  (time e)), 
    120122                ("mo"     , strfctime "%b"  (time e)), 
     
    129131                ("fn"     , path e), 
    130132                ("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 
    132135    ; cf <- fill "foot" [] 
    133136    ; return $ (ct, concat $ [ch, concat cs, cf]) 
    134137    } 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) 
    138142 
    139143cgiMain :: CGI CGIResult 
    140144cgiMain =  do 
    141145    { 
    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 
    147158    ; output $ cb 
    148159    } 
  • lang/haskell/blosxkel/config.sample

    r1159 r1165  
    22author: jknaoya 
    33data-dir: data 
     4default-flavour: html