forked from saurabh/orbit4-5
Mobile Web
This commit is contained in:
parent
4cbf7f5015
commit
cb69ea5c5c
|
@ -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
|
||||
|
|
|
@ -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,6 +174,7 @@ class PagesController < ApplicationController
|
|||
parts = page.page_parts rescue []
|
||||
@part_partials = {}
|
||||
|
||||
if $mobile.blank?
|
||||
parts.each do |part|
|
||||
subparts = part.sub_parts
|
||||
partials = []
|
||||
|
@ -194,12 +195,14 @@ class PagesController < ApplicationController
|
|||
end
|
||||
@part_partials["data-pp='#{part.part_id}'"] = partials
|
||||
end
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<footer class="footer">
|
||||
<div class="container footer-inner">
|
||||
<h1>THIS IS MOBILE FOOTER</h1>
|
||||
<div>
|
||||
{{footer-data}}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
|
@ -0,0 +1,17 @@
|
|||
<header class="main-header">
|
||||
<h1>THIS IS MOBILE HEADER</h1>
|
||||
<div class="clearfix">
|
||||
<div class="header-title pull-left">
|
||||
<h1>
|
||||
<a href="/">
|
||||
<img src="{{logo_url}}">
|
||||
<span>{{site_name}}</span>
|
||||
</a>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="header-nav pull-right" >
|
||||
{{header-data}}
|
||||
</div>
|
||||
</div>
|
||||
<%= render_partial("menu") %>
|
||||
</header>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%= render_partial("head") %>
|
||||
</head>
|
||||
<body>
|
||||
<%= render_orbit_bar %>
|
||||
<div class="warp container">
|
||||
<%= render_header %>
|
||||
<!-- Site Banner -->
|
||||
<section class="main-slide" data-pp="4">
|
||||
<%#= render_widget "ad_banner/widget" %>
|
||||
</section><!-- Site Banner end -->
|
||||
<h1>THIS IS MOBILE PAGE</h1>
|
||||
<div class="warp-inner">
|
||||
<div class="row">
|
||||
<section class="home-new col-sm-12" data-pp="1">
|
||||
</section>
|
||||
</div>
|
||||
<div class="row">
|
||||
<section class="section-block col-sm-8">
|
||||
<div class="block-inner" data-pp="2">
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<aside class="aside-block col-sm-4">
|
||||
<div class="block-inner" data-pp="3">
|
||||
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
<%= render_footer %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<ul class="nav navbar-nav" data-menu-level="0">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-menu-link="true">Mobile {{link_name}}</a>
|
||||
<ul class="dropdown-menu" data-menu-level="1">
|
||||
<li>
|
||||
<a href="index.html" data-menu-link="true">Mobile {{link_name}}</a>
|
||||
<ul data-menu-level="2">
|
||||
<li>
|
||||
<a href="index.html" data-menu-link="true">Mobile {{link_name}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%= render_partial("head") %>
|
||||
</head>
|
||||
<body>
|
||||
<%= render_orbit_bar %>
|
||||
<div class="warp container">
|
||||
<%= render_header %>
|
||||
<!-- Site Banner -->
|
||||
<section class="main-slide" data-pp="4">
|
||||
<%#= render_widget "ad_banner/widget" %>
|
||||
</section><!-- Site Banner end -->
|
||||
<h1>THIS IS MOBILE PAGE</h1>
|
||||
<div class="warp-inner">
|
||||
<div class="row">
|
||||
<section class="section-block col-sm-8">
|
||||
<main id="main-content" data-content="true">
|
||||
<%= yield %>
|
||||
<hr class="dotted">
|
||||
</main>
|
||||
<div class="block-inner" data-pp="1">
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<aside class="aside-block col-sm-4">
|
||||
<div class="block-inner" data-pp="2">
|
||||
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
<%= render_footer %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<ul>
|
||||
<li>
|
||||
<a href="">Sitemap</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="">Contact</a>
|
||||
</li>
|
||||
</ul>
|
|
@ -0,0 +1,14 @@
|
|||
<h2 class="widget-title">{{widget-title}}</h2>
|
||||
<h1>ANNOUNCEMENT MOBILE INDEX</h1>
|
||||
<ul class="media-list index" module="announcement" data-repeat="4" data-level="0" data-list="announcements">
|
||||
<li class="media">
|
||||
<a class="pull-left" href="{{link_to_show}}">
|
||||
<img class="media-object" src="{{img_src}}">
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><a href="{{link_to_show}}">{{title}}</a></h4>
|
||||
<p class="date">{{postdate}}</p>
|
||||
<p class="text">{{subtitle}}</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
|
@ -0,0 +1,27 @@
|
|||
<h1>ANNOUNCEMENT MOBILE SHOW</h1>
|
||||
<article class="show" module="announcement">
|
||||
<div class="post-title">
|
||||
<h1>{{title}}</h1>
|
||||
</div>
|
||||
<small class="post-meta-date">
|
||||
<span>
|
||||
TAGS :
|
||||
<span class="post-related" data-list="tags" data-level="0">
|
||||
<a href="#"><span class="label label-info">{{tag}}</span></a>
|
||||
</span>
|
||||
</span>
|
||||
<span class="author">{{update_user}}</span>
|
||||
<span class="unit">AT : unit</span>
|
||||
<span class="date">{{updated_at}}</span>
|
||||
</small>
|
||||
<section class="post">
|
||||
<p class="pic"><img src="{{image}}" alt=""></p>
|
||||
<p>{{body}}</p>
|
||||
</section>
|
||||
<div class="post-related" data-list="bulletin_files" data-level="0">
|
||||
<a href="{{file_url}}">{{file_title}}</a><br/>
|
||||
</div>
|
||||
<div class="post-related" data-list="bulletin_links" data-level="0">
|
||||
<a href="{{link_url}}" target="_blank">{{link_title}}</a><br/>
|
||||
</div>
|
||||
</article>
|
|
@ -0,0 +1,28 @@
|
|||
<div class="index" module="archive">
|
||||
<h2 class="widget-title">{{widget-title}}</h2>
|
||||
<h1>ARCHIVE MOBILE INDEX</h1>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item" data-list="categories" data-level="0">
|
||||
<h4 class="list-group-item-heading">{{category-title}}</h4>
|
||||
<ul class="list-group-item-text">
|
||||
<li data-list="archives" data-level="1">
|
||||
<h5 class="archives-title">
|
||||
{{archive-title}}
|
||||
<span data-list="status" data-level="2">
|
||||
<span class="label label-primary">{{archive-status}}</span>
|
||||
</span>
|
||||
</h5>
|
||||
<ol class="archives-item" data-list="files" data-level="2">
|
||||
<li>
|
||||
<a href="{{file-url}}" class="archives-file" target="_blank" title="Evaluation Rules">{{file-name}}</a>
|
||||
<span class="label label-primary">{{file-type}}</span>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li data-list="cool" data-level="1">
|
||||
<span>This is for test</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
<h2 class="widget-title">{{widget-title}}</h2>
|
||||
<h1>FAQ MOBILE INDEX</h1>
|
||||
<ul class="media-list index" module="faq" data-repeat="4" data-list="data" data-level="0">
|
||||
<li class="media">
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><a href="{{link_to_show}}">{{question}}</a></h4>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
|
@ -0,0 +1,15 @@
|
|||
<article class="show" module="faq">
|
||||
<h1>FAQ MOBILE SHOW</h1>
|
||||
<div class="post-title">
|
||||
<h1>{{question}}</h1>
|
||||
</div>
|
||||
<section class="post">
|
||||
<p>{{answer}}</p>
|
||||
</section>
|
||||
<div class="post-related" data-list="faqs_files" data-level="0">
|
||||
<a href="{{file_url}}" target="_blank">{{file_title}}</a><br/>
|
||||
</div>
|
||||
<div class="post-related" data-list="faqs_links" data-level="0">
|
||||
<a href="{{link_url}}" target="_blank">{{link_title}}</a><br/>
|
||||
</div>
|
||||
</article>
|
|
@ -0,0 +1,12 @@
|
|||
<div class="index" module="gallery">
|
||||
<h2 class="widget-title">{{widget-title}}</h2>
|
||||
<h1>GALLERY MOBILE INDEX</h1>
|
||||
<ul class="row" data-list="data" data-level="0">
|
||||
<li class="col-md-3 col-sm-4 col-xs-3">
|
||||
<a href="{{link_to_show}}">
|
||||
<img class="img-rounded" src="{{thumb-src}}" width="200px" height="200px" alt="">
|
||||
</a>
|
||||
<h4 class="album-name">{{album-name}}</h4>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<div class="index" module="gallery">
|
||||
<h2 class="widget-title">{{album-title}}</h2>
|
||||
<h1>GALLERY MOBILE SHOW</h1>
|
||||
<ul class="row" data-list="images" data-level="0">
|
||||
<li class="col-md-3 col-sm-4 col-xs-3">
|
||||
<a href="{{link_to_show}}">
|
||||
<img class="img-rounded" src="{{thumb-src}}" alt="">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
<div class="index" module="link">
|
||||
<h2 class="widget-title">{{widget-title}}</h2>
|
||||
<h1>WEB-RESOURCE MOBILE INDEX</h1>
|
||||
<ul class="link-list" module="link" data-repeat="4" data-level="0" data-list="web_link">
|
||||
<li class="item">
|
||||
<span class="title"><a href="{{link_to_show}}" target="_blank">{{title}}</a></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -39,6 +39,10 @@ class ImageUploader < CarrierWave::Uploader::Base
|
|||
process :resize_to_fit => [200, 200]
|
||||
end
|
||||
|
||||
version :mobile do
|
||||
process :resize_to_limit => [1152, 768]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
|
|
|
@ -188,6 +188,10 @@ Orbit::Application.routes.draw do
|
|||
get 'design_list' => 'designs#design_list'
|
||||
get 'module_store' => 'module_store#index'
|
||||
end
|
||||
|
||||
get 'mobile', to: 'pages#home'
|
||||
get 'mobile/:page(/:page)(/:page)(/:page)', to: 'pages#show', constraints: KeywordConstraint.new
|
||||
|
||||
get ':page(/:page)(/:page)(/:page)', to: 'pages#show', constraints: KeywordConstraint.new
|
||||
resources :pages
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue