Skip to content

Commit

Permalink
API : Add nextEvent operation
Browse files Browse the repository at this point in the history
  • Loading branch information
chamerling committed May 26, 2011
1 parent 813c742 commit 48f6a57
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/controllers/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public static void listMembers() {
render(members);
}

public static void nextEvent() {
Event event = Event.next();
if (request.format.equals("json")) {
renderJSONExclusion(event);
}
render(event);
}

private static void renderJSONExclusion(Object o) {
throw new RenderJsonExclusion(o);
}
Expand Down
1 change: 0 additions & 1 deletion app/controllers/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ public static void downloadEventAttachment(Long eventId, String attachment) {
notFound();
}
}

}
15 changes: 15 additions & 0 deletions app/views/API/event.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<event>
<title>${event.title}</title>
<date>${event.date}</date>
<location>${event.location}</location>
<description>${event.description}</description>
<registrationURL>${event.registrationURL}</registrationURL>
<capacity>${event.capacity}</capacity>
<open>${event.open}</open>
<map>${event.map}</map>
<talks>
#{list event.talks(), as : "talk"}
#{include 'API/talk.xml' /}
#{/list}
</talks>
</event>
6 changes: 1 addition & 5 deletions app/views/API/listEvents.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<events>
#{list events, as:'event'}
<event>
<title>${event.title}</title>
<date>${event.date}</date>
<description>${event.description}</description>
</event>
#{include 'API/event.xml' /}
#{/list}
</events>
2 changes: 2 additions & 0 deletions app/views/API/nextEvent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='utf-8'?>
#{include 'API/event.xml' /}
21 changes: 21 additions & 0 deletions app/views/API/talk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<talk>
<order>${talk.orderInEvent}</order>
<title>${talk.title}</title>
<time>${talk.time}</time>
<tags>${talk.tags}</tags>
<teaser>${talk.teaser}</teaser>
<speaker>
<fullname>${talk.speaker.fullName}</fullname>
<activity>${talk.speaker.activity?.escapeXml()}</activity>
<company>${talk.speaker.company}</company>
<url>${talk.speaker.url}</url>
<personalUrl>${talk.speaker.personalUrl}</personalUrl>
<description>${talk.speaker.description?.escapeXml()}</description>
#{if (talk.speaker.photoUrl)}
<photoUrl>${talk.speaker.photoUrl}</photoUrl>
#{/if}
#{else}
<photoUrl>${talk.speaker.getGravatar().escapeXml()}</photoUrl>
#{/else}
</speaker>
</talk>
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GET /remove/{eventId}/{filename} Admin.rmEventAttachment
# API stuff
GET /api/events.{<json|xml>format} API.listEvents
GET /api/members.{<json|xml>format} API.listMembers
GET /api/nextevent.{<json|xml>format} API.nextEvent

# Map static resources from the /app/public folder to the /public path
GET /public/ staticDir:public
Expand Down

0 comments on commit 48f6a57

Please sign in to comment.