Skip to content
This repository was archived by the owner on Sep 5, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'http://rubygems.org'

gem 'rails', '3.0.10'
gem 'rails', '3.2.18'

gem 'sqlite3-ruby', :require => 'sqlite3', :group => [:development, :test]
gem "sqlite3", :require => "sqlite3", :group => [:development, :test]
gem "mysql", :require => "mysql", :group => [:production]

# God monitors the auto-updater script.
Expand Down
125 changes: 0 additions & 125 deletions Gemfile.lock

This file was deleted.

16 changes: 14 additions & 2 deletions app/controllers/displays_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
class DisplaysController < ApplicationController

def index
@pages = Page.order("name").frontpage
render :layout => 'full_map'
# Is this coming from an Android WebView?
if request.user_agent.include? "Mobile Safari" or params[:mobile] == "1"
# Redirect outdated applications to Play Store.
if request.headers['X-Requested-With'] == 'com.aktarer.rpishuttle'
render :file => "#{Rails.root}/public/mobile_redirect.html", :status => 403, :layout => false
else
# Placeholder for WebViews.
@pages = Page.order("name").frontpage
render :layout => 'full_map'
end
else
@pages = Page.order("name").frontpage
render :layout => 'full_map'
end
end

# Generate a static KML file, a snapshot of the system.
Expand Down
54 changes: 54 additions & 0 deletions app/views/displays/index_mobile.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<% content_for :js_ready do %>
//Setup the overlays
$("a[rel]").overlay({
top: 150,
onBeforeLoad: function() {
var wrap = this.getOverlay().find(".contentWrap");
wrap.load(this.getTrigger().attr("href"));
}
});
//Map work
var point = {latitude: <%= MAP_CENTER[:lat] %>, longitude: <%= MAP_CENTER[:long] %>};
map = setup_map(point, 15);
$.ajaxSetup({
timeout: <%= AJAX_TIMEOUT %>
});
$('#status').ajaxError(function(e, xhr, settings, exception){
$(this).text("Unable to load data.");
$('#loading_icon').hide();
$('#error_icon').show();
});
$('#status').ajaxStart(function(){
$(this).text("Loading...");
$('#error_icon').hide();
$('#loading_icon').show();
});
$('#status').ajaxSuccess(function(){
$('#loading_icon').hide();
});
updater = setInterval("update()", <%= UPDATE_INTERVAL %>);
routes_and_stops();
update(); //Run the first update instead of waiting.
<% end %>
<% content_for :js do %>
var current_data_path = '<%= current_vehicles_path(:format => 'js') %>';
var netlink_data_path = '<%= displays_netlink_path(:format => 'js') %>';
var base_icon = '<%= rotate_icon_path(:id => ':id', :heading => ':heading', :format => 'png') %>';
var stop_icon_path = '<%= image_path "blue_dot.png" %>';
<% end %>
<div id="mapblock">
<div id="map_canvas"></div>
<div id="nav_container">
<%= link_to "http://webtech.union.rpi.edu" do %>
<%= image_tag 'little_wtg_logo.png', :alt => "Web Tech Group" %>
<% end %>
</div>
</div>
<div id="map_header">
<span id="loading_icon" style="display: none;"><%= image_tag 'full_map/loading.gif' %></span>
<span id="error_icon" style="display: none;"><%= image_tag 'full_map/error.png' %></span>
<span id="status">Loading...</span>
</div>
<div class="simple_overlay" id="overlay">
<div class="contentWrap"></div>
</div>
3 changes: 2 additions & 1 deletion app/views/layouts/full_map.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Track Vehicles Live</title>
<%= include_stylesheets :map %>
<%= include_stylesheets :map, :media => 'screen' %>
<%= include_stylesheets :mobile, :media => 'handheld' %>
<%= include_javascripts :common, :map %>
<%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %>
<%= csrf_meta_tag %>
Expand Down
2 changes: 2 additions & 0 deletions config/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ javascripts:
stylesheets:
map:
- public/stylesheets/new.css
mobile:
- public/stylesheets/mobile.css
backend:
- public/stylesheets/general.css
2 changes: 2 additions & 0 deletions config/initializers/security.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Workaround for CVE-2013-0156.
ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
30 changes: 30 additions & 0 deletions public/mobile_redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Application Upgrade</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>

<body>
<div class="dialog">
<h1>Performing update...</h1>
<p>Please download an updated version from the Google Play Store.</p>
</div>
<script type="text/javascript">
setTimeout(function() {
window.location='https://play.google.com/store/apps/details?id=com.abstractedsheep.shuttletracker';
}, 2000);
</script>
</body>
</html>
104 changes: 104 additions & 0 deletions public/stylesheets/mobile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
body
{
margin:0px;
padding:0px;
height:auto;
}
#mapblock
{
position:absolute;
width:100%;
height:100%;
margin:0px;
padding:0px;
}
#map_canvas
{
position:absolute;
width: 100%;
height: 100%;
}
#nav_container
{
display:block;
position:absolute;
right:0px;
bottom:10px;
}
#nav_container a img
{
border: none;
}
#nav
{
display:block;
background-color:black;
padding-top:1px;
}
#nav a
{
display:block;
width:64px;
height:15px;
background-color:white;
text-align:center;
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
line-height:15px;
border-style:solid;
border-width:1px;
border-color:#707070;
border-top-color:#D0D0D0;
border-left-color:#D0D0D0;
margin:1px;
margin-top:0px;
text-decoration:none;
color:black;
}
#nav a:visited
{
color:black;
}
#nav a:hover
{
border-color:#D0D0D0;
border-top-color:#707070;
border-left-color:#707070;
}

/* the overlayed element */
.simple_overlay {
/* must be initially hidden */
display:none;

/* place overlay on top of other elements */
z-index:10000;

/* styling */
background-color:#FFF;

width:400px;
border:1px solid #666;
padding: 25px;

/* CSS3 styling for latest browsers */
-moz-box-shadow:0 0 90px 5px #000;
-webkit-box-shadow: 0 0 90px #000;
}

/* close button positioned on upper right corner */
.simple_overlay .close {
background-image:url(../images/close.png);
position:absolute;
right:-15px;
top:-15px;
cursor:pointer;
height:35px;
width:35px;
}

/* styling for elements inside overlay */
.contentWrap {
font-family:Arial, Helvetica, sans-serif;
color:#000;
}