loli: A minimum web dev DSL in Haskell

[ bsd3, deprecated, library, web ] [ Propose Tags ]
Deprecated in favor of miku

A simple and easy to use library for fast web prototyping in Haskell.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 2009.6.25, 2009.6.26, 2009.6.27, 2009.6.29, 2009.7.2, 2009.8.16, 2009.8.18, 2009.10.13, 2010.10.9, 2011.6.24
Change log changelog.md
Dependencies base (>4 && <=5), bytestring, containers, data-default, hack (>=2009.5.19), hack-contrib (>=2009.6.25), mps (>=2009.6.25), mtl, template, utf8-string [details]
License BSD-3-Clause
Author Wang, Jinjing
Maintainer Wang, Jinjing <nfjinjing@gmail.com>
Category Web
Home page http://github.com/nfjinjing/loli
Uploaded by JinjingWang at 2009-06-26T16:16:13Z
Distributions
Reverse Dependencies 2 direct, 3 indirect [details]
Downloads 7004 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for loli-2009.6.27

[back to package description]

loli

A minimum web dev DSL

Example

First app

-- myloli.hs

import Network.Loli
import Hack.Handler.Happstack

main = run . loli $ get "/" (text "loli power")

Install and compile:

cabal update
cabal install loli
cabal install hack-handler-happstack

ghc --make myloli.hs
./myloli

check: http://localhost:3000

Routes

Verb

get "/" $ do
  -- something for a get request

post "/" $ do
  -- for a post request

put "/" $ do
  -- put ..

delete "/" $ do
  -- ..

Captures

get "/say/:user/:something" $ do
  text . show =<< captures

-- /say/jinjing/hello will output
-- [("user","jinjing"),("something","hello")]

Static

-- public serve, only allows /src
public (Just ".") ["/src"]

Views

-- in `./views`, can be changed by
views "template"

Text Template

import Network.Loli.Template.TextTemplate

-- template
get "/hi/:user" $ text_template "hello.html"

-- in hello.html
<html>
<title>hello</title>
<body>
  <p>hello $user</p>
</body>
</html>

Local bindings

get "/local-binding" $ do
  bind "user" "alice" (text_template "hello.html")

Batched local bindings

get "/batched-local-binding" $ do
  context [("user", "alice"), ("password", "foo")] $ 
    text . show =<< bindings

Mime types

-- treat .hs extension as text/plain
mime "hs" "text/plain"

Note

If you see this, use the git version!