parent
f1c628f2d6
commit
fcbba6660b
|
@ -15,4 +15,5 @@
|
|||
*= require scroll_style
|
||||
*= require isotope
|
||||
*= require icons
|
||||
*= require site-map
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class Admin::SitesController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!, :except => [:sitemap_frontend]
|
||||
before_filter :is_admin?, :except => [:sitemap_frontend]
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :get_site
|
||||
|
||||
# def index
|
||||
|
@ -31,18 +31,13 @@ class Admin::SitesController < ApplicationController
|
|||
@items = get_homepage.children rescue []
|
||||
end
|
||||
|
||||
def sitemap_frontend
|
||||
@items = get_homepage.children.excludes(sitemap_enabled: false) rescue []
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def sitemap_toggle
|
||||
@item = Item.find(params[:id])
|
||||
@item.sitemap_enabled = !@item.sitemap_enabled
|
||||
@item.sitemap_enabled[params[:temp_locale]] = (!@item.show_in_sitemap_for(params[:temp_locale])).to_s
|
||||
@item.save
|
||||
if params[:parent]
|
||||
@item.children.each do |child|
|
||||
child.sitemap_enabled = @item.sitemap_enabled
|
||||
child.sitemap_enabled[params[:temp_locale]] = @item.sitemap_enabled[params[:temp_locale]].to_s
|
||||
child.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -119,7 +119,7 @@ class ApplicationController < ActionController::Base
|
|||
def render_page
|
||||
if @item
|
||||
respond_to do |format|
|
||||
format.html { render :text => parse_page_noko(@item), :layout => 'page_layout' }
|
||||
format.html { render :text => parse_page_content(@item), :layout => 'page_layout' }
|
||||
format.rss { render_main_rss }
|
||||
end
|
||||
else
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
class FrontController < ApplicationController
|
||||
|
||||
layout false
|
||||
|
||||
def show_banner
|
||||
@ad_banner = AdBanner.find(params[:id]) rescue nil
|
||||
end
|
||||
|
||||
def show_footer
|
||||
render :text => @site.footer
|
||||
end
|
||||
|
||||
def show_menu
|
||||
page = Page.find(params[:id]) rescue nil
|
||||
render :text => menu_level(Page.root, page, 1, page.design.layout.menu) if page
|
||||
end
|
||||
|
||||
def show_site_sub_menu
|
||||
render :text => @site.sub_menu
|
||||
end
|
||||
|
||||
def show_sitemap
|
||||
@items = get_homepage.children.excludes(sitemap_enabled: false) rescue []
|
||||
end
|
||||
|
||||
def show_page_sub_menu
|
||||
@menu_page = Page.find(params[:menu_page_id]) rescue nil
|
||||
@page_id = params[:page_id]
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def menu_level(page, current_page, current, menu)
|
||||
res = ''
|
||||
if page.visible_children.size > 0
|
||||
res << "<ul class='"
|
||||
res << menu.values["class_#{current}"] rescue nil
|
||||
res << "'>"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
children = current == 1 ? page.visible_children.reverse : page.visible_children
|
||||
children.each do |child|
|
||||
res << menu_li(child, current_page, current, menu, i)
|
||||
i += 1 if i
|
||||
end
|
||||
if menu.values['home'] && current == 1
|
||||
res << menu_li(page, current_page, current, menu, i)
|
||||
end
|
||||
res << "</ul>"
|
||||
end
|
||||
res
|
||||
end
|
||||
|
||||
def menu_li(page, current_page, current, menu, i)
|
||||
res = "<li class='"
|
||||
res << menu.values["li_class_#{current}"] rescue nil
|
||||
res << "_#{i}" if i
|
||||
res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page))
|
||||
res << "'>"
|
||||
root = "/"
|
||||
res << "<a href='#{(page.class.to_s.eql?('Page') ? root + page.path : page.url)}'><span>#{page.title}</span></a>"
|
||||
if page.visible_children.size > 0 && current < menu.levels
|
||||
res << "<span class='dot'></span>"
|
||||
res << menu_level(page, current_page, current + 1, menu)
|
||||
end unless (page.root? rescue nil)
|
||||
res << "</li>"
|
||||
end
|
||||
|
||||
end
|
|
@ -29,63 +29,62 @@ class PagesController < ApplicationController
|
|||
else
|
||||
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
end
|
||||
#rescue
|
||||
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
#end
|
||||
end
|
||||
#rescue
|
||||
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
#end
|
||||
end
|
||||
|
||||
def index_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
|
||||
uri = URI::escape(url + options)
|
||||
#uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&'))
|
||||
redirect_to(uri)unless save_from_no_lang_for_page
|
||||
end
|
||||
def index_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
|
||||
uri = URI::escape(url + options)
|
||||
#uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&'))
|
||||
redirect_to(uri)unless save_from_no_lang_for_page
|
||||
end
|
||||
|
||||
def show_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}id=#{params[:id]}" unless params[:id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}preview=#{params[:preview]}" unless params[:preview].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}controller_action=#{params[:controller_action]}" unless params[:controller_action].blank?
|
||||
redirect_to(url + options) unless save_from_no_lang_for_page
|
||||
end
|
||||
def show_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}id=#{params[:id]}" unless params[:id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}preview=#{params[:preview]}" unless params[:preview].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}controller_action=#{params[:controller_action]}" unless params[:controller_action].blank?
|
||||
redirect_to(url + options) unless save_from_no_lang_for_page
|
||||
end
|
||||
|
||||
def load_orbit_bar
|
||||
render :partial => 'layouts/orbit_bar', :locals => {:referer => request.referer}
|
||||
end
|
||||
def load_orbit_bar
|
||||
render :partial => 'layouts/orbit_bar', :locals => {:referer => request.referer}
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_item
|
||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||
if !params[:category_id].blank? && !params[:tag_id].blank?
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
|
||||
elsif !params[:category_id].blank?
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first
|
||||
elsif !params[:tag_id].blank?
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
|
||||
end
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
||||
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_item
|
||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||
if !params[:category_id].blank? && !params[:tag_id].blank?
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
|
||||
elsif !params[:category_id].blank?
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first
|
||||
elsif !params[:tag_id].blank?
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
|
||||
end
|
||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
||||
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
||||
end
|
||||
|
||||
def save_from_no_lang_for_page
|
||||
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
|
||||
flash[:error] = t('sys.module_page_lang_not_support')
|
||||
redirect_to '/'
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
|
||||
flash[:error] = t('sys.module_page_lang_not_support')
|
||||
redirect_to '/'
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class Item
|
|||
field :enabled_for, :type => Array, :default => nil
|
||||
field :menu_enabled_for, :type => Array, :default => nil
|
||||
field :title, localize: true
|
||||
field :sitemap_enabled, :type => Boolean, :default => true
|
||||
field :sitemap_enabled, :type => Hash
|
||||
|
||||
|
||||
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
|
||||
|
@ -53,12 +53,29 @@ class Item
|
|||
save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show_in_sitemap_for(locale)
|
||||
if !sitemap_enabled[locale].blank?
|
||||
sitemap_enabled[locale].eql?('true') ? true : false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def rebuild_path
|
||||
self.path = (self.ancestors_and_self - [Item.root]).collect{|x| x.name unless x.root?}.join('/')
|
||||
self.rebuild_children_path
|
||||
end
|
||||
|
||||
def rebuild_children_path
|
||||
self.children.each do |child|
|
||||
child.path = (child.ancestors_and_self - [Item.root]).collect{|x| x.name}.join('/')
|
||||
child.save
|
||||
child.rebuild_children_path
|
||||
end
|
||||
end
|
||||
|
||||
def find_by_parent_and_position(parent, position)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
class Page < Item
|
||||
include Rails.application.routes.url_helpers
|
||||
include Impressionist::Impressionable
|
||||
include ParserFrontEnd
|
||||
|
||||
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||
|
||||
field :content
|
||||
field :content, localize: true
|
||||
field :app_frontend_url
|
||||
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||
field :category, :default => ''
|
||||
|
@ -17,40 +19,34 @@ class Page < Item
|
|||
|
||||
belongs_to :design
|
||||
belongs_to :module_app
|
||||
has_many :page_parts, :autosave => true, :dependent => :destroy
|
||||
has_many :page_parts, :dependent => :destroy
|
||||
has_many :page_contexts, :autosave => true, :dependent => :destroy
|
||||
has_many :page_metas, :autosave => true, :dependent => :destroy
|
||||
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
||||
|
||||
before_save :create_parts, :delete_empty_frontend_field
|
||||
|
||||
# embeds_many :custom_images, :class_name => 'Image', as: :design_image
|
||||
|
||||
def generate_parts
|
||||
page_design = self.design
|
||||
page_design.layout.layout_parts.each do |layout_part|
|
||||
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
|
||||
current_part = self.page_parts.build(:name => layout_part.name) unless current_part
|
||||
current_part.save if current_part.new_record?
|
||||
end
|
||||
end
|
||||
before_save :delete_empty_frontend_field
|
||||
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
|
||||
after_save :generate_html
|
||||
|
||||
protected
|
||||
|
||||
def create_parts
|
||||
if self.new_record? || self.design_id_changed?
|
||||
page_design = self.design
|
||||
parent = self.parent
|
||||
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
||||
page_design.layout.layout_parts.each do |layout_part|
|
||||
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
|
||||
current_part = self.page_parts.build(:name => layout_part.name) unless current_part
|
||||
if menu_part && current_part.name.eql?(menu_part.name)
|
||||
if current_part.new_record?
|
||||
current_part.kind = menu_part.kind
|
||||
current_part.public_r_tag = menu_part.public_r_tag
|
||||
current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id
|
||||
else
|
||||
page_design = self.design
|
||||
parent = self.parent
|
||||
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
||||
page_design.layout.layout_parts.each do |layout_part|
|
||||
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
|
||||
current_part = self.page_parts.build(:name => layout_part.name) unless current_part
|
||||
if menu_part && current_part.name.eql?(menu_part.name)
|
||||
if current_part.new_record?
|
||||
current_part.kind = menu_part.kind
|
||||
current_part.public_r_tag = menu_part.public_r_tag
|
||||
current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id
|
||||
PagePart.without_callback(:save, :after, :update_parent) do
|
||||
current_part.save
|
||||
end
|
||||
else
|
||||
PagePart.without_callback(:save, :after, :update_parent) do
|
||||
current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id)
|
||||
end
|
||||
end
|
||||
|
@ -69,5 +65,12 @@ class Page < Item
|
|||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def generate_html
|
||||
Page.without_callback(:save, :after, :generate_html) do
|
||||
self.content_translations = parse_page_noko(self, Site.first)
|
||||
self.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,6 +20,7 @@ class PagePart
|
|||
belongs_to :module_app
|
||||
|
||||
before_save :delete_empty_widget_field
|
||||
after_save :update_parent
|
||||
|
||||
protected
|
||||
|
||||
|
@ -30,4 +31,8 @@ class PagePart
|
|||
# self.widget_field.delete("") if self.widget_field
|
||||
end
|
||||
|
||||
def update_parent
|
||||
self.page.save
|
||||
end
|
||||
|
||||
end
|
|
@ -138,7 +138,7 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title",params[:ad_banner_id]) , :class=>"input-medium", %>
|
||||
<%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title",params[:ad_banner_id]) , :class=>"input-medium" %>
|
||||
<% @site_valid_locales.each do |locale|%>
|
||||
<%= content_tag :div,:class => "tab-pane #{active_when_current_locale_eq locale}",:id=>"#{locale}" do%>
|
||||
<div class="title">
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<div class="map-block <%= 'disabled' if !sitemap_block.sitemap_enabled %>">
|
||||
<div class="map-block <%= 'disabled' if !sitemap_block.show_in_sitemap_for(temp_locale) %>">
|
||||
<h4>
|
||||
<button id="<%= sitemap_block.id %>" class="onoff pull-right"><%= sitemap_block.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button>
|
||||
<span><%= sitemap_block_counter + 1 %> <%= sitemap_block.title %></span>
|
||||
<button id="<%= sitemap_block.id %>" class="onoff pull-right" temp_locale="<%= temp_locale %>"><%= sitemap_block.show_in_sitemap_for(temp_locale) ? t('on_upcase') : t('off_upcase') %></button>
|
||||
<span><%= sitemap_block_counter + 1 %> <%= sitemap_block.title_translations[temp_locale] %></span>
|
||||
</h4>
|
||||
<ul>
|
||||
<% sitemap_block.children.each_with_index do |child, i| %>
|
||||
<li class="clear <%= 'disabled' if !child.sitemap_enabled %>">
|
||||
<%= content_tag :button, :id => child.id, :class => "onoff pull-right", :disabled => !sitemap_block.sitemap_enabled do %>
|
||||
<%= child.sitemap_enabled ? t('on_upcase') : t('off_upcase') %>
|
||||
<li class="clear <%= 'disabled' if !child.show_in_sitemap_for(temp_locale) %>">
|
||||
<%= content_tag :button, :id => child.id, :class => "onoff pull-right", :temp_locale => temp_locale, :disabled => !child.show_in_sitemap_for(temp_locale) do %>
|
||||
<%= child.show_in_sitemap_for(temp_locale) ? t('on_upcase') : t('off_upcase') %>
|
||||
<% end %>
|
||||
<span><%= "#{sitemap_block_counter + 1}-#{i + 1}" %> <%= child.title %></span>
|
||||
<span><%= "#{sitemap_block_counter + 1}-#{i + 1}" %> <%= child.title_translations[temp_locale] %></span>
|
||||
</li>
|
||||
<% end if sitemap_block.children %>
|
||||
</ul>
|
||||
|
|
|
@ -2,9 +2,18 @@
|
|||
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div class="site-map">
|
||||
<%= render :partial => 'sitemap_block', :collection => @items %>
|
||||
<ul class="nav nav-tabs">
|
||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||
<li <%= ( i == 0 ) ? " class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<% @site_valid_locales.each_with_index do |temp_locale, i| %>
|
||||
<div class="tab-pane site-map <%= temp_locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
<%= render :partial => 'sitemap_block', :collection => @items, :locals => {:temp_locale => temp_locale} %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
|
@ -13,9 +22,14 @@
|
|||
$(document).ready(function(){
|
||||
$('.site-map').masonry({
|
||||
itemSelector: '.map-block',
|
||||
columnWidth: 260,
|
||||
isAnimated: true
|
||||
columnWidth: 260
|
||||
});
|
||||
$('a[data-toggle="tab"]').on('shown', function (e) {
|
||||
$('.site-map').masonry({
|
||||
itemSelector: '.map-block',
|
||||
columnWidth: 260
|
||||
});
|
||||
})
|
||||
});
|
||||
$(document).on('click', 'li .onoff', function () {
|
||||
$(this).parents("li").toggleClass("disabled");
|
||||
|
@ -24,7 +38,7 @@
|
|||
} else {
|
||||
$(this).text("<%= t('on_upcase') %>")
|
||||
}
|
||||
$.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle');
|
||||
$.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?temp_locale=' + $(this).attr('temp_locale'));
|
||||
});
|
||||
$(document).on('click', 'h4 .onoff', function () {
|
||||
$(this).parents(".map-block").toggleClass("disabled");
|
||||
|
@ -39,7 +53,7 @@
|
|||
$(this).parents(".map-block").find('button').text("<%= t('on_upcase') %>")
|
||||
$(this).parents(".map-block").find('li button').removeAttr("disabled")
|
||||
}
|
||||
$.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?parent=true');
|
||||
$.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?parent=true&temp_locale=' + $(this).attr('temp_locale'));
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
|
@ -0,0 +1,26 @@
|
|||
<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>
|
||||
<script type='text/javascript'>
|
||||
jQuery(function( $ ){
|
||||
|
||||
$('#slideshow-<%= @ad_banner.title.dehumanize %>').cycle({
|
||||
delay: -1000,
|
||||
fx: "<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
|
||||
timeoutFn: getTimeout,
|
||||
pager: '.banner_nav-<%= @ad_banner.title.dehumanize %>',
|
||||
pagerAnchorBuilder: function(idx, slide) {
|
||||
return "<li><a href='#'></a></li>";
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div style='position:relative'>
|
||||
<ul id='banner_nav' class='clear banner_nav-<%= @ad_banner.title.dehumanize %>'></ul>
|
||||
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'>
|
||||
<% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %>
|
||||
<% if ad_image.display? %>
|
||||
<img src='<%= ad_image.file %>' alt='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= (ad_image.direct_to_after_click? ? ad_image.out_link : ad_image.context) || ' ' %>' link_url='<%= (ad_image.out_link) %>' style=' <%= 'cursor:pointer;' if !ad_image.out_link.blank? %>'/>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
<% if @menu_page && @menu_page.visible_children.size > 0 %>
|
||||
<div class='category_list'>
|
||||
<h3 class='h3'><%= @menu_page.title} %></h3>
|
||||
<ul class='list'>"
|
||||
<% menu_page.visible_children.each do |child| %>
|
||||
<li class="<%= @page_id.eql?(child.id) ? 'active' : nil %>">
|
||||
<a href="<%= (child.class.to_s.eql?('Page') ? '/' + child.path : child.url) %>"><%= child.title %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,27 @@
|
|||
<div class="site-map">
|
||||
<% @items.each_with_index do |item, i| %>
|
||||
<% if item.show_in_sitemap_for(I18n.locale.to_s) %>
|
||||
<div class="map-block">
|
||||
<h4><%= i+1 %> <a href='<%= item.path %>'><%= item.title %></a></h4>
|
||||
<ul>
|
||||
<% item.children.each_with_index do |child, ii| %>
|
||||
<% if child.show_in_sitemap_for(I18n.locale.to_s) %>
|
||||
<li class="clear"><%= "#{i+1}-#{ii+1}" %> <a href='<%= child.path %>'><%= child.title %></a></span></li>
|
||||
<% end %>
|
||||
<% end if item.children %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= javascript_include_tag "lib/jquery.masonry.min.js" %>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('.site-map').masonry({
|
||||
itemSelector: '.map-block',
|
||||
columnWidth: 220,
|
||||
isAnimated: true
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -162,7 +162,8 @@ Orbit::Application.routes.draw do
|
|||
post 'upload'
|
||||
end
|
||||
end
|
||||
match "desktop" => "desktop#index"
|
||||
|
||||
match "desktop" => "desktop#index"
|
||||
namespace :desktop do
|
||||
match "desktop" => "desktop#desktop"
|
||||
match '/journal_pages/get_journals_json' => 'journal_pages#get_journals_json'
|
||||
|
@ -231,6 +232,14 @@ Orbit::Application.routes.draw do
|
|||
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
|
||||
|
||||
|
||||
scope '/front' do
|
||||
match 'show_banner/:id' => 'front#show_banner', :as => :front_show_banner
|
||||
match 'show_footer' => 'front#show_footer', :as => :front_show_footer
|
||||
match 'show_menu/:id' => 'front#show_menu', :as => :front_show_menu
|
||||
match 'show_page_sub_menu' => 'front#show_page_sub_menu', :as => :front_show_page_sub_menu
|
||||
match 'show_site_sub_menu' => 'front#show_site_sub_menu', :as => :front_show_site_sub_menu
|
||||
match 'show_sitemap' => 'front#show_sitemap', :as => :front_show_sitemap
|
||||
end
|
||||
|
||||
|
||||
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
|
||||
|
|
|
@ -25,13 +25,13 @@ module ParserBackEnd
|
|||
|
||||
def parse_page_edit_noko(page)
|
||||
body = Nokogiri::HTML(page.design.layout.body)
|
||||
parse_menu(body, page, true)
|
||||
public_r_tags = parse_contents(body, page, true)
|
||||
parse_images(body, page)
|
||||
parse_footer(body, page)
|
||||
parse_sub_menu(body, page)
|
||||
parse_menu_edit(body, page, true)
|
||||
public_r_tags = parse_contents_edit(body, page, true)
|
||||
parse_images_edit(body, page)
|
||||
parse_footer_edit(body, page)
|
||||
parse_sub_menu_edit(body, page)
|
||||
public_r_tags.each do |tag|
|
||||
send("parse_#{tag}s", body, page, true)
|
||||
send("parse_#{tag}s_edit", body, page, true)
|
||||
end
|
||||
body.to_html
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ module ParserCommon
|
|||
end
|
||||
|
||||
# ad_banners
|
||||
def parse_ad_banners(body = nil, page = nil, edit=nil)
|
||||
def parse_ad_banners_edit(body = nil, page = nil, edit=nil)
|
||||
body.css('ad_banner').each do |banner|
|
||||
res = ''
|
||||
ad_banner = AdBanner.find(banner["id"]) rescue nil
|
||||
|
@ -94,7 +94,7 @@ module ParserCommon
|
|||
end
|
||||
|
||||
# page_images
|
||||
def parse_images(body, page, edit=nil)
|
||||
def parse_images_edit(body, page, edit=nil)
|
||||
body.css('.page_image').each do |page_image|
|
||||
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
||||
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
|
@ -112,20 +112,16 @@ module ParserCommon
|
|||
end
|
||||
|
||||
# page_menu
|
||||
def parse_menu(body, page, edit=nil)
|
||||
def parse_menu_edit(body, page, edit=nil)
|
||||
page_menu = body.css('.page_menu').first
|
||||
if page_menu
|
||||
home = get_homepage
|
||||
menu = page.design.layout.menu
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, page, 1, menu, edit))
|
||||
page_menu.swap(fragment)
|
||||
else
|
||||
''
|
||||
end
|
||||
home = get_homepage
|
||||
menu = page.design.layout.menu
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, page, 1, menu, edit))
|
||||
page_menu.swap(fragment)
|
||||
end
|
||||
|
||||
# sub_menus
|
||||
def parse_sub_menus(body = nil, page = nil, edit=nil)
|
||||
def parse_sub_menus_edit(body = nil, page = nil, edit=nil)
|
||||
body.css('sub_menu').each do |sub_menu|
|
||||
menu_page = Page.find(sub_menu['id']) rescue nil
|
||||
res = ''
|
||||
|
@ -149,7 +145,7 @@ module ParserCommon
|
|||
end
|
||||
|
||||
# page_footer
|
||||
def parse_footer(body, page)
|
||||
def parse_footer_edit(body, page)
|
||||
page_footer = body.css('.page_footer').first
|
||||
if page_footer
|
||||
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
|
||||
|
@ -163,7 +159,7 @@ module ParserCommon
|
|||
end
|
||||
|
||||
# page_sub_menu
|
||||
def parse_sub_menu(body, page)
|
||||
def parse_sub_menu_edit(body, page)
|
||||
page_sub_menu = body.css('.page_sub_menu').first
|
||||
if page_sub_menu
|
||||
res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>"
|
||||
|
@ -177,20 +173,16 @@ module ParserCommon
|
|||
end
|
||||
|
||||
# sitemap
|
||||
def parse_sitemaps(body = nil, page = nil, edit=nil)
|
||||
def parse_sitemaps_edit(body = nil, page = nil, edit=nil)
|
||||
sitemap = body.css('sitemap').first
|
||||
if sitemap
|
||||
url = admin_site_sitemap_frontend_path(@site)
|
||||
options = "?inner=true"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load' path='#{url + options}'></div>")
|
||||
sitemap.swap(fragment)
|
||||
else
|
||||
''
|
||||
end
|
||||
url = admin_site_sitemap_frontend_path(@site)
|
||||
options = "?inner=true"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load' path='#{url + options}'></div>")
|
||||
sitemap.swap(fragment)
|
||||
end
|
||||
|
||||
# page_contents
|
||||
def parse_contents(body, page, edit=nil)
|
||||
def parse_contents_edit(body, page, edit=nil)
|
||||
public_r_tags = []
|
||||
body.css('.page_content').each do |content|
|
||||
ret = ''
|
||||
|
@ -199,7 +191,6 @@ module ParserCommon
|
|||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||
ret << "/#{params[:controller_action]}" if params[:controller_action] && params[:id]
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}&name=#{params[:name]}"
|
||||
ret << "'></div>"
|
||||
else
|
||||
|
@ -216,7 +207,7 @@ module ParserCommon
|
|||
ret << part.content rescue ''
|
||||
when 'module_widget'
|
||||
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&part_id=#{part.id}"
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
|
||||
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
|
|
|
@ -1,38 +1,139 @@
|
|||
module ParserFrontEnd
|
||||
include ParserCommon
|
||||
# c.define_tag 'language_bar' do
|
||||
# @site.in_use_locales.map{ |locale|
|
||||
# lang = I18nVariable.first(:conditions => {:key => locale})[locale]
|
||||
# if I18n.locale.to_s.eql?(locale)
|
||||
# lang
|
||||
# else
|
||||
# "<a href='?locale=#{locale}'>#{lang}</a>"
|
||||
# end
|
||||
# }.join(' | ')
|
||||
# end
|
||||
# c.define_tag 'link' do |tag|
|
||||
# item = Item.first(:conditions => { :path => tag.attr['name'] })
|
||||
# ret = ''
|
||||
# ret << "<a href='#{tag.attr['name']}'>"
|
||||
# ret << item.i18n_variable[I18n.locale]
|
||||
# ret << '</a>'
|
||||
# end
|
||||
# end
|
||||
|
||||
require 'nokogiri'
|
||||
|
||||
def parse_page_noko(page)
|
||||
body = Nokogiri::HTML(page.design.layout.body)
|
||||
parse_menu(body, page)
|
||||
public_r_tags = parse_contents(body, page)
|
||||
parse_images(body, page)
|
||||
parse_footer(body, page)
|
||||
parse_sub_menu(body, page)
|
||||
public_r_tags.each do |tag|
|
||||
send("parse_#{tag}s", body, page)
|
||||
def parse_page_noko(page, site)
|
||||
i18n = {}
|
||||
Site.first.valid_locales.each do |locale|
|
||||
body = Nokogiri::HTML(page.design.layout.body)
|
||||
parse_contents(body, page, locale)
|
||||
parse_footer(body, page, site)
|
||||
parse_images(body, page)
|
||||
parse_menu(body, page)
|
||||
parse_sub_menu(body, page, site)
|
||||
i18n.merge!({locale => body.to_html})
|
||||
end
|
||||
i18n
|
||||
end
|
||||
|
||||
def parse_page_content(page)
|
||||
category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
||||
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
||||
body = Nokogiri::HTML(page.content)
|
||||
body.css('orbit_front').each do |front|
|
||||
ret = ''
|
||||
part = PagePart.find(front['part_id']) if front['part_id']
|
||||
ret << eval("\"#{front['path']}\"") rescue ''
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>")
|
||||
front.swap(fragment)
|
||||
end
|
||||
body.to_html
|
||||
end
|
||||
|
||||
|
||||
# page_footer
|
||||
def parse_footer(body, page, site)
|
||||
page_footer = body.css('.page_footer').first
|
||||
if page_footer
|
||||
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
|
||||
res << "<div class='dymanic_load' path='#{front_show_footer_path}'></div>"
|
||||
res << "</div>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||
page_footer.swap(fragment) rescue nil
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
# page_images
|
||||
def parse_images(body, page, edit=nil)
|
||||
body.css('.page_image').each do |page_image|
|
||||
image = page.design.images.detect{|image| image.name.eql?(File.basename(page_image['src'])) } unless image
|
||||
if image
|
||||
res = "<img src=#{image.file.url} "
|
||||
page_image.attributes.each do |l|
|
||||
res << "#{l[0]}='#{l[1]}' "
|
||||
end
|
||||
res << '>'
|
||||
end
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||
page_image.swap(fragment)
|
||||
end
|
||||
end
|
||||
|
||||
# page_menu
|
||||
def parse_menu(body, page)
|
||||
page_menu = body.css('.page_menu').first
|
||||
if page_menu
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load' path='#{front_show_menu_path(page.id)}'></div>")
|
||||
page_menu.swap(fragment)
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# page_sub_menu
|
||||
def parse_sub_menu(body, page, site)
|
||||
page_sub_menu = body.css('.page_sub_menu').first
|
||||
if page_sub_menu
|
||||
res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>"
|
||||
res << "<div class='dymanic_load' path='#{front_show_site_sub_menu_path}'></div>"
|
||||
res << "</div>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||
page_sub_menu.swap(fragment)
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
# page_contents
|
||||
def parse_contents(body, page, edit=nil, locale)
|
||||
public_r_tags = []
|
||||
body.css('.page_content').each do |content|
|
||||
ret = ''
|
||||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}?inner=true"
|
||||
options = "&page_id=#{page.id}&category_id=\#{category}&tag_id=\#{tag}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}"
|
||||
ret << "<orbit_front path='#{url + options}'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
case part.kind
|
||||
when 'text'
|
||||
ret << part.content_translations[locale.to_s] rescue ''
|
||||
when 'module_widget'
|
||||
url = "/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
||||
options = "&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}"
|
||||
ret << "<orbit_front path='#{url + options}' part_id=#{part.id}></div>"
|
||||
when 'public_r_tag'
|
||||
ret << send("generate_#{part.public_r_tag}s", part.public_r_tag_object_id, page)
|
||||
else
|
||||
''
|
||||
end if part
|
||||
end
|
||||
scope = "<#{content.name}"
|
||||
content.attributes.each_pair do |key, value|
|
||||
scope << " #{key}='#{value}'"
|
||||
end
|
||||
scope << ">#{ret}</#{content.name}>"
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
|
||||
content.swap(fragment)
|
||||
end
|
||||
end
|
||||
|
||||
# ad_banners
|
||||
def generate_ad_banners(*args)
|
||||
"<div class='dymanic_load' path='#{front_show_banner_path(args[0])}'></div>"
|
||||
end
|
||||
|
||||
# sitemap
|
||||
def generate_sitemaps(*args)
|
||||
"<div class='dymanic_load' path='#{front_show_sitemap_path}'></div>"
|
||||
end
|
||||
|
||||
# sub_menus
|
||||
def generate_sub_menus(*args)
|
||||
"<div class='dymanic_load' path='#{front_show_page_sub_menu_path({:menu_page_id => args[0], :page_id => args[1]})}'></div>"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -304,5 +304,12 @@ namespace :migrate do
|
|||
i += 1
|
||||
end if news_bulletins
|
||||
end
|
||||
|
||||
task :sitemap_i18n => :environment do
|
||||
Item.all.each do |item|
|
||||
item.sitemap_enabled = item.sitemap_enabled ? {'en' => 'true', 'zh_tw' => 'true'} : nil
|
||||
item.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<div class="widget-action clear">
|
||||
<a href="#" class="action"><i title="Set the announcement to start and end dates" class="icon-exclamation-sign icon-white tip"></i></a>
|
||||
</div>
|
||||
<h3 class="widget-title"><i class="icons-calendar"></i><%= t(:date) %></h3>
|
||||
<h3 class="widget-title"><i class="icons-calendar"></i><%= t(:date_) %></h3>
|
||||
<div class="widget-content clear">
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t(:start) %></label>
|
||||
|
|
Loading…
Reference in New Issue