{{body}}
+diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6e686d0..8bb40e2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :null_session
- before_action :set_locale
+ before_action :set_locale, :set_mobile_web
helper_method :current_site, :current_user
def default_url_options(options={})
@@ -49,6 +49,32 @@ class ApplicationController < ActionController::Base
current_user.nil? and !current_site.frontend_open
end
+ def set_mobile_web
+ path = request.path.split('/')
+ is_mobile_path = ( (path[1].eql?("mobile") or path[2].eql?("mobile")) or params[:mobile].eql?("1") )
+
+ if params[:mobile].eql?("0")
+ session[:desktop] = true
+ session[:mobile] = false
+ $mobile= ""
+ redirect_to root_path if is_mobile_path
+ else
+ is_mobile_device = ( (request.user_agent =~ /iPhone|iPod|Android/) and !session[:desktop])
+ $mobile = session[:mobile] ? "/mobile" : ""
+
+ if current_site.mobile_on
+ if is_mobile_path or is_mobile_device
+ session[:desktop] = false
+ session[:mobile] = true
+ $mobile = "/mobile"
+ end
+ else
+ session[:mobile] = false
+ redirect_to root_path if is_mobile_path
+ end
+ end
+ end
+
def log_user_action
unless (request.filtered_parameters['action'].eql? "system_info") and (request.filtered_parameters['controller'].eql? "admin/sites")
log = UserAction.new
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 71a639f..c1a0070 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -30,12 +30,12 @@ class PagesController < ApplicationController
impressionist(page)
OrbitHelper.set_params params
OrbitHelper.set_site_locale locale
- render :html => render_final_page("home",page,true).html_safe
+ render :html => render_final_page("home#{$mobile}",page,true).html_safe
end
def show
- path = request.original_fullpath.split('/')
- if path.size <= 2
+ path = request.path.split('/')
+ if path.size <= 2 or path.last.eql?("mobile")
redirect_to root_path
else
if path.last.include? '-'
@@ -174,32 +174,35 @@ class PagesController < ApplicationController
parts = page.page_parts rescue []
@part_partials = {}
- parts.each do |part|
- subparts = part.sub_parts
- partials = []
- subparts.each do |subpart|
- if subpart.kind == "module_widget"
- OrbitHelper.set_widget_data_count subpart.data_count
- OrbitHelper.set_widget_categories subpart.categories
- OrbitHelper.set_widget_module_app subpart.module
- OrbitHelper.set_widget_item_url subpart
- custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
- if !custom_value.nil?
- OrbitHelper.set_widget_custom_value custom_value
- end
- partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type)
- elsif subpart.kind == "text"
- partials << subpart.content
+ if $mobile.blank?
+ parts.each do |part|
+ subparts = part.sub_parts
+ partials = []
+ subparts.each do |subpart|
+ if subpart.kind == "module_widget"
+ OrbitHelper.set_widget_data_count subpart.data_count
+ OrbitHelper.set_widget_categories subpart.categories
+ OrbitHelper.set_widget_module_app subpart.module
+ OrbitHelper.set_widget_item_url subpart
+ custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
+ if !custom_value.nil?
+ OrbitHelper.set_widget_custom_value custom_value
+ end
+ partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type)
+ elsif subpart.kind == "text"
+ partials << subpart.content
+ end
end
+ @part_partials["data-pp='#{part.part_id}'"] = partials
end
- @part_partials["data-pp='#{part.part_id}'"] = partials
end
+
@file = nil
@layout_html = nil
- if original_view == "home"
- @file = File.join('../templates', "#{@key}", '/home/index.html.erb')
+ if original_view == "home#{$mobile}"
+ @file = File.join('../templates', "#{@key}", "/home#{$mobile}/index.html.erb")
else
- @file = File.join('../templates', "#{@key}", '/home/page.html.erb')
+ @file = File.join('../templates', "#{@key}", "/home#{$mobile}/page.html.erb")
end
@layout_html = render_to_string(@file)
doc = Nokogiri::HTML(@layout_html, nil, "UTF-8")
@@ -214,7 +217,7 @@ class PagesController < ApplicationController
pp.inner_html = html_string
end
- if original_view != "home"
+ if original_view != "home#{$mobile}"
viewarea = doc.css("*[data-content='true']")[0]
viewarea.inner_html = render_to_string(original_view)
end
@@ -234,10 +237,10 @@ class PagesController < ApplicationController
def get_view
page = Page.find(params[:id]) rescue Page.root
if page == Page.root
- @view = File.join(Rails.root, 'app', 'templates', "#{@key}", 'home/index.html.erb')
+ @view = File.join(Rails.root, 'app', 'templates', "#{@key}", 'home#{$mobile}/index.html.erb')
else
module_name = page.module.downcase.singularize
- @view = File.join(Rails.root, 'app', 'templates', "#{@key}", "modules/#{module_name}/index.html.erb")
+ @view = File.join(Rails.root, 'app', 'templates', "#{@key}", "modules#{$mobile}/#{module_name}/index.html.erb")
end
end
@@ -263,7 +266,7 @@ class PagesController < ApplicationController
if page.page_id == "" || page.page_id == nil
false
else
- File.join("../../templates", "#{@key}", '/home/page.html.erb')
+ File.join("../../templates", "#{@key}", "/#{@home}#{$mobile}/page.html.erb")
end
# elsif request[:action] == "show" || request[:action] == "moduleShow"
# File.join("../../templates", "themes", "#{@key}", '/home/page.html.erb')
@@ -281,4 +284,5 @@ class PagesController < ApplicationController
redirect_to '/admin/dashboards'
end
end
+
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 025ae98..4ff629f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -19,7 +19,7 @@ module ApplicationHelper
def render_header
site = Site.first
key = Template::KEY
- header_file = File.join('../templates', "#{key}", '/home/header.html.erb')
+ header_file = File.join('../templates', "#{key}", "/home#{$mobile}/header.html.erb")
header_file_html = render :file => header_file
header = Nokogiri::HTML(header_file_html, nil, "UTF-8")
sub_menu_html = site.sub_menu
@@ -37,7 +37,7 @@ module ApplicationHelper
def render_footer
site = Site.first
key = Template::KEY
- footer_file = File.join('../templates', "#{key}", '/home/footer.html.erb')
+ footer_file = File.join('../templates', "#{key}", "/home#{$mobile}/footer.html.erb")
footer_file_html = render :file => footer_file
footer = Nokogiri::HTML(footer_file_html, nil, "UTF-8")
html = footer.to_s
@@ -74,7 +74,7 @@ module ApplicationHelper
end
@items = create_json(@pages)
key = current_site.template
- menu_file = File.open(File.join(Rails.root, 'app', 'templates', "#{key}", '/home/menu.html.erb'))
+ menu_file = File.open(File.join(Rails.root, 'app', 'templates', "#{key}", "/home#{$mobile}/menu.html.erb"))
doc = Nokogiri::HTML(menu_file, nil, "UTF-8")
menu_file.close
@@ -164,7 +164,7 @@ module ApplicationHelper
if params[:target_action] == "index"
- file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb"))
+ file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize+$mobile, "#{params[:target_action]}.html.erb"))
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
@@ -186,7 +186,7 @@ module ApplicationHelper
end
html.html_safe
elsif params[:target_action] == "show"
- file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb"))
+ file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize+$mobile, "#{params[:target_action]}.html.erb"))
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
diff --git a/app/templates/orbit_bootstrap/home/mobile/footer.html.erb b/app/templates/orbit_bootstrap/home/mobile/footer.html.erb
new file mode 100644
index 0000000..a92bb99
--- /dev/null
+++ b/app/templates/orbit_bootstrap/home/mobile/footer.html.erb
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/app/templates/orbit_bootstrap/home/mobile/header.html.erb b/app/templates/orbit_bootstrap/home/mobile/header.html.erb
new file mode 100644
index 0000000..3b76597
--- /dev/null
+++ b/app/templates/orbit_bootstrap/home/mobile/header.html.erb
@@ -0,0 +1,17 @@
+THIS IS MOBILE HEADER
+
+
+
+ {{site_name}}
+
+
+
{{body}}
+{{answer}}
+