Permalink
Browse files

Merge branch '0.4'

  • Loading branch information...
weavejester committed Mar 21, 2010
2 parents 4008389 + 4c1f6b5 commit 6f21014f2c28f7d551551e40bc17cae1958e96bb
Showing with 211 additions and 3,323 deletions.
  1. +1 −0 .gitignore
  2. +0 −62 README.markdown
  3. +51 −0 README.md
  4. +0 −90 build.xml
  5. +8 −25 project.clj
  6. +0 −29 src/compojure.clj
  7. +0 −73 src/compojure/control.clj
  8. +113 −0 src/compojure/core.clj
  9. +0 −129 src/compojure/crypto.clj
  10. +0 −64 src/compojure/encodings.clj
  11. +0 −16 src/compojure/html.clj
  12. +0 −169 src/compojure/html/form_helpers.clj
  13. +0 −124 src/compojure/html/gen.clj
  14. +0 −103 src/compojure/html/page_helpers.clj
  15. +0 −19 src/compojure/http.clj
  16. +0 −76 src/compojure/http/helpers.clj
  17. +0 −131 src/compojure/http/middleware.clj
  18. +0 −80 src/compojure/http/multipart.clj
  19. +0 −109 src/compojure/http/request.clj
  20. +0 −106 src/compojure/http/response.clj
  21. +0 −243 src/compojure/http/routes.clj
  22. +0 −129 src/compojure/http/servlet.clj
  23. +0 −243 src/compojure/http/session.clj
  24. +0 −21 src/compojure/map_utils.clj
  25. +0 −23 src/compojure/ns_utils.clj
  26. +16 −10 src/compojure/{validation/predicates.clj → response.clj}
  27. +0 −26 src/compojure/server/common.clj
  28. +0 −74 src/compojure/server/grizzly.clj
  29. +0 −106 src/compojure/server/jetty.clj
  30. +0 −86 src/compojure/str_utils.clj
  31. +0 −91 src/compojure/validation.clj
  32. +22 −0 test/compojure/core_test.clj
  33. +0 −35 test/compojure/crypto_test.clj
  34. +0 −118 test/compojure/html/form_helpers_test.clj
  35. +0 −93 test/compojure/html/gen_test.clj
  36. +0 −71 test/compojure/html/page_helpers_test.clj
  37. +0 −21 test/compojure/http/helpers_test.clj
  38. +0 −115 test/compojure/http/middleware_test.clj
  39. +0 −51 test/compojure/http/request_test.clj
  40. +0 −46 test/compojure/http/response_test.clj
  41. +0 −168 test/compojure/http/routes_test.clj
  42. +0 −73 test/compojure/http/session_test.clj
  43. +0 −7 test/compojure/str_utils_test.clj
  44. +0 −37 test/compojure/validation_test.clj
  45. +0 −14 test/helpers.clj
  46. +0 −17 test/run.clj
View
@@ -1,5 +1,6 @@
lib
classes
lib
compojure.jar
deps
deps.zip
View
@@ -1,62 +0,0 @@
Compojure is an open source web framework for the [Clojure](http://clojure.org)
programming language. It emphasizes a thin I/O layer and a functional approach
to web development.
Compojure is still in active development. The current stable branch has been
released as version 0.3.1.
Sample Code
-----------
Here's a small web application written in Compojure:
(use 'compojure)
(defroutes my-app
(GET "/"
(html [:h1 "Hello World"]))
(ANY "*"
(page-not-found)))
(run-server {:port 8080}
"/*" (servlet my-app))
Dependencies
------------
To run Compojure, you'll need:
* The [Clojure](http://clojure.org) programming language
* The [Clojure-Contrib](http://code.google.com/p/clojure-contrib/) library
* A Java servlet container like [Jetty](http://www.mortbay.org/jetty/)
* Apache Commons [FileUpload](http://commons.apache.org/fileupload),
[IO](http://commons.apache.org/io) and
[Codec](http://commons.apache.org/codec).
These dependencies can be downloaded automatically using:
ant deps
Documentation
-------------
For information on how to get started and use Compojure, please see our
[Wiki](http://en.wikibooks.org/wiki/Compojure).
There is also a rough draft of a [Compojure Tutorial](http://groups.google.com/group/compojure/browse_thread/thread/3c507da23540da6e)
available to read.
Community
---------
The [Compojure Group](http://groups.google.com/group/compojure) is the best place
to ask questions about Compojure, suggest improvements or to report bugs.
Tutorials
---------
Eric Lavigne has written a series of excellent tutorials on Compojure:
* [Install Compojure on a Slicehost VPS](http://ericlavigne.wordpress.com/2008/12/18/compojure-on-a-slicehost-vps/)
* [Using PostgreSQL with Compojure](http://ericlavigne.wordpress.com/2008/12/28/using-postgresql-with-compojure/)
* [Compojure security: authentication and authorization](http://ericlavigne.wordpress.com/2009/01/04/compojure-security-authentication-and-authorization/)
View
@@ -0,0 +1,51 @@
Compojure is a small, open source web framework for the
[Clojure](http://clojure.org) programming language.
This is the latest development version of Compojure. For the latest stable
version, see [0.3.2](http://github.com/weavejester/compojure/tree/0.3.2).
An Example
----------
Here's a small web application written using Compojure,
[Ring](http://github.com/mmcgrana/ring) and
[Hiccup](http://github.com/weavejester/hiccup).
(ns hello-world
(:use [compojure.core :only (defroutes GET ANY)]
[hiccup.core :only (html)]
[ring.adapter.jetty :only (run-jetty)]
[ring.util.response :only (redirect)]))
(defroutes main-routes
(GET "/" []
(redirect "/world"))
(GET "/:name" [name]
(html [:h1 "Hello " name]))
(ANY "*" {uri :uri}
{:status 404
:body (html [:h1 "Page not found: " uri])}))
(run-jetty main-routes {:port 8080})
Installing
----------
The easiest way to use Compojure in your own projects is via
[Leiningen](http://github.com/technomancy/leiningen). Add the following
dependency to your project.clj file:
[compojure "0.4.0-SNAPSHOT"]
To build Compojure from source, run the following commands:
lein deps
lein jar
Mailing List
------------
Compojure has a [Google Group](http://groups.google.com/group/compojure). This
is the best place to ask questions and report bugs.
View
@@ -1,90 +0,0 @@
<project name="compojure" default="jar">
<description>
Compojure library package.
</description>
<property name="build.dir" location="classes"/>
<property name="deps.dir" location="deps"/>
<property name="source.dir" location="src"/>
<property name="tests.dir" location="test"/>
<property name="compojure.jar" location="compojure.jar"/>
<property name="deps.file" value="deps.zip"/>
<property name="deps.url" value="http://cloud.github.com/downloads/weavejester/compojure/${deps.file}"/>
<path id="classpath">
<path location="${build.dir}"/>
<path location="${source.dir}"/>
<fileset dir="${deps.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean" description="Remove generated files">
<delete file="${compojure.jar}"/>
<delete dir="${build.dir}"/>
</target>
<target name="init" depends="clean">
<tstamp/>
<mkdir dir="${build.dir}"/>
</target>
<target name="compile" depends="compile-compojure, compile-grizzly-server" description="Compile sources."/>
<target name="compile-compojure" depends="init" description="Compile compojure sources">
<java classname="clojure.lang.Compile" fork="true">
<sysproperty key="clojure.compile.path" value="${build.dir}"/>
<classpath refid="classpath"/>
<arg value="compojure"/>
<arg value="compojure.control"/>
<arg value="compojure.html"/>
<arg value="compojure.html.gen"/>
<arg value="compojure.html.form-helpers"/>
<arg value="compojure.html.page-helpers"/>
<arg value="compojure.http"/>
<arg value="compojure.http.routes"/>
<arg value="compojure.http.request"/>
<arg value="compojure.http.response"/>
<arg value="compojure.http.session"/>
<arg value="compojure.http.servlet"/>
<arg value="compojure.http.helpers"/>
<arg value="compojure.ns-utils"/>
<arg value="compojure.server.common"/>
<arg value="compojure.server.jetty"/>
<arg value="compojure.str-utils"/>
<arg value="compojure.validation"/>
</java>
</target>
<target name="compile-grizzly-server" depends="compile-compojure" description="Compile Grizzly server" if="with.grizzly">
<java classname="clojure.lang.Compile">
<sysproperty key="clojure.compile.path" value="${build.dir}"/>
<classpath refid="classpath"/>
<arg value="compojure.server.grizzly"/>
</java>
</target>
<target name="test" description="Run tests">
<java fork="true" classname="clojure.main" failonerror="true">
<classpath>
<path refid="classpath"/>
<path location="${tests.dir}"/>
<path location="."/>
</classpath>
<arg value="${tests.dir}/run.clj"/>
</java>
</target>
<target name="jar" description="Create jar file" depends="compile">
<jar jarfile="${compojure.jar}">
<path location="LICENSE"/>
<fileset dir="${source.dir}" includes="**/*.clj"/>
<fileset dir="${build.dir}" includes="**/*.class"/>
</jar>
</target>
<target name="deps" description="Download dependencies and unzip">
<get usetimestamp="true" description="Clojure dependencies." src="${deps.url}" dest="${deps.file}"/>
<unzip src="${deps.file}" dest="."/>
</target>
</project>
View
@@ -1,27 +1,10 @@
(defproject compojure "0.3.2"
(defproject compojure "0.4.0-SNAPSHOT"
:description "A concise web framework for Clojure"
:url "http://github/weavejester/compojure/tree/refactor"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.0-SNAPSHOT"]
[commons-codec "1.3"]
[commons-io "1.4"]
[commons-fileupload "1.2.1"]
[org.mortbay.jetty/jetty "6.1.21"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]]
:namespaces [compojure
compojure.control
compojure.html
compojure.html.gen
compojure.html.form-helpers
compojure.html.page-helpers
compojure.http
compojure.http.routes
compojure.http.request
compojure.http.response
compojure.http.session
compojure.http.servlet
compojure.http.helpers
compojure.ns-utils
compojure.server.common
compojure.server.jetty
compojure.str-utils
compojure.validation])
[org.clojure/clojure-contrib "1.1.0"]
[clout "0.2.0-SNAPSHOT"]
[ring/ring-core "0.2.0-RC2"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
[ring/ring-jetty-adapter "0.2.0-RC2"]
[hiccup "0.2.1"]])
View
@@ -1,29 +0,0 @@
;; Copyright (c) James Reeves. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.
(ns compojure
"Convenience library that includes every compojure.* namespace. If you want
to access Compojure quickly, and don't care about having everything in one
namespace, just use or require 'compojure."
(:use compojure.ns-utils))
(immigrate
'compojure.control
'compojure.html.gen
'compojure.html.page-helpers
'compojure.html.form-helpers
'compojure.http.helpers
'compojure.http.middleware
'compojure.http.multipart
'compojure.http.routes
'compojure.http.servlet
'compojure.http.session
'compojure.server.jetty
'compojure.str-utils
'compojure.map-utils
'compojure.validation)
View
@@ -1,73 +0,0 @@
;; Copyright (c) James Reeves. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.
(ns compojure.control
"Various macros for controling program flow."
(:use clojure.contrib.seq-utils))
(defmacro return
"A do block that will always return the argument 'x'."
[x & body]
`(let [x# ~x]
(do ~@body x#)))
(defmacro maybe
"Returns (f x & xs) if x is not nil, otherwise returns nil."
[f x & xs]
`(if (not (nil? ~x))
(~f ~x ~@xs)))
(defmacro domap
"Similar to doseq, but collects the results into a sequence."
[[item list] & body]
`(map (fn [~item] ~@body) (doall ~list)))
(defmacro redef
"Redefine an existing value, keeping the metadata intact."
[name value]
`(let [m# (meta #'~name)
v# (def ~name ~value)]
(alter-meta! v# merge m#)
v#))
(defmacro decorate
"Wrap a function in one or more decorators."
[func & decorators]
`(redef ~func (-> ~func ~@decorators)))
(defmacro decorate-with
"Wrap multiple functions in a decorator."
[decorator & funcs]
`(do ~@(for [f funcs]
`(redef ~f (~decorator ~f)))))
(defmacro decorate-bind
"Wrap named functions in a decorator for a bounded scope."
[decorator funcs & body]
`(binding
[~@(mapcat (fn [f] [f (list decorator f)]) funcs)]
~@body))
(defn apply-doc
"Return a symbol and body with an optional docstring applied."
[name doc? body]
(if (string? doc?)
(list* (with-meta name (assoc (meta name) :doc doc?)) body)
(list* name doc? body)))
(defmacro deftmpl
"Define a template function. Arguments are passed via key-value pairs.
e.g. (deftmpl foo [bar baz] (+ bar baz))
(foo :bar 1 :baz 2)"
[name doc? & body]
(let [[name params & body] (apply-doc name doc? body)]
`(defn ~name
~@doc?
[& param-map#]
(let [{:keys ~params} (apply hash-map param-map#)]
~@body))))
Oops, something went wrong.

0 comments on commit 6f21014

Please sign in to comment.