Browse files

First commit.

  • Loading branch information...
0 parents commit 8e59e0d8436d298d82966bd55789f178076edfc1 @maxweber committed Jul 27, 2011
Showing with 101 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +13 −0 README.md
  3. +2 −0 cljs/.gitignore
  4. +18 −0 cljs/hello-dev.html
  5. +13 −0 cljs/hello.html
  6. +8 −0 cljs/src/hello/core.cljs
  7. +4 −0 cljs/src/hello/foo/bar.cljs
  8. +8 −0 project.clj
  9. +28 −0 src/cljs_devmode_example/core.clj
7 .gitignore
@@ -0,0 +1,7 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-failures
+.lein-deps-sum
+cljs-devmode.sh
13 README.md
@@ -0,0 +1,13 @@
+# cljs-devmode-example
+
+This is an example how to use [cljs-devmode](https://github.com/maxweber/cljs-devmode).
+
+## Usage
+
+See the README of [cljs-devmode](https://github.com/maxweber/cljs-devmode).
+
+## License
+
+Copyright (C) 2011 Maximilian Weber
+
+Distributed under the Eclipse Public License, the same as Clojure.
2 cljs/.gitignore
@@ -0,0 +1,2 @@
+out/
+cljs-devmode-example.js
18 cljs/hello-dev.html
@@ -0,0 +1,18 @@
+<html>
+ <head>
+ <title>Hello ClojureScript</title>
+ </head>
+ <body>
+ <h1>Hello ClojureScript!</h1>
+ <!-- In unoptimized mode, additional script tags are required -->
+ <script type="text/javascript" src="out/goog/base.js"></script>
+ <script type="text/javascript" src="cljs-devmode-example.js"></script>
+ <script>
+ goog.require('hello.core');
+ </script>
+ <script>
+ alert(greet("ClojureScript"));
+ alert("The sum of [1,2,3,4,5,6,7,8,9] is: " + hello.core.sum([1,2,3,4,5,6,7,8,9]));
+ </script>
+ </body>
+</html>
13 cljs/hello.html
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Hello ClojureScript</title>
+ </head>
+ <body>
+ <h1>Hello ClojureScript!</h1>
+ <script type="text/javascript" src="cljs-devmode-example.js"></script>
+ <script>
+ alert(greet("ClojureScript"));
+ alert("The sum of [1,2,3,4,5,6,7,8,9] is: " + hello.core.sum([1,2,3,4,5,6,7,8,9]));
+ </script>
+ </body>
+</html>
8 cljs/src/hello/core.cljs
@@ -0,0 +1,8 @@
+(ns hello.core
+ (:require [hello.foo.bar :as bar]))
+
+(defn ^{:export greet} greet [n]
+ (str "Hello " n))
+
+(defn ^:export sum [xs]
+ (bar/sum xs))
4 cljs/src/hello/foo/bar.cljs
@@ -0,0 +1,4 @@
+(ns hello.foo.bar)
+
+(defn sum [xs]
+ (reduce + 0 xs))
8 project.clj
@@ -0,0 +1,8 @@
+(defproject cljs-devmode-example "0.1.0-SNAPSHOT"
+ :description ""
+ :dependencies [[org.clojure/clojure "1.2.1"]
+ [compojure "0.6.5"]
+ [hiccup "0.3.6"]
+ [ring/ring-jetty-adapter "0.3.11"]]
+ :dev-dependencies [[cljs-devmode "0.1.0-SNAPSHOT"]]
+ :main cljs-devmode-example.core)
28 src/cljs_devmode_example/core.clj
@@ -0,0 +1,28 @@
+(ns cljs-devmode-example.core
+ (:use compojure.core
+ hiccup.core
+ hiccup.page-helpers
+ ring.adapter.jetty
+ cljs-devmode.ring-middleware))
+
+(defroutes app
+ (GET "/" []
+ (html [:head
+ [:title "Hello cljs-devmode"]
+ (include-js "cljs/out/goog/base.js")
+ (include-js "cljs/cljs-devmode-example.js")
+ (javascript-tag
+ "goog.require('hello.core');")
+ (javascript-tag
+ "alert(greet(\"ClojureScript\"));
+ alert(\"The sum of [1,2,3,4,5,6,7,8,9] is: \"
+ + hello.core.sum([1,2,3,4,5,6,7,8,9]));")]
+ [:body
+ [:h1 "Hello cljs-devmode!"]])))
+
+(def the-app
+ (-> app
+ (wrap-cljs-forward "/cljs")))
+
+(defn -main []
+ (run-jetty (var the-app) {:port 8080}))

0 comments on commit 8e59e0d

Please sign in to comment.