Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
New mobile interface with full functionality.
Browse files Browse the repository at this point in the history
This is not a stripped down version like the jQTouch-based
interface. Content simply resizes and reflows a bit and the styling is
not compromised as a result.

Awesome.
  • Loading branch information
seven1m committed Nov 19, 2010
1 parent 0287f09 commit 607c345
Show file tree
Hide file tree
Showing 33 changed files with 136 additions and 804 deletions.
19 changes: 0 additions & 19 deletions app/controllers/application_controller.rb
Expand Up @@ -8,11 +8,6 @@ class ApplicationController < ActionController::Base
before_filter :get_site
before_filter :feature_enabled?
before_filter :authenticate_user
before_filter :detect_mobile

def iphone?
session[:iphone] or (request.env["HTTP_USER_AGENT"] and request.env["HTTP_USER_AGENT"] =~ /Mobile\/.+Safari/ and session[:iphone].nil?)
end

def params_without_action
params.clone.delete_if { |k, v| %w(controller action).include? k }
Expand Down Expand Up @@ -172,20 +167,6 @@ def decrypt_password(pass)
end
end

def detect_mobile
session[:iphone] = params[:iphone] == 'true' if params[:iphone]
if iphone?
request.format = :iphone
if params[:iphoneAjax]
self.class.layout 'iphone_bare.html'
else
self.class.layout 'iphone.html'
end
else
self.class.layout 'default'
end
end

def check_full_access
if @logged_in and !@logged_in.full_access?
unless LIMITED_ACCESS_AVAILABLE_ACTIONS.include?("#{params[:controller]}/#{params[:action]}") or \
Expand Down
1 change: 0 additions & 1 deletion app/controllers/news_controller.rb
Expand Up @@ -36,7 +36,6 @@ def show
@news_item = NewsItem.find(params[:id])
respond_to do |format|
format.html
format.iphone
end
else
respond_to do |format|
Expand Down
1 change: 0 additions & 1 deletion app/controllers/people_controller.rb
Expand Up @@ -48,7 +48,6 @@ def show
else
respond_to do |format|
format.html
format.iphone
format.xml { render :xml => @person.to_xml } if can_export?
end
end
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/searches_controller.rb
Expand Up @@ -36,13 +36,6 @@ def create
render :action => 'create'
end
end
wants.iphone do
if params[:iphoneAjax] # 'load more' link
render :partial => 'result_items_iphone'
else
render :action => 'results'
end
end
wants.js do
if params[:auto_complete]
@people = @people[0..MAX_SELECT_PEOPLE]
Expand Down
1 change: 0 additions & 1 deletion app/controllers/streams_controller.rb
Expand Up @@ -14,7 +14,6 @@ def show
@album_names = @person.albums.all(:select => 'name').map { |a| a.name }
respond_to do |format|
format.html
format.iphone
format.xml { render :layout => false }
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/styles_controller.rb
Expand Up @@ -8,6 +8,8 @@ class StylesController < ApplicationController
def show
if params[:browser] == 'ie'
path = 'public/stylesheets/style.ie.scss'
elsif params[:browser] == 'mobile'
path = 'public/stylesheets/style.mobile.scss'
else
path = 'public/stylesheets/style.scss'
end
Expand Down
32 changes: 14 additions & 18 deletions app/helpers/application_helper.rb
Expand Up @@ -13,14 +13,20 @@ def banner_message

def head_tags
(
'<meta http-equiv="content-type" content="text/html; charset=utf-8" />' + \
'<meta http-equiv="content-type" content="text/html; charset=utf-8"/>' + \
'<meta http-equiv="Pragma" content="no-cache"/>' + \
'<meta http-equiv="no-cache"/>' + \
'<meta http-equiv="Expires" content="-1"/>' + \
'<meta http-equiv="Cache-Control" content="no-cache"/>'
'<meta http-equiv="Cache-Control" content="no-cache"/>' + \
(mobile? ? '<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>' : '')
).html_safe
end

def mobile?
session[:mobile] = params[:mobile] == 'true' if params[:mobile]
session[:mobile] or (request.env["HTTP_USER_AGENT"].to_s =~ /mobile/i and session[:mobile].nil?)
end

STYLESHEET_MTIMES = {}

def cached_mtime_for_path(path)
Expand All @@ -31,13 +37,16 @@ def cached_mtime_for_path(path)
end
end

def stylesheet_path(ie=false)
def stylesheet_path(browser=nil)
theme_colors = Setting.get(:appearance, :theme_primary_color).to_s + \
Setting.get(:appearance, :theme_secondary_color).to_s + \
Setting.get(:appearance, :theme_top_color).to_s
if ie
if browser == :ie
path = 'public/stylesheets/style.ie.scss'
browser_style_path(:browser => :ie) + '?' + cached_mtime_for_path(path) + theme_colors
elsif browser == :mobile
path = 'public/stylesheets/style.mobile.scss'
browser_style_path(:browser => :mobile) + '?' + cached_mtime_for_path(path) + theme_colors
else
path = 'public/stylesheets/style.scss'
style_path + '?' + cached_mtime_for_path(path) + theme_colors
Expand All @@ -46,6 +55,7 @@ def stylesheet_path(ie=false)

def stylesheet_tags
stylesheet_link_tag(stylesheet_path) + "\n" + \
(mobile? ? (stylesheet_link_tag(stylesheet_path(:mobile)) + "\n") : '') + \
"<!--[if lte IE 8]>\n".html_safe + \
stylesheet_link_tag(stylesheet_path(:ie)) + "\n" + \
"<![endif]-->".html_safe
Expand Down Expand Up @@ -264,20 +274,6 @@ def sortable_column_heading(label, sort, keep_params=[])
link_to label, url
end

def iphone_back_button(url=nil, label='Back')
if url
"<a class=\"button backButton\" rel=\"external\" href=\"#{url}\">#{label}</a>"
elsif params[:iphoneAjax]
"<a class=\"back\" href=\"#home\">#{label}</a>"
else
"<a class=\"button backButton\" rel=\"external\" href=\"/stream\">#{label}</a>"
end
end

def iphone?
controller.iphone?
end

def params_without_action
controller.params_without_action
end
Expand Down
29 changes: 0 additions & 29 deletions app/views/comments/_comments_iphone.erb

This file was deleted.

21 changes: 0 additions & 21 deletions app/views/friends/index.iphone.erb

This file was deleted.

21 changes: 0 additions & 21 deletions app/views/groupies/index.iphone.erb

This file was deleted.

39 changes: 0 additions & 39 deletions app/views/groups/show.iphone.erb

This file was deleted.

31 changes: 0 additions & 31 deletions app/views/layouts/iphone.html.erb

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/layouts/iphone_bare.html.erb

This file was deleted.

91 changes: 0 additions & 91 deletions app/views/messages/show.iphone.erb

This file was deleted.

0 comments on commit 607c345

Please sign in to comment.