--- a/src/main/resources/templates/gpx.ssp Thu Aug 25 16:57:37 2011 -0400
+++ b/src/main/resources/templates/gpx.ssp Thu Aug 25 17:46:38 2011 -0400
@@ -1,3 +1,4 @@
+<%@ val w:org.w3.virtualtrainer.model.Workout %>
<?xml version="1.0" encoding="UTF-8"?>
<gpx creator="BuddyRunner.com" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
@@ -5,10 +6,10 @@
<time>2011-08-10T06:13:35.711-0400</time> <!-- From the schema: "The creation date of the file." - Optional -->
<extensions>
<activity>http://dbpedia.org/resource/Running</activity>
- <time></time>
- <duration></duration>
- <distance></distance>
- <useragent><useragent>
+ <time>${w.date}</time>
+ <duration>${w.duration}</duration>
+ <distance>${w.distance}</distance>
+ <useragent>${w.distance}<useragent>
</extensions>
</metadata>
@@ -17,14 +18,16 @@
<!-- A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. -->
- <trkpt lat="42.412414" lon="-71.140267">
- <time>2011-08-10T06:13:34.000-0400</time>
- <ele>-31.0</ele>
+#for (e <- w.events if (! e.status.isDefined))
+<% val Some((lon, lat, altO)) = e.c %>
+ <trkpt lat="${lat}" lon="${lon}">
+ <time>e.timestamp</time>
+#if (altO.isDefined)
+ <ele>${altO.get}</ele>
+#end
</trkpt>
- <trkpt lat="42.412457" lon="-71.140305">
- <time>2011-08-10T06:13:37.000-0400</time>
- <ele>-34.0</ele>
- </trkpt>
+#end
+
</trkseg>
</trk>
</gpx>
\ No newline at end of file
--- a/src/main/scala/Main.scala Thu Aug 25 16:57:37 2011 -0400
+++ b/src/main/scala/Main.scala Thu Aug 25 17:46:38 2011 -0400
@@ -61,7 +61,7 @@
val realId = id.replaceAll(".json$", "").replaceAll(".gpx$", "")
WorkoutDAO.findOneByID(realId) match {
case Some(workout) if id endsWith ".gpx" =>
- Ok ~> ResponseString("TO BE IMPLEMENTED")
+ Ok ~> Scalate(req, "gpx.ssp", "w" -> workout)(engine)
case Some(workout) if (id endsWith ".json") || (id == realId) =>
Ok ~> ContentType("application/json") ~> ResponseString(workout.asJSON)
case _ => NotFound
--- a/src/main/scala/Workout.scala Thu Aug 25 16:57:37 2011 -0400
+++ b/src/main/scala/Workout.scala Thu Aug 25 17:46:38 2011 -0400
@@ -37,11 +37,14 @@
activity:String,
date: Long,
distance: Long,
+ duration: Long,
+ @Key("userAgent") useragent: String,
events:Seq[Event]) {
def asJSON:String = {
val formattedEvents = events map { _.asJSON } mkString ("[ ", ", ", " ]")
- """{ "activity": "%s", "date": %d, "distance": %d, "events": %s }""" format (activity, date, distance, formattedEvents)
+ """{ "activity": "%s", "date": %d, "distance": %d, "duration": %s, "userAgent": "%s", "events": %s }""" format
+ (activity, date, distance, duration, useragent, formattedEvents)
}
}
--- a/src/test/scala/WorkoutAPISpec.scala Thu Aug 25 16:57:37 2011 -0400
+++ b/src/test/scala/WorkoutAPISpec.scala Thu Aug 25 17:46:38 2011 -0400
@@ -17,6 +17,8 @@
"activity": "http://dbpedia.org/resource/Running",
"date": 1314049555595,
"distance": 5000,
+ "duration": 1234,
+ "userAgent": "panda-en-feu",
"events":
[
{