Changeset 1156 for lang/haskell

Show
Ignore:
Timestamp:
11/05/07 20:35:41 (6 years ago)
Author:
jknaoya
Message:

lang/haskell/blosxkel/head.html,
lang/haskell/blosxkel/foot.html,
lang/haskell/blosxkel/blosxkel.hs:

もうすこしシンプルにしてみました。
fill 関数の中で scriptName や pathInfo といった
MonadCGI の関数をよんで title などと一緒にセットしたいですがよくわかりません……

Location:
lang/haskell/blosxkel
Files:
3 modified

Legend:

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

    r1155 r1156  
    1919-- ref. http://i.loveruby.net/ja/stdhaskell/samples/lazylines/Template.hs.html 
    2020fillFlavour :: String -> String -> [(String, String)] -> IO String 
    21 fillFlavour place flavour params = return . fill =<< (readFile $ place ++ "." ++ flavour) 
     21fillFlavour flavour place params = return . fill =<< (readFile $ place ++ "." ++ flavour) 
    2222    where 
    2323        fill ""   = "" 
     
    7575    } 
    7676 
    77 applyStory :: Entry -> IO String 
    78 applyStory e = fillFlavour "story" "html" [("title", title e), 
    79                                            ("body", concat (body e)), 
    80                                            ("time", formatCalendarTime defaultTimeLocale "%Y-%m-%d %H:%M:%S" (toUTCTime (time e))), 
    81                                            ("path", path e)] 
     77applyStory :: (String -> [(String, String)] -> IO String) -> Entry -> IO String 
     78applyStory fill e = fill "story" [("title", title e), 
     79                                  ("body", concat (body e)), 
     80                                  ("time", formatCalendarTime defaultTimeLocale "%Y-%m-%d %H:%M:%S" (toUTCTime (time e))), 
     81                                  ("path", path e)] 
    8282 
    8383cgiMain :: CGI CGIResult 
     
    8585    { 
    8686    ; entries <- liftIO $ getTextFileEntries "data" 
    87     ; ct <- liftIO $ fillFlavour "content_type" "html" [] 
    88     ; ch <- liftIO $ fillFlavour "head"  "html" [("title", "hogehoge")] 
    89     ; cs <- liftIO $ mapM applyStory $ take 7 $ reverse $ sortBy (\a b -> compare (time a) (time b)) entries 
    90     ; cf <- liftIO $ fillFlavour "foot"  "html" [("title", "hogehoge")] 
     87    ; ct <- liftIO $ fill "content_type" [] 
     88    ; ch <- liftIO $ fill "head" [] 
     89    ; cs <- liftIO $ mapM (applyStory fill) $ take 7 $ reverse $ sortBy (\a b -> compare (time a) (time b)) entries 
     90    ; cf <- liftIO $ fill "foot" [] 
    9191    ; setHeader "Content-Type" ct 
    9292    ; output $ concat $ [ch, concat cs, cf] 
    93     } 
     93    } where 
     94        fill place params = fillFlavour "html" place (params ++ [("title", "Blosxkel.hs"), 
     95                                                                 ("version", "aaa")]) 
    9496 
    9597main :: IO () 
  • lang/haskell/blosxkel/foot.html

    r1153 r1156  
    22 
    33                        <div id="footer"> 
     4                <p>$version</p> 
    45                        </div> 
    56                </div> 
  • lang/haskell/blosxkel/head.html

    r1155 r1156  
    9393            <h1 id="top"><a href="/">$title</a></h1> 
    9494 
     95            <p>$home</p> 
     96 
    9597            <div id="content">