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
;Read the blog post on this gist here http://www.digitalbricklayers.com/2012/03/geotasklist-in-jquery-mobile-and.htm | |
(defproject GeoTaskList "1.0.0-SNAPSHOT" | |
:description "Geolocated Tasklist mobile application" | |
:dependencies [[org.clojure/clojure "1.3.0"] [cheshire "2.2.0"] [compojure "1.0.1"]] | |
:dev-dependencies [[appengine-magic "0.4.7"]]) |
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
;Follow the blog posts for this code here: http://www.digitalbricklayers.com/2012/03/geotasklist-part-2.html | |
(ns GeoTaskList.persistence | |
(:require [appengine-magic.services.datastore :as ds])) | |
(ds/defentity Location [^:key locationId, ^:clj location]) | |
;Save a location. -1 is used to signify no id passed in and nil | |
;should be substitued | |
(defn save-location [location-map] |
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
;Read the blog post on this gist here http://www.digitalbricklayers.com/2012/03/geotasklist-in-jquery-mobile-and.htm | |
(ns GeoTaskList.core | |
(:require [appengine-magic.core :as ae] | |
[compojure.route :as route]) | |
(:use [compojure.core] | |
[cheshire.core :as json] | |
[ring.util.response :as ring-response])) | |
(defn json-response [data & [status]] | |
{:status (or status 200) |
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
<!-- Read the blog post on this gist here http://www.digitalbricklayers.com/2012/03/geotasklist-in-jquery-mobile-and.html --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>GeoTaskList</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width,initial-scale=1" /> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" /> | |
<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry" type="text/javascript"></script> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> |
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
{"locations":[{"lng":115.931422,"name":"Hardware","lat":-31.957242},{"lng":115.935241,"name":"Mall","lat":-31.964779}]} |
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
;Follow the blog posts for this code here: http://www.digitalbricklayers.com/2012/03/geotasklist-part-2.html | |
(ns GeoTaskList.core | |
(:require [appengine-magic.core :as ae] | |
[compojure.route :as route]) | |
(:use [compojure.core] | |
[cheshire.core :as json] | |
[ring.util.response :as ring-response] | |
[compojure.handler :as comp-handler] | |
[GeoTaskList.persistence :as persist])) |
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
<!-- Follow the blog posts for this code here: http://www.digitalbricklayers.com/2012/03/geotasklist-part-2.html --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>GeoTaskList</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width,initial-scale=1" /> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" /> | |
<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry" type="text/javascript"></script> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> |
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
(ds/defentity Location [^:key locationId, ^:clj location]) |
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
;Gets a map of locations keyed by the locationId value | |
(defn get-all-locations-map [] | |
(let [loaded-locations | |
(get-all-locations)] | |
(zipmap (map (fn [k] (:locationId k)) loaded-locations) loaded-locations))) | |
(defn save-task [task-map] | |
(let [input-id (Integer/parseInt (:taskId task-map)) |
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
(GET "/tasks" [] | |
(json-response {:tasks (get-all-tasks)})) | |
(POST "/task" {params :params} | |
(json-response {:taskId (persist/save-task params)})) |
OlderNewer