Add mobile but remove news in it

This commit is contained in:
chris committed 2013-01-07 03:03:38 +08:00
1 parent 9745bcf7f1
commit 37740adb24
66 files changed
+6946 -2

No files matched your search

+18 -1
View File
@@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
layout :layout_by_resource
helper :admin
before_filter :set_locale, :set_site
before_filter :set_locale, :set_site, :prepare_for_mobile
helper_attr :site_valid_locales
@@ -130,6 +130,7 @@ class ApplicationController < ActionController::Base
respond_to do |format|
format.html { render :text => parse_page_content(@item), :layout => 'page_layout' }
format.rss { render_main_rss }
format.mobile { redirect_to mobile_path }
end
else
render :text => '404 Not Found'
@@ -237,4 +238,20 @@ class ApplicationController < ActionController::Base
redirect_to ret
end
private
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /iPhone|iPod|Android/
end
end
def prepare_for_mobile
session[:mobile_param] = params[:mobile] if params[:mobile]
request.format = :mobile if mobile_device?
end
end