diff --git a/Gemfile b/Gemfile index 9b98a6d..d60cb81 100644 --- a/Gemfile +++ b/Gemfile @@ -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. diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 381fc65..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,125 +0,0 @@ -GIT - remote: git://github.com/bamnet/devise_cas_authenticatable.git - revision: d08f41d3cb2f903aa3a4ad01f97997ecc424441b - specs: - devise_cas_authenticatable (1.0.0.alpha4) - devise (>= 1.0.6) - rubycas-client (~> 2.1.0) - -GEM - remote: http://rubygems.org/ - specs: - POpen4 (0.1.4) - Platform (>= 0.4.0) - open4 - Platform (0.4.0) - RedCloth (4.2.8) - abstract (1.0.0) - actionmailer (3.0.10) - actionpack (= 3.0.10) - mail (~> 2.2.19) - actionpack (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.10) - activesupport (= 3.0.10) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) - activeresource (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - activesupport (3.0.10) - arel (2.0.10) - bcrypt-ruby (2.1.4) - builder (2.1.2) - cancan (1.6.5) - chronic_duration (0.9.6) - numerizer (~> 0.1.1) - devise (1.4.2) - bcrypt-ruby (~> 2.1.2) - orm_adapter (~> 0.0.3) - warden (~> 1.0.3) - erubis (2.6.6) - abstract (>= 1.0.0) - god (0.11.0) - i18n (0.5.0) - jammit (0.6.3) - yui-compressor (>= 0.9.3) - kaminari (0.12.4) - activesupport (>= 2.3.6) - i18n (>= 0.4.0) - mime-types (~> 1.16) - rails (>= 3.0.0) - treetop (~> 1.4.8) - mail (2.2.19) - mime-types (1.16) - mysql (2.8.1) - numerizer (0.1.1) - open4 (1.1.0) - orm_adapter (0.0.5) - polyglot (0.3.2) - rack (1.2.3) - rack-mount (0.6.14) - rack (>= 1.0.0) - rack-test (0.5.7) - rack (>= 1.0) - rails (3.0.10) - actionmailer (= 3.0.10) - actionpack (= 3.0.10) - activerecord (= 3.0.10) - activeresource (= 3.0.10) - activesupport (= 3.0.10) - bundler (~> 1.0) - railties (= 3.0.10) - railties (3.0.10) - actionpack (= 3.0.10) - activesupport (= 3.0.10) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (~> 0.14.4) - rake (0.9.2) - rdoc (3.9.4) - rmagick (2.12.2) - rubycas-client (2.1.0) - activesupport - sqlite3 (1.3.4) - sqlite3-ruby (1.3.3) - sqlite3 (>= 1.3.3) - thor (0.14.6) - treetop (1.4.10) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.29) - warden (1.0.5) - rack (>= 1.0) - yui-compressor (0.9.6) - POpen4 (>= 0.1.4) - -PLATFORMS - ruby - -DEPENDENCIES - RedCloth - cancan - chronic_duration - devise - devise_cas_authenticatable! - god - jammit - kaminari - mysql - rails (= 3.0.10) - rmagick (= 2.12.2) - sqlite3-ruby diff --git a/app/controllers/displays_controller.rb b/app/controllers/displays_controller.rb index ba4c049..6cc43e6 100644 --- a/app/controllers/displays_controller.rb +++ b/app/controllers/displays_controller.rb @@ -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. diff --git a/app/views/displays/index_mobile.html.erb b/app/views/displays/index_mobile.html.erb new file mode 100755 index 0000000..4f15749 --- /dev/null +++ b/app/views/displays/index_mobile.html.erb @@ -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 %> +
+
+ +
+
+ + + Loading... +
+
+
+
diff --git a/app/views/layouts/full_map.html.erb b/app/views/layouts/full_map.html.erb index 9cd8872..84b84ba 100644 --- a/app/views/layouts/full_map.html.erb +++ b/app/views/layouts/full_map.html.erb @@ -3,7 +3,8 @@ Track Vehicles Live - <%= 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 %> diff --git a/config/assets.yml b/config/assets.yml index 690d2c3..740cac3 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -16,5 +16,7 @@ javascripts: stylesheets: map: - public/stylesheets/new.css + mobile: + - public/stylesheets/mobile.css backend: - public/stylesheets/general.css diff --git a/config/initializers/security.rb b/config/initializers/security.rb new file mode 100644 index 0000000..85e74cb --- /dev/null +++ b/config/initializers/security.rb @@ -0,0 +1,2 @@ +# Workaround for CVE-2013-0156. +ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML) \ No newline at end of file diff --git a/public/mobile_redirect.html b/public/mobile_redirect.html new file mode 100644 index 0000000..0a3841a --- /dev/null +++ b/public/mobile_redirect.html @@ -0,0 +1,30 @@ + + + + Application Upgrade + + + + +
+

Performing update...

+

Please download an updated version from the Google Play Store.

+
+ + + diff --git a/public/stylesheets/mobile.css b/public/stylesheets/mobile.css new file mode 100644 index 0000000..96a8549 --- /dev/null +++ b/public/stylesheets/mobile.css @@ -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; +}