From f2f42293e86198bb2a1c6411819ded5d3d82cd35 Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Tue, 23 Feb 2010 18:56:56 -0500 Subject: [PATCH] Doc and example tweaks. --- LICENSE | 2 +- README.markdown | 14 +++++++------- example/hello_world.clj | 5 ++--- example/linted.clj | 8 ++++---- example/public/clojure.png | Bin 2174 -> 2174 bytes example/wrapping.clj | 2 +- src/ring/middleware/file_info.clj | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index 762aa887..65783ea2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 Mark McGranaghan +Copyright (c) 2009-2010 Mark McGranaghan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.markdown b/README.markdown index fad5da4a..32786587 100644 --- a/README.markdown +++ b/README.markdown @@ -18,12 +18,12 @@ A Ring handler: Adding simple middleware: - (defn with-upcase [app] + (defn wrap-upcase [app] (fn [req] (let [orig-resp (app req)] (assoc orig-resp :body (.toUpperCase (:body orig-resp)))))) - (def upcase-app (with-upcase app)) + (def upcase-app (wrap-upcase app)) (run-jetty upcase-app {:port 8080}) @@ -36,7 +36,7 @@ First, pull in Ring's dependencies using [Leiningen](http://github.com/technoman To see a live "Hello World" Ring app, run: - $ clj src/ring/example/hello_world.clj + $ clj example/hello_world.clj Now visit `http://localhost:8080/` in your browser; the Ring app will respond to your request with a simple HTML page indicating the time of day. @@ -44,7 +44,7 @@ Note that your `clj` script needs to add the `src` directory and the jars in `li To see a more sophisticated Ring app, run: - $ clj src/ring/example/wrapping.clj + $ clj example/wrapping.clj * If you request `http://localhost:8080/` in your browser the `ring.handler.dump` handler will respond with an HTML page representing the request map that it received (see the `SPEC` for details on the request map). * If you request `http://localhost:8080/clojure.png`, the `ring.middleware.file` middleware will detect that there is a `clojure.png` file in the app's `public` directory and return that image as a response. @@ -68,11 +68,11 @@ Included Libs Development ----------- -Ring is being actively developed; you can track its progress and contribute at the project's [GitHub](http://github.com/mmcgrana/ring) page. +Ring is being actively developed; you can track its progress and contribute at the project's [GitHub page](http://github.com/mmcgrana/ring) and [Google Group](http://groups.google.com/group/ring-clojure). To run all the Ring unit tests: - $ clj test/ring/run.clj + $ lein test Thanks ------ @@ -82,6 +82,6 @@ This project borrows heavily from Ruby's Rack and Python's WSGI, and I thank the License ------- -Copyright (c) 2009 Mark McGranaghan and released under an MIT license. +Copyright (c) 2009-2010 Mark McGranaghan and released under an MIT license. Clojure logo by Tom Hickey. \ No newline at end of file diff --git a/example/hello_world.clj b/example/hello_world.clj index afccdd25..e1426e87 100644 --- a/example/hello_world.clj +++ b/example/hello_world.clj @@ -4,14 +4,13 @@ (:use ring.adapter.jetty) (:import java.util.Date java.text.SimpleDateFormat)) -(def formatter (SimpleDateFormat. "HH:mm:ss")); - (defn app [req] {:status 200 :headers {"Content-Type" "text/html"} :body (str "

Hello World from Ring

" "

The current time is " - (.format formatter (Date.)) ".

")}) + (.format (SimpleDateFormat. "HH:mm:ss") (Date.)) + ".

")}) (run-jetty app {:port 8080}) diff --git a/example/linted.clj b/example/linted.clj index 5cf13547..549c5f81 100644 --- a/example/linted.clj +++ b/example/linted.clj @@ -13,9 +13,9 @@ wrap-lint wrap-file-info wrap-lint - (wrap-file "src/ring/example/public") + (wrap-file "example/public") wrap-lint - (wrap-reload '(ring.dump) - wrap-lint))) + (wrap-reload '(ring.handler.dump)) + wrap-lint)) -(run-jetty app {:port 8080}) \ No newline at end of file +(run-jetty app {:port 8080}) diff --git a/example/public/clojure.png b/example/public/clojure.png index 84eee16d95b131330e74e55f834849f27a1bb353..7798882c433eb7eb0c9a71e6a6434e1870a34f6a 100644 GIT binary patch delta 75 zcmew-@K0dFEha{;$+wyM*tsNZjG8OBCKoU-0g8ySJOPrwSndGH>#TPfxi)WQlVAjL a&apcJNdb-|9xlC#TPfc{gumlVAjL a&apcJNdb-|9$vkaN8a~;sVNCCSOWmb3K$;% diff --git a/example/wrapping.clj b/example/wrapping.clj index fe942d89..a6a6f607 100644 --- a/example/wrapping.clj +++ b/example/wrapping.clj @@ -15,7 +15,7 @@ (def app (-> handle-dump wrap-error - (wrap-file "src/ring/example/public") + (wrap-file "example/public") wrap-file-info wrap-stacktrace)) diff --git a/src/ring/middleware/file_info.clj b/src/ring/middleware/file_info.clj index 9929a313..032242c7 100644 --- a/src/ring/middleware/file_info.clj +++ b/src/ring/middleware/file_info.clj @@ -60,7 +60,7 @@ (defn- get-extension "Returns the file extension of a file." - [file] + [#^File file] (second (re-find #"\.([^./\\]+)$" (.getPath file)))) (defn- guess-mime-type