diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b266b3d..9106db1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index d9f7028..f4ca3aa 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -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 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 70439fd..ff3862d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,7 +3,7 @@ - <%= ENV['site_name'] %> + <%= ENV['TITLE'] %> <%= yield :head %> <%= stylesheet_link_tag 'application' %> @@ -11,28 +11,28 @@
diff --git a/app/views/layouts/application.iphone.erb b/app/views/layouts/application.iphone.erb new file mode 100644 index 0000000..b737c44 --- /dev/null +++ b/app/views/layouts/application.iphone.erb @@ -0,0 +1,47 @@ + + + + + + + + <%= ENV['TITLE'] %> + <%= yield :head %> + <%= stylesheet_link_tag 'application', 'iphone' %> + + +
+ + + +
+

<%= flash[:notice] %>

+ <%= yield %> +
+ + + +
+ +<%= javascript_include_tag 'jquery-1.3.2.js', 'jquery.livequery.js', 'balder' %> +<%= yield :javascript %> + + diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e..531d59b 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -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 \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 29f7564..2719740 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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; } diff --git a/public/stylesheets/iphone.css b/public/stylesheets/iphone.css new file mode 100644 index 0000000..c5060d4 --- /dev/null +++ b/public/stylesheets/iphone.css @@ -0,0 +1,4 @@ +#container { + width: 100%; + margin: 0; +} \ No newline at end of file