forked from emezeske/lein-cljsbuild
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding crossover support and examples.
- Loading branch information
Evan Mezeske
committed
Dec 31, 2011
1 parent
4128668
commit 91e8506
Showing
16 changed files
with
369 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
This is an example web application that uses [Ring][1], [Compojure][2], | ||
and [lein-cljsbuild][3]. It demonstrates the use of lein-cljsbuild to | ||
build ClojureScript into JavaScript. It also shows how to share code | ||
between Clojure and ClojureScript, including macros. | ||
|
||
To play around with this example project, you will first need | ||
[Leiningen][4] installed. | ||
|
||
Set up and start the server like this: | ||
|
||
lein deps | ||
lein cljsbuild once | ||
lein ring server | ||
|
||
[1]: https://github.com/mmcgrana/ring | ||
[2]: https://github.com/weavejester/compojure | ||
[3]: https://github.com/emezeske/lein-cljsbuild | ||
[4]: https://github.com/technomancy/leiningen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(defproject cljsbuild-example-advanced "0.0.1" | ||
:description "An advanced example of how to use lein-cljsbuild" | ||
:source-path "src-clj" | ||
:dependencies [[org.clojure/clojure "1.3.0"] | ||
[compojure "0.6.5"] | ||
[hiccup "0.3.7"]] | ||
:dev-dependencies [[emezeske/lein-cljsbuild "0.0.1"] | ||
[lein-ring "0.5.0"]] | ||
:cljsbuild {:source-dir "src-cljs" | ||
:crossovers [{:from-dir "src-clj/example/crossover" | ||
:to-dir "src-cljs/example/crossover"}] | ||
:output-file "resources/public/js/main.js" | ||
:optimizations :whitespace | ||
:pretty-print true} | ||
:ring {:handler example.routes/app}) |
6 changes: 6 additions & 0 deletions
6
example-projects/advanced/src-clj/example/crossover/macros.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
;*CLJSBUILD-MACRO-FILE*; | ||
|
||
(ns example.crossover.macros) | ||
|
||
(defmacro reverse-eval [form] | ||
(reverse form)) |
7 changes: 7 additions & 0 deletions
7
example-projects/advanced/src-clj/example/crossover/shared.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns example.crossover.shared | ||
(:require;*CLJSBUILD-REMOVE*;-macros | ||
[example.crossover.macros :as macros])) | ||
|
||
(defn make-example-text [] | ||
(macros/reverse-eval | ||
("code" "shared " "from the " "Hello " str))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(ns example.routes | ||
(:use compojure.core | ||
example.views | ||
[hiccup.middleware :only (wrap-base-url)]) | ||
(:require [compojure.route :as route] | ||
[compojure.handler :as handler] | ||
[compojure.response :as response])) | ||
|
||
(defroutes main-routes | ||
(GET "/" [] (index-page)) | ||
(route/resources "/") | ||
(route/not-found "Page not found")) | ||
|
||
(def app | ||
(-> (handler/site main-routes) | ||
(wrap-base-url))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(ns example.views | ||
(:require | ||
[example.crossover.shared :as shared]) | ||
(:use | ||
[hiccup core page-helpers])) | ||
|
||
(defn index-page [] | ||
(html5 | ||
[:head | ||
[:title (shared/make-example-text)] | ||
(include-js "/js/main.js")] | ||
[:body | ||
[:h1 (shared/make-example-text)]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(ns example.hello | ||
(:require | ||
[example.crossover.shared :as shared])) | ||
|
||
(js/alert (shared/make-example-text)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This is an example web application that uses [Ring][1], [Compojure][2], | ||
and [lein-cljsbuild][3]. It demonstrates the use of lein-cljsbuild to | ||
build ClojureScript into JavaScript. | ||
|
||
To play around with this example project, you will first need | ||
[Leiningen][4] installed. | ||
|
||
Set up and start the server like this: | ||
|
||
lein deps | ||
lein cljsbuild once | ||
lein ring server | ||
|
||
[1]: https://github.com/mmcgrana/ring | ||
[2]: https://github.com/weavejester/compojure | ||
[3]: https://github.com/emezeske/lein-cljsbuild | ||
[4]: https://github.com/technomancy/leiningen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(defproject cljsbuild-example-simple "0.0.1" | ||
:description "A simple example of how to use lein-cljsbuild" | ||
:source-path "src-clj" | ||
:dependencies [[org.clojure/clojure "1.3.0"] | ||
[compojure "0.6.5"] | ||
[hiccup "0.3.7"]] | ||
:dev-dependencies [[emezeske/lein-cljsbuild "0.0.1"] | ||
[lein-ring "0.5.0"]] | ||
:cljsbuild {:source-dir "src-cljs" | ||
:output-file "resources/public/js/main.js" | ||
:optimizations :whitespace | ||
:pretty-print true} | ||
:ring {:handler example.routes/app}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(ns example.routes | ||
(:use compojure.core | ||
example.views | ||
[hiccup.middleware :only (wrap-base-url)]) | ||
(:require [compojure.route :as route] | ||
[compojure.handler :as handler] | ||
[compojure.response :as response])) | ||
|
||
(defroutes main-routes | ||
(GET "/" [] (index-page)) | ||
(route/resources "/") | ||
(route/not-found "Page not found")) | ||
|
||
(def app | ||
(-> (handler/site main-routes) | ||
(wrap-base-url))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(ns example.views | ||
(:use [hiccup core page-helpers])) | ||
|
||
(defn index-page [] | ||
(html5 | ||
[:head | ||
[:title "Hello World"] | ||
(include-js "/js/main.js")] | ||
[:body | ||
[:h1 "Hello World"]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns example.hello) | ||
|
||
(js/alert "Hello from ClojureScript!") |
Oops, something went wrong.