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
+52
View File
@@ -0,0 +1,52 @@
class MobileController < ApplicationController
layout 'mobile'
def index
date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page(params[:page_main]).per(15)
@ad_banner = AdBanner.where(title: "Banner")[0]
end
def announcement
@page_title = t('mobile.bulletin')
date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page(params[:page_main]).per(15)
end
def announcement_content
@bulletin = Bulletin.find(params[:id]) rescue nil
@page_title = @bulletin.title
end
def dialog_contact
@no_menu = @no_footer = true
@page_title = t('mobile.contact')
end
def dialog_copyright
@no_menu = @no_footer = true
@page_title = t('mobile.copyright')
end
def dialog_language
@no_menu = @no_footer = true
@page_title = t('mobile.language')
end
def map
@no_menu = @no_footer = true
@page_title = t('mobile.location')
end
def page
@page_title = t('mobile.page')
@page_contexts = PageContext.where(:archived => false).page(params[:page_main]).per(15)
end
def page_content
@page_context = PageContext.first(conditions: { id: params[:id], :archived => false }) rescue nil
@page_title = @page_context.page.title
end
end