Changeset 1161

Show
Ignore:
Timestamp:
11/06/07 01:50:00 (6 years ago)
Author:
jknaoya
Message:

lang/haskell/blosxkel/blosxkel.hs:

path_info によるフィルタリングを実装してみました。まだ完全ではないです

Files:
1 modified

Legend:

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

    r1160 r1161  
    9292 
    9393 
     94filterByPathInfo :: String -> [Entry] -> [Entry] 
     95filterByPathInfo pathinfo entries 
     96    | length spath == 2 && 
     97      all isDigit (spath !! 1) = filter (\e -> (formatCalendarTime defaultTimeLocale "/%Y" (toUTCTime (time e))) == joinPath spath) entries 
     98    | length spath == 3 && 
     99      all isDigit (spath !! 1) = filter (\e -> (formatCalendarTime defaultTimeLocale "/%Y/%m" (toUTCTime (time e))) == joinPath spath) entries 
     100    | length spath == 4 && 
     101      all isDigit (spath !! 1) = filter (\e -> (formatCalendarTime defaultTimeLocale "/%Y/%m/%d" (toUTCTime (time e))) == joinPath spath) entries 
     102    | otherwise                = filter (\e -> isPrefixOf (joinPath spath) (path e)) entries 
     103    where 
     104        spath = splitDirectories pathinfo 
     105 
    94106getResult :: [(String, String)] -> [(String, String)] -> IO (String, String) 
    95107getResult cgiparams config = do 
     
    115127                ("fn"     , path e), 
    116128                ("path"   , path e)]) 
    117                $ take 7 $ reverse $ sortBy (\a b -> compare (time a) (time b)) entries 
     129               $ take 7 $ reverse $ sortBy (\a b -> compare (time a) (time b)) $ filterByPathInfo (fromJust $ lookup "pathinfo" cgiparams) entries 
    118130    ; cf <- fill "foot" [] 
    119131    ; return $ (ct, concat $ [ch, concat cs, cf]) 
     
    121133        fill place params = fillFlavour "html" place (params ++ [("title"  , getConfig config "title"), 
    122134                                                                 ("author" , getConfig config "author"), 
    123                                                                  ("version", "How I can get this version of GHC in program?")] ++ cgiparams) 
     135                                                                 ("version", "How do I get this version of GHC in program?")] ++ cgiparams) 
    124136 
    125137cgiMain :: CGI CGIResult