I have been working on a simple web "framework" for programming web
apps using clojure.
I'm planning to put it to sourceforge under the CPL license very soon.
Features:
Basic dispatching to clojure functions:
Functions can be registered to the servlet's dispatch table with
(webjure/publish <fn> <url-pattern>)
Where <fn> is a 3 argument handler function (method, request and
response) and
<url-pattern> is an url pattern (like "/foo" or "/bar*"). The shortest
matching handler
will be called for a request.
HTML generation expressions:
HTML output can be generated from clojure forms with html-format.
(webjure/html-format
(webjure/response-writer resp)
`(:html
(:body
(:a {:href "
http://clojure.sf.net" :style "font-weight: bold;"}
"Clojure site"))))
SQL queries:
Simple SQL query (with query parameters) support using JDBC.
(sql/query *db* "SELECT * FROM cities WHERE country_iso_code = ?"
"FI")
Returns a sequence of rows where each row is a sequence of values.
The returned result sequence has a meta attached to it that provides
information on the result set columns and size.
Trying it out:
You can try the current version by downloading
http://homepage.mac.com/tatu.tarvainen/webjure.war
into a servlet container's webapps directory (tested with Jetty 6.1.7
on Mac OS X and Linux).
When the servlet container is started, point your browser to
http://localhost:8080/webjure/index
Demos included:
- simple html generation (the index page)
- request header dump
- SQL listings as tables (requires the "toursdb" directory from derby)
- AJAX REPL (very buggy and basic functionality)
Extract the war to look at the source files.
Also: this is running with a slightly patched version of clojure
20080106, but the classloader
issues should be resolved in the SVN version, so I should be able to
get that working soon.