Skip to content
Browse files

added automatic and manual mobile switching

  • Loading branch information...
1 parent 7bb6f04 commit c4d8aeead1e499450a37ad53b2f5e08957b5b575 @bobop committed Dec 3, 2011
View
18 app/controllers/application_controller.rb
@@ -1,3 +1,21 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ before_filter :prepare_for_mobile
+
+private
+
+ def mobile_device?
+ if session[:mobile_param]
+ session[:mobile_param] == "1"
+ else
+ request.user_agent =~ /Mobile|webOS/
+ end
+ end
+ helper_method :mobile_device?
+
+ def prepare_for_mobile
+ session[:mobile_param] = params[:mobile] if params[:mobile]
+ request.format = :mobile if mobile_device?
+ end
end
View
2 app/views/layouts/application.html.erb
@@ -11,7 +11,7 @@
<h1><%= link_to "Greater Manchester Bus Times", root_path %></h1>
<p class="description">Making Greater Manchester's Bus Times more Accessible</p>
-<%= yield %>
+ <%= yield %>
<div id="footer">
<p>
View
13 app/views/layouts/application.mobile.erb
@@ -12,22 +12,17 @@
</head>
<body<%= yield :body_tag %>>
<div data-role="page">
- <div data-role="header">
+ <div data-role="header" data-theme="b">
<a href="/" data-icon="home">Home</a>
<h1>Greater Manchester Bus Times</h1>
</div>
<div data-role="content">
- <%= yield %>
+ <%= yield %>
</div>
- <div data-role="footer">
- <div id="footer">
- <p>Built by <%= link_to "Bobop", "http://bobop.co.uk" %><br />
- Open Data from <%= link_to "TfGM", "http://www.tfgm.com" %><br />
- Linked Data from <%= link_to "Swirrl", "http://www.swirrl.com" %><br />
- Inspired by Open Data Manchester</p>
- </div>
+ <div data-role="footer" data-theme="b">
+ <h4>Built by <%= link_to "Bobop", "http://bobop.co.uk", "data-role" => "button" %></h4>
</div>
</div>
View
2 app/views/pages/home.html.erb
@@ -1,5 +1,5 @@
<div id="content">
- <p class="description">Making Greater Manchester's Bus Times more Accessible</p>
+ <p><%= link_to "Mobile Site", :mobile => 1 %></p>
<div id="info" class="form">
<%= form_tag('/route', :method => :get) do -%>
<%= label_tag 'route', "Route" %>
View
2 app/views/pages/home.mobile.erb
@@ -1,5 +1,5 @@
<div id="content">
-
+ <p class="description">Making Greater Manchester's Bus Times more Accessible</p>
<div data-role="fieldcontain">
<%= form_tag('/route', :method => :get) do -%>
<input type="search", name='route', id="route", placeholder="Search for a Route number">

0 comments on commit c4d8aee

Please sign in to comment.
Something went wrong with that request. Please try again.