initial iphone/ipad support

This commit is contained in:
Espen Antonsen 2010-07-01 12:14:23 +02:00
parent c854b3d2e9
commit b3b8baf8b5
7 changed files with 94 additions and 7 deletions

View file

@ -9,16 +9,44 @@ class ApplicationController < ActionController::Base
helper_method :current_user, :current_user_session helper_method :current_user, :current_user_session
before_filter :setup before_filter :setup
#before_filter :adjust_format
layout :application_layout
private private
def application_layout
@browser_name ||= begin
if iphone_request?
'application.iphone'
else
'application'
end
end
end
# Set iPhone format if request to iphone.trawlr.com
def adjust_format
request.format = :iphone if iphone_request?
request.format = :ipad if ipad_request?
end
# Return true for requests to iphone.trawlr.com
def iphone_request?
return (request.subdomains.first == "iphone" || request.env['HTTP_USER_AGENT'].downcase.include?('iphone') )
end
# Return true for requests to iphone.trawlr.com
def ipad_request?
return (request.subdomains.first == "iphone" || request.env['HTTP_USER_AGENT'].downcase.include?('ipad') )
end
def setup def setup
redirect_to new_account_path if User.all.length == 0 redirect_to new_account_path if User.all.length == 0
end end
def check_public_access def check_public_access
require_user unless ENV['public'] == 'true' require_user unless ENV['PUBLIC'] == 'true'
end end
def current_user_session def current_user_session

View file

@ -57,7 +57,7 @@ class FileUploader < CarrierWave::Uploader::Base
end end
end end
version :single do version :single do
process :resize_to_fit => [950, 950] process :resize_to_limit => [950, 950]
def store_dir def store_dir
"uploads/thumbs/#{model.album.path}" "uploads/thumbs/#{model.album.path}"
end end

View file

@ -3,7 +3,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= ENV['site_name'] %></title> <title><%= ENV['TITLE'] %></title>
<%= yield :head %> <%= yield :head %>
<%= stylesheet_link_tag 'application' %> <%= stylesheet_link_tag 'application' %>
</head> </head>
@ -11,28 +11,28 @@
<div id="container"> <div id="container">
<div id="header"> <div id="header">
<%= breadcrumbs %>
<div id="action_links"> <div id="action_links">
<%= yield :action_links %> <%= yield :action_links %>
<% if current_user %> <% if current_user %>
Logged in as <%= current_user.name %> Logged in as <%= current_user.name %>
<%= link_to 'Logout', logout_path %> <%= link_to 'Logout', logout_path %>
<% else %>
<%= link_to 'Login', login_path %>
<% end %> <% end %>
</div> </div>
<h1> <h1>
<a href="/">
<% if ENV['LOGO'] %> <% if ENV['LOGO'] %>
<%= image_tag ENV['LOGO'] %> <%= image_tag ENV['LOGO'] %>
<% else %> <% else %>
<%= ENV['TITLE'] %> <%= ENV['TITLE'] %>
<% end %> <% end %>
</a>
</h1> </h1>
<form action="/albums" method="get" id="search"> <form action="/albums" method="get" id="search">
<input type="text" name="q" class="textfie.d"/> <input type="text" name="q" class="textfield"/>
<input type="submit" value="Search" class="button" /> <input type="submit" value="Search" class="button" />
</form> </form>
<hr class="seperator" /> <hr class="seperator" />
<%= breadcrumbs %>
</div> </div>
<div id="content"> <div id="content">

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name = "viewport" content = "width = device-width">
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable=no">
<title><%= ENV['TITLE'] %></title>
<%= yield :head %>
<%= stylesheet_link_tag 'application', 'iphone' %>
</head>
<body>
<div id="container">
<div id="header">
<%= breadcrumbs('/',false) %>
<div id="action_links">
<%= yield :action_links %>
<% if current_user %>
Logged in as <%= current_user.name %>
<%= link_to 'Logout', logout_path %>
<% end %>
</div>
<h1>
<% if ENV['LOGO'] %>
<%= image_tag ENV['LOGO'] %>
<% else %>
<%= ENV['TITLE'] %>
<% end %>
</h1>
<hr class="seperator" />
</div>
<div id="content">
<p id="notice"><%= flash[:notice] %></p>
<%= yield %>
</div>
<div id="footer">
</div>
</div>
<%= javascript_include_tag 'jquery-1.3.2.js', 'jquery.livequery.js', 'balder' %>
<%= yield :javascript %>
</body>
</html>

View file

@ -3,3 +3,6 @@
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf # Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone # Mime::Type.register_alias "text/html", :iphone
Mime::Type.register_alias "text/html", :iphone
Mime::Type.register_alias "text/html", :ipad

View file

@ -89,6 +89,11 @@ div#header h1 {
clear: left; clear: left;
} }
div#header h1 a, div#header h1 a:visited, div#header h1 a:active, div#header h1 a:hover {
text-decoration: none;
color: #222;
}
div#header { div#header {
padding: 10px 0; padding: 10px 0;
} }

View file

@ -0,0 +1,4 @@
#container {
width: 100%;
margin: 0;
}