Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
james committed Sep 2, 2011
0 parents commit 502c186
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'sinatra'
require 'net/http'
require 'json'
require 'erb'
set :views, File.dirname(__FILE__) + '/templates'

get '/stop/:stop_id' do |stop_id|
response = Net::HTTP.get(URI.parse("http://countdown.tfl.gov.uk/stopBoard/#{stop_id}/"))
@json = JSON.parse(response)
erb :stop
end
40 changes: 40 additions & 0 deletions templates/stop.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Bus stop</title>
<style type="text/css" media="screen">
body {
background-color:#000;
color:#F00;
font-family: monospace;
font-size:30px;
font-weight:bold;
margin:0 auto;
}
table {
width:100%;
}
tr {
width:50%;
}
td.number {
text-align:right;
padding-right:1em;
}
</style>
</head>

<body>
<table>
<% @json["arrivals"].each do |arrival| %>
<tr>
<td class="number"><%= arrival["routeId"] %></td>
<td><%= arrival["estimatedWait"] %></td>
</tr>
<% end %>
</table>
</body>
</html>

0 comments on commit 502c186

Please sign in to comment.