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
(defproject compojureongae "0.2.0" | |
:description "Example app for deployoing Compojure on Google App Engine" | |
:namespaces [compojureongae.core] | |
:dependencies [[compojure "0.4.0-RC3"] | |
[ring/ring-servlet "0.2.1"] | |
[hiccup "0.2.4"] | |
[appengine "0.2"] | |
[com.google.appengine/appengine-api-1.0-sdk "1.3.4"] | |
[com.google.appengine/appengine-api-labs "1.3.4"]] | |
:dev-dependencies [[swank-clojure "1.2.0"] |
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
(ns local-dev | |
"Tools for local development. | |
Enables the use of the App Engine APIs on the REPL and in a local Jetty instance." | |
(:use ring.adapter.jetty | |
[ring.middleware file file-info]) | |
(:import [java.io File] | |
[java.util HashMap] | |
[com.google.apphosting.api ApiProxy ApiProxy$Environment] | |
[com.google.appengine.tools.development | |
ApiProxyLocalFactory |
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
<security-constraint> | |
<web-resource-collection> | |
<url-pattern>/new</url-pattern> | |
<url-pattern>/post</url-pattern> | |
</web-resource-collection> | |
<auth-constraint> | |
<role-name>admin</role-name> | |
</auth-constraint> | |
</security-constraint> |
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
(defn render-post [post] | |
"Renders a post to HTML." | |
[:div | |
[:h2 (h (:title post))] | |
[:p (h (:body post))]]) | |
(defn get-posts [] | |
"Returns all posts stored in the datastore." | |
(ds/find-all (Query. "post"))) |
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
(defn create-post [title body] | |
"Stores a new post in the datastore and issues an HTTP Redirect to the main page." | |
(ds/create-entity {:kind "post" :title title :body body}) | |
(redirect "/")) |
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
(defroutes example | |
(GET "/" [] (main-page)) | |
(GET "/new" [] (render-page "New Post" new-form)) | |
(POST "/post" [title body] (create-post title body)) | |
(route/not-found "Page not found")) |
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
(ns compojureongae.core | |
(:gen-class :extends javax.servlet.http.HttpServlet) | |
(:use compojure.core | |
[ring.util.servlet :only [defservice]] | |
[ring.util.response :only [redirect]] | |
[hiccup.core :only [h html]] | |
[hiccup.page-helpers :only [doctype include-css link-to xhtml-tag]] | |
[hiccup.form-helpers :only [form-to text-area text-field]]) | |
(:import (com.google.appengine.api.datastore Query)) | |
(:require [compojure.route :as route] |
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
(defproject compojureongae "0.2.0" | |
:description "Example app for deployoing Compojure on Google App Engine" | |
:namespaces [compojureongae.core] | |
:dependencies [[compojure "0.4.0-RC3"] | |
[ring/ring-servlet "0.2.1"] | |
[hiccup "0.2.4"] | |
[appengine "0.2"] | |
[com.google.appengine/appengine-api-1.0-sdk "1.3.4"]] | |
:dev-dependencies [[swank-clojure "1.2.0"]] | |
:compile-path "war/WEB-INF/classes" |
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
body { | |
font: 62.5% "Lucida Sans Unicode", "Lucida Grande", sans-serif; | |
padding: 10px 30px; | |
} | |
ol, ul, p { | |
font-size: 1.2em; | |
line-height: 1.5; | |
} | |
form, fieldset, legend { | |
border: 0; |
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
lein clean && lein deps && lein compile # regular leiningen build | |
lein uberwar # create a war with all dependency (and dev-dependency) jars | |
rm -rf war && mkdir war | |
unzip compojureongae-0.1.0.war -d war # unpack the war | |
rm -r war/WEB-INF/lib/dev # remove the dev-dependencies |