packages feed

loli 2010.10.9 → 2011.6.24

raw patch · 4 files changed

+30/−13 lines, 4 files

Files

loli.cabal view
@@ -1,5 +1,5 @@ Name:                 loli-Version:              2010.10.9+Version:              2011.6.24 Build-type:           Simple Synopsis:             A minimum web dev DSL in Haskell Description:
readme.md view
@@ -115,3 +115,8 @@ * loli is inspired by [Rack](http://rack.rubyforge.org), [Rails](http://rubyonrails.org), [Ramaze](http://ramaze.net), [Happstack](http://happstack.com/) and [Sinatra](http://www.sinatrarb.com/).  +<br/>++<p>+<a href="http://en.wikipedia.org/wiki/Shinryaku!_Ika_Musume"><img src="https://github.com/nfjinjing/loli/raw/master/ita.jpg"/></a>+</p>
src/Network/Loli/Middleware/LoliRouter.hs view
@@ -34,7 +34,7 @@ parse_params "" ""  = Just ("", []) parse_params "" _   = Nothing parse_params "/" "" = Nothing-parse_params "/" _  = Just ("/", [])+parse_params "/" "/"  = Just ("/", [])  parse_params t s =    let template_tokens = t.split "/"@@ -43,19 +43,24 @@   if url_tokens.length P.< template_tokens.length     then Nothing     else -      let rs = zipWith capture template_tokens url_tokens-      in-      if rs.all isJust-        then -          let token_length = template_tokens.length-              location     = "/" / url_tokens.take token_length .join "/"+      if not - ( template_tokens.length P.> 0 && template_tokens.last.is "*" ) || (template_tokens.length == url_tokens.length)+        then+          Nothing+        else +          let rs = zipWith capture template_tokens url_tokens           in-          Just - (location, rs.catMaybes.catMaybes)-        else Nothing+          if rs.all isJust+            then +              let token_length = template_tokens.length+                  location     = "/" / url_tokens.take token_length .join "/"+              in+              Just - (location, rs.catMaybes.catMaybes)+            else Nothing      where     capture x y        | x.starts_with ":" = Just - Just (x.tail, y)+      | x.is "*" = Just Nothing       | x == y = Just Nothing       | otherwise = Nothing       
src/Test/Test.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE PackageImports #-}+ import "mtl" Control.Monad.Reader import Hack.Contrib.Response -- import Hack.Handler.SimpleServer@@ -84,11 +86,16 @@       no_layout - do         text "no-layout"   -    -- default     get "/" - do-      io . print =<< ask ^ url-      text . show =<< ask+      text "match /"+    +    get "/test-star/*/hi" - do+      text "test-star/*/hi" +  -- default+    get "*" - do+      text "match everything"+           -- public serve, only allows /src     public (Just ".") ["/src"]