initial iphone/ipad support
This commit is contained in:
parent
24e5a8c516
commit
bf8d3a0f89
|
@ -9,16 +9,44 @@ class ApplicationController < ActionController::Base
|
|||
helper_method :current_user, :current_user_session
|
||||
|
||||
before_filter :setup
|
||||
#before_filter :adjust_format
|
||||
layout :application_layout
|
||||
|
||||
|
||||
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
|
||||
redirect_to new_account_path if User.all.length == 0
|
||||
end
|
||||
|
||||
def check_public_access
|
||||
require_user unless ENV['public'] == 'true'
|
||||
require_user unless ENV['PUBLIC'] == 'true'
|
||||
end
|
||||
|
||||
def current_user_session
|
||||
|
|
|
@ -57,7 +57,7 @@ class FileUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
end
|
||||
version :single do
|
||||
process :resize_to_fit => [950, 950]
|
||||
process :resize_to_limit => [950, 950]
|
||||
def store_dir
|
||||
"uploads/thumbs/#{model.album.path}"
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title><%= ENV['site_name'] %></title>
|
||||
<title><%= ENV['TITLE'] %></title>
|
||||
<%= yield :head %>
|
||||
<%= stylesheet_link_tag 'application' %>
|
||||
</head>
|
||||
|
@ -11,28 +11,28 @@
|
|||
<div id="container">
|
||||
|
||||
<div id="header">
|
||||
<%= breadcrumbs %>
|
||||
<div id="action_links">
|
||||
<%= yield :action_links %>
|
||||
<% if current_user %>
|
||||
Logged in as <%= current_user.name %>
|
||||
<%= link_to 'Logout', logout_path %>
|
||||
<% else %>
|
||||
<%= link_to 'Login', login_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
<h1>
|
||||
<a href="/">
|
||||
<% if ENV['LOGO'] %>
|
||||
<%= image_tag ENV['LOGO'] %>
|
||||
<% else %>
|
||||
<%= ENV['TITLE'] %>
|
||||
<% end %>
|
||||
</a>
|
||||
</h1>
|
||||
<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" />
|
||||
</form>
|
||||
<hr class="seperator" />
|
||||
<%= breadcrumbs %>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
|
47
app/views/layouts/application.iphone.erb
Normal file
47
app/views/layouts/application.iphone.erb
Normal 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>
|
|
@ -3,3 +3,6 @@
|
|||
# Add new mime types for use in respond_to blocks:
|
||||
# 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", :ipad
|
|
@ -89,6 +89,11 @@ div#header h1 {
|
|||
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 {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
|
4
public/stylesheets/iphone.css
Normal file
4
public/stylesheets/iphone.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
#container {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
Loading…
Reference in a new issue