Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 972db848a9245a0c3b965b05c54330fce155c193 @mbknor committed Jun 7, 2011
@@ -0,0 +1,3 @@
+.idea
+*.iml
+tmp
@@ -0,0 +1,80 @@
+package controllers;
+
+import com.mchange.v2.c3p0.ComboPooledDataSource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import play.Logger;
+import play.libs.WS;
+import play.libs.XPath;
+import play.mvc.*;
+
+
+import models.*;
+import sun.security.krb5.internal.Ticket;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class Application extends Controller {
+
+ public static void index() {
+ render();
+ }
+
+ public static void getit() {
+
+ List<Ticket> tickets = new ArrayList<Ticket>();
+ int page = 1;
+
+ while ( true ) {
+ Document doc = WS.url("http://play.lighthouseapp.com/projects/57987-play-framework/tickets.xml?q=state:open&page="+page).get().getXml();
+
+
+ List<Node> nodes = XPath.selectNodes("/tickets/ticket", doc);
+ if (nodes.size()==0) {
+ break;
+ }
+ for ( Node ticket : nodes) {
+ Ticket t = new Ticket();
+ t.number = Integer.parseInt( XPath.selectText("number", ticket) );
+ t.version = Integer.parseInt( XPath.selectText("version", ticket) );
+ t.title = XPath.selectText("title", ticket);
+
+ tickets.add( t);
+ }
+
+ page++;
+ }
+
+
+ Collections.sort( tickets);
+
+ render(tickets);
+ }
+
+ public static class Ticket implements Comparable{
+ public int number;
+ public int version;
+ public String title;
+
+ public int compareTo(Object _o) {
+ Ticket o = (Ticket)_o;
+ if (version>o.version) {
+ return -1;
+ }
+ if (version<o.version) {
+ return 1;
+ }
+
+ if (number>o.number) {
+ return 1;
+ }
+ if (number<o.number) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+
+}
@@ -0,0 +1,13 @@
+#{extends 'main.html' /}
+#{set title:'Home' /}
+
+<div>
+ <div>
+ Number of open tickets: ${tickets.size}
+ </div>
+ <ul>
+ #{list tickets, as: 't'}
+ <li><a href="http://play.lighthouseapp.com/projects/57987/tickets/${t.number}" target="right">#${t.number}</a><br>${t.title} (version:${t.version})</li>
+ #{/list}
+ </ul>
+</div>
@@ -0,0 +1,4 @@
+<frameset border="1" cols="25%,*">
+ <frame name="left" src="@{Application.getit}">
+ <frame name="right">
+</frameset>
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>Not found</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>
+ </head>
+ <body>
+ #{if play.mode.name() == 'DEV'}
+ #{404 result /}
+ #{/if}
+ #{else}
+ <h1>Not found</h1>
+ <p>
+ ${result.message}
+ </p>
+ #{/else}
+ </body>
+</html>
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>Application error</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>
+ </head>
+ <body>
+ #{if play.mode.name() == 'DEV'}
+ #{500 exception /}
+ #{/if}
+ #{else}
+ <h1>Oops, an error occured</h1>
+ #{if exception instanceof play.exceptions.PlayException}
+ <p>
+ This exception has been logged with id <strong>${exception.id}</strong>.
+ </p>
+ #{/if}
+ #{/else}
+ </body>
+</html>
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>#{get 'title' /}</title>
+ <meta charset="${_response_encoding}">
+ <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/main.css'}">
+ #{get 'moreStyles' /}
+ <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">
+ <script src="@{'/public/javascripts/jquery-1.6.min.js'}" type="text/javascript" charset="${_response_encoding}"></script>
+ #{get 'moreScripts' /}
+ </head>
+ <body>
+ #{doLayout /}
+ </body>
+</html>
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+This file provides limited functionalities for system without Python.
+If Python is available, the play command is recommended over this build file.
+
+Usage:
+Example 1:
+ export PLAY_PATH=/home/user/play
+ ant run
+Sets play path to the environment variable PLAY_PATH and then runs play with target run.
+
+Example 2:
+ ant run -Dplay.path=/home/user/play
+Gives the play path to the ant as command line property.
+
+Example 3:
+ build.xml:
+ ...
+ <property name="play.path" value="/home/user/play"/>
+ ...
+
+ ant run
+Sets the play path to the build.xml directly.
+-->
+<project basedir=".">
+
+ <property environment="env"/>
+ <property name="play.path" value="${env.PLAY_PATH}"/>
+ <import file="${play.path}/resources/application-build.xml"/>
+
+</project>
Oops, something went wrong.

0 comments on commit 972db84

Please sign in to comment.