Skip to content

Instantly share code, notes, and snippets.

View christianberg's full-sized avatar

Christian Berg christianberg

View GitHub Profile
(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"
(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]
(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"))
(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 "/"))
(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")))
<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>
(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
(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"]
diff --git a/src/leiningen/classpath.clj b/src/leiningen/classpath.clj
index 3be7e1f..836740e 100644
--- a/src/leiningen/classpath.clj
+++ b/src/leiningen/classpath.clj
@@ -8,7 +8,9 @@
"Returns a seq of Files for all the jars in the project's library directory."
[project]
(filter #(.endsWith (.getName %) ".jar")
- (file-seq (file (:library-path project)))))
+ (concat
mvn install:install-file -DgroupId=com.google.appengine \
-DartifactId=appengine-api-labs -Dversion=1.3.4 -Dpackaging=jar \
-Dfile=$GAESDK/lib/user/appengine-api-labs-1.3.4.jar