packages feed

maid 2010.9.19 → 2010.9.29

raw patch · 3 files changed

+34/−34 lines, 3 filesdep ~hack-contribdep ~moe

Dependency ranges changed: hack-contrib, moe

Files

changelog.md view
@@ -1,3 +1,9 @@+2010.9.29+---------++### Fix++* use moe2  2010.9.19 ----------
maid.cabal view
@@ -1,5 +1,5 @@ Name:                 maid-Version:              2010.9.19+Version:              2010.9.29 Build-type:           Simple Synopsis:             A simple static web server Description:@@ -21,12 +21,12 @@   build-depends:      base >= 4 && < 5                     , mps >= 2010.1.26                     , haskell98-                    , hack-contrib >= 2010.1.26+                    , hack-contrib >= 2010.9.28                     , data-default                     , hack-handler-happstack                     , hack                     , containers-                    , moe+                    , moe >= 2010.9.29.2                     , unix                     , bytestring                     , process
src/maid.hs view
@@ -3,7 +3,7 @@  import Hack.Handler.Happstack import System (getArgs)-import MPS.Env hiding (div, log)+import MPS.Env hiding (div, log, head) import MPS.TH import MPS.Extra (u2b, b2u, strip, purify) import MPSUTF8 (ls)@@ -14,16 +14,19 @@ import Hack.Contrib.Middleware.Static import Hack.Contrib.Middleware.SimpleAccessLogger import Hack.Contrib.Middleware.UserMime+import Hack.Contrib.Middleware.Cascade+import qualified Hack as Hack+ -- import Hack.Contrib.Mime -- import Data.Map (toAscList) import Hack.Contrib.Utils (use, unescape_uri) import Hack.Contrib.Response (set_content_type) import Hack.Contrib.Request (path)-import Hack+import Hack hiding (body) import Data.ByteString.Lazy.Char8 (pack) import System.Posix.Files import Data.List (isInfixOf, sort)-import Text.HTML.Moe hiding ((/), body, head, select)+import Text.HTML.Moe2 hiding ((/), select) import Control.Monad ((>=>)) import System.Process import System.Directory (doesFileExist)@@ -38,7 +41,7 @@   let { port =      if length args == 0       then 3000-      else read - head args+      else read - first args     }      let { app =@@ -94,7 +97,7 @@     no_favicon   , content_length   , simple_access_logger - Just log-  , user_mime - parse_user_mines mime_types+  , user_mime - parse_user_mimes mime_types   -- , user_mime - mime_types.toAscList.map_fst (drop 1)   -- , \app env -> do   --   r <- app env@@ -103,18 +106,8 @@   ]      where-    parse_user_mines :: String -> [(String, String)]-    parse_user_mines = lines > reject null > map (words > head &&& words > tail > unwords)--cascade :: [Application] -> Application-cascade [] = const - return not_found-cascade (x:xs) = \env -> do-  r <- x env-  if r.status == 404-    then-      cascade xs env-    else-      return r+    parse_user_mimes :: String -> [(String, String)]+    parse_user_mimes = lines > reject null > map (words > first &&& words > tail > unwords)   no_favicon :: Middleware@@ -166,34 +159,35 @@                      maid_css_exist <- doesFileExist "maid.css"           -          css <- if maid_css_exist then readFile "maid.css" else return default_css_style+          _css <- if maid_css_exist then readFile "maid.css" else return default_css_style                                   return - def             {               status = 200-            , body = pack - dir_template sorted css (env.path.unescape_uri.b2u)+            , Hack.body = pack - dir_template sorted _css (env.path.unescape_uri.b2u)             }             .set_content_type "text/html; charset=utf-8"   dir_template :: [(String, Bool)] -> String -> String -> String-dir_template xs css current_path = render --  html' - do-    head' - do-      meta [http_equiv "Content-Type", content "text/html; charset=utf-8"]-      style' - str css-    body' - do-      div [_class "container"] - do-        ul' - do-          xs.mapM_ (\(path, dir_tag) ->-            li' - do+dir_template xs _css current_path = render -+  html - do+    head - do+      meta ! [http_equiv "Content-Type", content "text/html; charset=utf-8"] - return ()+      style - str _css+      +    body - do+      div ! [_class "container"] - do+        ul - do+          xs.mapM_ (\(_path, dir_tag) ->+            li - do               -              let path_dom = a [href - "/" / current_path / path] - str - path+              let path_dom = a ![href - "/" / current_path / _path] - str - _path                                if dir_tag                 then-                  div [_class "directory"] -+                  div ! [_class "directory"] -                     path_dom                 else                   path_dom